From 977b89c99d60826afc063447261b45ca42986cc8 Mon Sep 17 00:00:00 2001 From: mike-000 <49240900+mike-000@users.noreply.github.com> Date: Wed, 18 Dec 2019 20:40:20 +0000 Subject: [PATCH 1/2] Disable image smoothing for the DEM source --- examples/sea-level.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/examples/sea-level.js b/examples/sea-level.js index bb8fb5b5ab..f52cdb0aad 100644 --- a/examples/sea-level.js +++ b/examples/sea-level.js @@ -22,9 +22,15 @@ function flood(pixels, data) { } const key = 'pk.eyJ1IjoidHNjaGF1YiIsImEiOiJjaW5zYW5lNHkxMTNmdWttM3JyOHZtMmNtIn0.CDIBD8H-G2Gf-cPkIuWtRg'; -const elevation = new XYZ({ - url: 'https://api.mapbox.com/v4/mapbox.terrain-rgb/{z}/{x}/{y}.pngraw?access_token=' + key, - crossOrigin: 'anonymous' +const elevation = new TileLayer({ + source: new XYZ({ + url: 'https://api.mapbox.com/v4/mapbox.terrain-rgb/{z}/{x}/{y}.pngraw?access_token=' + key, + crossOrigin: 'anonymous' + }) +}); +elevation.on('prerender', function(evt) { + evt.context.imageSmoothingEnabled = false; + evt.context.msImageSmoothingEnabled = false; }); const raster = new RasterSource({ From caefe8c85bc551388738275b6b9ec8fcfbb64214 Mon Sep 17 00:00:00 2001 From: mike-000 <49240900+mike-000@users.noreply.github.com> Date: Wed, 18 Dec 2019 20:49:44 +0000 Subject: [PATCH 2/2] Disable image smoothing for the DEM source --- examples/sea-level.html | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/examples/sea-level.html b/examples/sea-level.html index 4fa8001f35..6861d69fec 100644 --- a/examples/sea-level.html +++ b/examples/sea-level.html @@ -8,6 +8,11 @@ docs: > Mapbox Terrain-RGB tiles to "flood" areas below the elevation shown on the sea level slider.

+

+ ol/source/Raster can take either a tile source or layer. + In this case a layer is used to allow disabling at the prerender event + of image smoothing which would change the precise elevation values set in the pixels. +

tags: "raster, pixel operation, flood" cloak: - key: pk.eyJ1IjoidHNjaGF1YiIsImEiOiJjaW5zYW5lNHkxMTNmdWttM3JyOHZtMmNtIn0.CDIBD8H-G2Gf-cPkIuWtRg