From b4275f887eaf59e9266404e0b83ff76b369397d9 Mon Sep 17 00:00:00 2001 From: mike-000 <49240900+mike-000@users.noreply.github.com> Date: Mon, 20 Sep 2021 11:17:59 +0100 Subject: [PATCH 1/5] Polyfill for Promise.allSettled --- examples/resources/Promise.allSettled.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 examples/resources/Promise.allSettled.js diff --git a/examples/resources/Promise.allSettled.js b/examples/resources/Promise.allSettled.js new file mode 100644 index 0000000000..e8822b2db4 --- /dev/null +++ b/examples/resources/Promise.allSettled.js @@ -0,0 +1,21 @@ +if (typeof Promise !== 'undefined' && !Promise.allSettled && Array.from) { + Promise.allSettled = + function (promises) { + return Promise.all( + Array.from( + promises, + function (p) { + return p.then ( + function (value) { + return {status: 'fulfilled', value: value}; + } + ).catch( + function (reason) { + return {status: 'rejected', reason: reason}; + } + ); + } + ) + ) + }; +} From 208e2cb022e71f454564f2d189617cac79858fc6 Mon Sep 17 00:00:00 2001 From: mike-000 <49240900+mike-000@users.noreply.github.com> Date: Mon, 20 Sep 2021 11:21:21 +0100 Subject: [PATCH 2/5] Polyfill for Promise.allSettled --- examples/templates/example.html | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/templates/example.html b/examples/templates/example.html index b6f7598625..e60def9d5e 100644 --- a/examples/templates/example.html +++ b/examples/templates/example.html @@ -69,6 +69,7 @@ + {{{ extraHead.local }}} {{{ css.tag }}} {{ title }} From 3b108ef0589ecbc56eeb2db11965c73799b312b3 Mon Sep 17 00:00:00 2001 From: mike-000 <49240900+mike-000@users.noreply.github.com> Date: Mon, 20 Sep 2021 11:25:21 +0100 Subject: [PATCH 3/5] add NumpyLoader --- examples/.eslintrc | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/.eslintrc b/examples/.eslintrc index b00313d641..96581d11d6 100644 --- a/examples/.eslintrc +++ b/examples/.eslintrc @@ -13,6 +13,7 @@ "jsts": false, "JSZip": false, "mapboxgl": false, + "NumpyLoader": false, "saveAs": false, "toastr": false, "topojson": false, From 8be8660b911f8633227b9ba17d5bbf20ff78d4e8 Mon Sep 17 00:00:00 2001 From: mike-000 <49240900+mike-000@users.noreply.github.com> Date: Mon, 20 Sep 2021 11:39:21 +0100 Subject: [PATCH 4/5] Fix range slider for better browser support --- examples/numpytile.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/examples/numpytile.js b/examples/numpytile.js index 78df71634d..bd540b5497 100644 --- a/examples/numpytile.js +++ b/examples/numpytile.js @@ -1,8 +1,7 @@ +import DataTileSource from '../src/ol/source/DataTile.js'; import Map from '../src/ol/Map.js'; import TileLayer from '../src/ol/layer/WebGLTile.js'; import View from '../src/ol/View.js'; - -import DataTileSource from '../src/ol/source/DataTile.js'; import {fromLonLat} from '../src/ol/proj.js'; // 16-bit COG @@ -17,7 +16,7 @@ function numpyTileLoader(z, x, y) { return fetch(url) .then((r) => r.arrayBuffer()) - .then((buffer) => NumpyLoader.fromArrayBuffer(buffer)) // eslint-disable-line no-undef + .then((buffer) => NumpyLoader.fromArrayBuffer(buffer)) .then((numpyData) => { // flatten the numpy data const dataTile = new Float32Array(256 * 256 * 5); @@ -84,21 +83,25 @@ const inputMax = document.getElementById('input-max'); const outputMin = document.getElementById('output-min'); const outputMax = document.getElementById('output-max'); -inputMin.addEventListener('input', (evt) => { +const handleMin = (evt) => { numpyLayer.updateStyleVariables({ 'bMin': parseFloat(evt.target.value), 'bMax': parseFloat(inputMax.value), }); outputMin.innerText = evt.target.value; -}); +}; +inputMin.addEventListener('input', handleMin); +inputMin.addEventListener('change', handleMin); -inputMax.addEventListener('input', (evt) => { +const handleMax = (evt) => { numpyLayer.updateStyleVariables({ 'bMin': parseFloat(inputMin.value), 'bMax': parseFloat(evt.target.value), }); outputMax.innerText = evt.target.value; -}); +}; +inputMax.addEventListener('input', handleMax); +inputMax.addEventListener('change', handleMax); inputMin.value = initialMin; inputMax.value = initialMax; From ff6aee0d45c021aa7d7e5bc5b283c5495254f3e3 Mon Sep 17 00:00:00 2001 From: mike-000 <49240900+mike-000@users.noreply.github.com> Date: Mon, 20 Sep 2021 12:25:18 +0100 Subject: [PATCH 5/5] Additional requirements for ol/source/GeoTIFF --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 15c10c0417..98f4da52d5 100644 --- a/README.md +++ b/README.md @@ -102,6 +102,8 @@ For older browsers and platforms (Internet Explorer, Android 4.x, iOS v12 and ol * [`Number.isInteger`](https://caniuse.com/isInteger): Available from [polyfill.io](https://polyfill.io/). * [Pointer events](https://caniuse.com/pointer): Use [elm-pep](https://npmjs.com/package/elm-pep) (lightweight) or [pepjs](https://npmjs.com/package/pepjs) (for really, really old browsers). +[`ol/source/GeoTIFF`](https://openlayers.org/en/latest/apidoc/module-ol_source_GeoTIFF-GeoTIFFSource.html) requires a browser that supports [ECMAScript 6](https://262.ecma-international.org/6.0/). Additionally a polyfill for [`Promise.allSettled`](https://caniuse.com/mdn-javascript_builtins_promise_allsettled) may be needed. + ## Documentation Check out the [hosted examples](https://openlayers.org/en/latest/examples/), the [workshop](https://openlayers.org/workshop/) or the [API documentation](https://openlayers.org/en/latest/apidoc/).