From c93548aa544af84f9cf11b5937038d656b6b4aed Mon Sep 17 00:00:00 2001 From: Siamak Date: Sun, 10 Jan 2021 14:39:37 +0330 Subject: [PATCH 1/6] fix: adding isNaN to noValueData min/max filter --- src/leaflet-geotiff.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/leaflet-geotiff.js b/src/leaflet-geotiff.js index 1ca8060..b3e6ab0 100644 --- a/src/leaflet-geotiff.js +++ b/src/leaflet-geotiff.js @@ -206,10 +206,10 @@ L.LeafletGeotiff = L.ImageOverlay.extend({ this._reset(); this.min = this.raster.data[0] - .filter((val) => val !== this.options.noDataValue) + .filter((val) => !isNaN(val) && val !== this.options.noDataValue) .reduce((a, b) => Math.min(a, b)); this.max = this.raster.data[0] - .filter((val) => val !== this.options.noDataValue) + .filter((val) => !isNaN(val) && val !== this.options.noDataValue) .reduce((a, b) => Math.max(a, b)); } }, From e77dc1d3fee5ec0537d835ebca864e0eb5cb6781 Mon Sep 17 00:00:00 2001 From: Siamak Date: Sun, 10 Jan 2021 15:18:30 +0330 Subject: [PATCH 2/6] fix: add built files --- dist/leaflet-geotiff.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/leaflet-geotiff.js b/dist/leaflet-geotiff.js index 7ea2899..a179849 100644 --- a/dist/leaflet-geotiff.js +++ b/dist/leaflet-geotiff.js @@ -201,8 +201,8 @@ this._reset(); - this.min = this.raster.data[0].filter(val => val !== this.options.noDataValue).reduce((a, b) => Math.min(a, b)); - this.max = this.raster.data[0].filter(val => val !== this.options.noDataValue).reduce((a, b) => Math.max(a, b)); + this.min = this.raster.data[0].filter(val => !isNaN(val) && val !== this.options.noDataValue).reduce((a, b) => Math.min(a, b)); + this.max = this.raster.data[0].filter(val => !isNaN(val) && val !== this.options.noDataValue).reduce((a, b) => Math.max(a, b)); } }, From 162072010ddd7dd68b2771dc0fe4899a92975c95 Mon Sep 17 00:00:00 2001 From: Siamak Date: Sun, 24 Jan 2021 12:44:10 +0330 Subject: [PATCH 3/6] feat: exposing plotty.addColorScale --- dist/leaflet-geotiff-plotty.js | 3 +++ src/leaflet-geotiff-plotty.js | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/dist/leaflet-geotiff-plotty.js b/dist/leaflet-geotiff-plotty.js index 88ed689..1231dab 100644 --- a/dist/leaflet-geotiff-plotty.js +++ b/dist/leaflet-geotiff-plotty.js @@ -46,6 +46,9 @@ getColorbarOptions: function getColorbarOptions() { return Object.keys(plotty.colorscales); }, + addColorScale: function addColorScale(name, colorsList, rangeMap) { + plotty.addColorScale(name, colorsList, rangeMap); + }, getColourbarDataUrl: function getColourbarDataUrl(paletteName) { var canvas = document.createElement("canvas"); var plot = new plotty.plot({ diff --git a/src/leaflet-geotiff-plotty.js b/src/leaflet-geotiff-plotty.js index 1c1379e..712eff2 100644 --- a/src/leaflet-geotiff-plotty.js +++ b/src/leaflet-geotiff-plotty.js @@ -44,6 +44,10 @@ L.LeafletGeotiff.Plotty = L.LeafletGeotiffRenderer.extend({ return Object.keys(plotty.colorscales); }, + addColorScale(name, colorsList,rangeMap) { + plotty.addColorScale(name, colorsList,rangeMap); + }, + getColourbarDataUrl(paletteName) { const canvas = document.createElement("canvas"); const plot = new plotty.plot({ From ce30e095b0a1ea986c41028026604f886493d111 Mon Sep 17 00:00:00 2001 From: Siamak Date: Sun, 24 Jan 2021 12:47:16 +0330 Subject: [PATCH 4/6] fix: getColorbarDataUrl naming + dataUrl variable --- dist/leaflet-geotiff-plotty.js | 4 ++-- src/leaflet-geotiff-plotty.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dist/leaflet-geotiff-plotty.js b/dist/leaflet-geotiff-plotty.js index 1231dab..07549da 100644 --- a/dist/leaflet-geotiff-plotty.js +++ b/dist/leaflet-geotiff-plotty.js @@ -49,7 +49,7 @@ addColorScale: function addColorScale(name, colorsList, rangeMap) { plotty.addColorScale(name, colorsList, rangeMap); }, - getColourbarDataUrl: function getColourbarDataUrl(paletteName) { + getColorbarDataUrl: function getColorbarDataUrl(paletteName) { var canvas = document.createElement("canvas"); var plot = new plotty.plot({ canvas: canvas, @@ -61,7 +61,7 @@ clampLow: true, clampHigh: true }); - dataUrl = plot.colorScaleCanvas.toDataURL(); + var dataUrl = plot.colorScaleCanvas.toDataURL(); canvas.remove(); return dataUrl; }, diff --git a/src/leaflet-geotiff-plotty.js b/src/leaflet-geotiff-plotty.js index 712eff2..5e0f4ad 100644 --- a/src/leaflet-geotiff-plotty.js +++ b/src/leaflet-geotiff-plotty.js @@ -48,7 +48,7 @@ L.LeafletGeotiff.Plotty = L.LeafletGeotiffRenderer.extend({ plotty.addColorScale(name, colorsList,rangeMap); }, - getColourbarDataUrl(paletteName) { + getColorbarDataUrl(paletteName) { const canvas = document.createElement("canvas"); const plot = new plotty.plot({ canvas, @@ -60,7 +60,7 @@ L.LeafletGeotiff.Plotty = L.LeafletGeotiffRenderer.extend({ clampLow: true, clampHigh: true }); - dataUrl = plot.colorScaleCanvas.toDataURL(); + var dataUrl = plot.colorScaleCanvas.toDataURL(); canvas.remove(); return dataUrl; }, From 276a7cebce889efb3b4c25d07615936dd92c3921 Mon Sep 17 00:00:00 2001 From: Siamak Date: Sun, 24 Jan 2021 12:47:40 +0330 Subject: [PATCH 5/6] fix: version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f604db9..ebd6a50 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "leaflet-geotiff-2", "description": "A LeafletJS plugin for displaying geoTIFF raster data.", - "version": "0.5.0", + "version": "0.5.1", "license": "MIT", "author": "mail@danwild.io", "contributors": [ From e3b3a134b757956f47e0347d2fa144f728d3df2f Mon Sep 17 00:00:00 2001 From: Siamak Date: Sun, 24 Jan 2021 13:16:03 +0330 Subject: [PATCH 6/6] fix: namings --- dist/leaflet-geotiff-plotty.js | 4 ++-- src/leaflet-geotiff-plotty.js | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/dist/leaflet-geotiff-plotty.js b/dist/leaflet-geotiff-plotty.js index 07549da..98b8939 100644 --- a/dist/leaflet-geotiff-plotty.js +++ b/dist/leaflet-geotiff-plotty.js @@ -46,8 +46,8 @@ getColorbarOptions: function getColorbarOptions() { return Object.keys(plotty.colorscales); }, - addColorScale: function addColorScale(name, colorsList, rangeMap) { - plotty.addColorScale(name, colorsList, rangeMap); + addColorScale: function addColorScale(name, colors, positions) { + plotty.addColorScale(name, colors, positions); }, getColorbarDataUrl: function getColorbarDataUrl(paletteName) { var canvas = document.createElement("canvas"); diff --git a/src/leaflet-geotiff-plotty.js b/src/leaflet-geotiff-plotty.js index 5e0f4ad..2e93b1c 100644 --- a/src/leaflet-geotiff-plotty.js +++ b/src/leaflet-geotiff-plotty.js @@ -13,7 +13,7 @@ L.LeafletGeotiff.Plotty = L.LeafletGeotiffRenderer.extend({ noDataValue: -9999, }, - initialize: function(options) { + initialize: function (options) { if (typeof plotty === "undefined") { throw new Error("plotty not defined"); } @@ -23,18 +23,18 @@ L.LeafletGeotiff.Plotty = L.LeafletGeotiffRenderer.extend({ this._preLoadColorScale(); }, - setColorScale: function(colorScale) { + setColorScale: function (colorScale) { this.options.colorScale = colorScale; this.parent._reset(); }, - setDisplayRange: function(min, max) { + setDisplayRange: function (min, max) { this.options.displayMin = min; this.options.displayMax = max; this.parent._reset(); }, - setClamps: function(clampLow, clampHigh) { + setClamps: function (clampLow, clampHigh) { this.options.clampLow = clampLow; this.options.clampHigh = clampHigh; this.parent._reset(); @@ -44,8 +44,8 @@ L.LeafletGeotiff.Plotty = L.LeafletGeotiffRenderer.extend({ return Object.keys(plotty.colorscales); }, - addColorScale(name, colorsList,rangeMap) { - plotty.addColorScale(name, colorsList,rangeMap); + addColorScale(name, colors, positions) { + plotty.addColorScale(name, colors, positions); }, getColorbarDataUrl(paletteName) { @@ -65,7 +65,7 @@ L.LeafletGeotiff.Plotty = L.LeafletGeotiffRenderer.extend({ return dataUrl; }, - _preLoadColorScale: function() { + _preLoadColorScale: function () { var canvas = document.createElement("canvas"); var plot = new plotty.plot({ canvas: canvas, @@ -80,7 +80,7 @@ L.LeafletGeotiff.Plotty = L.LeafletGeotiffRenderer.extend({ this.colorScaleData = plot.colorScaleCanvas.toDataURL(); }, - render: function(raster, canvas, ctx, args) { + render: function (raster, canvas, ctx, args) { var plottyCanvas = document.createElement("canvas"); var plot = new plotty.plot({ data: raster.data[0], // fix for use with rgb conversion (appending alpha channel) @@ -106,6 +106,6 @@ L.LeafletGeotiff.Plotty = L.LeafletGeotiffRenderer.extend({ } }); -L.LeafletGeotiff.plotty = function(options) { +L.LeafletGeotiff.plotty = function (options) { return new L.LeafletGeotiff.Plotty(options); };