nakarte

Source code of https://map.sikmir.ru (fork)
git clone git://git.sikmir.ru/nakarte
Log | Files | Refs | LICENSE

commit 4fbced062639efcebd09556e87854adc87060c60
parent eedc523f9fd37b8fd3cbdf0bb8ba9d84c6d46b64
Author: Sergej Orlov <wladimirych@gmail.com>
Date:   Wed, 17 Dec 2025 22:54:31 +0100

JNX: allow to correct jnx scale for Garmin GPSMAP 67

Diffstat:
Msrc/lib/leaflet.control.jnx/control.css | 5+++++
Msrc/lib/leaflet.control.jnx/control.html | 4++++
Msrc/lib/leaflet.control.jnx/index.js | 3++-
Msrc/lib/leaflet.control.jnx/jnx-encoder.js | 9+++++++--
Msrc/lib/leaflet.control.jnx/jnx-maker.js | 8++++++--
5 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/src/lib/leaflet.control.jnx/control.css b/src/lib/leaflet.control.jnx/control.css @@ -69,6 +69,11 @@ opacity: unset; } +.leaflet-control-jnx .cb-fix-zoom { + margin-left: 0; + vertical-align: bottom; +} + .leaflet-control-jnx .bottom-row { position: relative; text-align: center; diff --git a/src/lib/leaflet.control.jnx/control.html b/src/lib/leaflet.control.jnx/control.html @@ -40,6 +40,10 @@ </div> </div> + <div class="row"> + <label><input class="cb-fix-zoom" type="checkbox" data-bind="checked: fixZoom"> Fix zoom for GPSMAP 67</label> + </div> + <div class="bottom-row row"> <a class="text-button" data-bind=" click: makeJnx, diff --git a/src/lib/leaflet.control.jnx/index.js b/src/lib/leaflet.control.jnx/index.js @@ -25,6 +25,7 @@ L.Control.JNX = L.Control.extend({ this.areaSelectorVisible = ko.observable(false); this.zoomLevel = ko.observable(null); this.zoomChoices = ko.observable(null); + this.fixZoom = ko.observable(false); }, getLayerForJnx: function () { @@ -136,7 +137,7 @@ L.Control.JNX = L.Control.extend({ zoom, bounds, }); - makeJnxFromLayer(layer, layerName, zoom, bounds, this.notifyProgress.bind(this)) + makeJnxFromLayer(layer, layerName, zoom, bounds, this.fixZoom(), this.notifyProgress.bind(this)) .then((fileData) => { saveAs(fileData, fileName, true); this.fire('tileExportEnd', {eventId, success: true}); diff --git a/src/lib/leaflet.control.jnx/jnx-encoder.js b/src/lib/leaflet.control.jnx/jnx-encoder.js @@ -10,11 +10,12 @@ function jnxCoordinates(extents) { } const JnxWriter = L.Class.extend({ - initialize: function(productName, productId, zOrder) { + initialize: function(productName, productId, zOrder, scaleMultiplier = 1) { this.tiles = {}; this.productName = productName || 'Raster map'; this.productId = productId || 0; this.zOrder = zOrder; + this.scaleMultiplier = scaleMultiplier; }, addTile: function(tileData, level, latLngBounds) { @@ -101,7 +102,11 @@ const JnxWriter = L.Class.extend({ level = parseInt(level, 10); stream.writeInt32(this.tiles[level].length); stream.writeUint32(tileDescriptorOffset); - jnxScale = 34115555 / (2 ** level) * Math.cos((north + south) / 2 / 180 * Math.PI) / 1.1; + jnxScale = + 34115555 / + (2 ** level) * + Math.cos((north + south) / 2 / 180 * Math.PI) / + 1.1 * this.scaleMultiplier; stream.writeInt32(jnxScale); stream.writeInt32(2); stream.writeUint8(0); diff --git a/src/lib/leaflet.control.jnx/jnx-maker.js b/src/lib/leaflet.control.jnx/jnx-maker.js @@ -55,10 +55,14 @@ function ensureImageJpg(image) { return null; } -async function makeJnxFromLayer(srcLayer, layerName, maxZoomLevel, latLngBounds, progress) { +async function makeJnxFromLayer( + srcLayer, layerName, maxZoomLevel, latLngBounds, correctZoom, progress +) { const jnxProductId = L.stamp(srcLayer); const jnxZOrder = Math.min(jnxProductId, 100); - const writer = new JnxWriter(layerName, jnxProductId, jnxZOrder); + // scale multiplier for GPSMAP 67 + const scaleMultiplier = correctZoom ? 3.5 : 1; + const writer = new JnxWriter(layerName, jnxProductId, jnxZOrder, scaleMultiplier); const xhrQueue = new XHRQueue(); let doStop = false; let error;