From 148d56c2fe981b2fbf43dc317a62f5dad941d767 Mon Sep 17 00:00:00 2001 From: Andreas Hocevar Date: Fri, 29 Mar 2024 10:33:37 +0100 Subject: [PATCH] Use point resolution for hillshade calculation --- src/apply.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/apply.js b/src/apply.js index ca3b3ead..b5cf5313 100644 --- a/src/apply.js +++ b/src/apply.js @@ -45,11 +45,12 @@ import { import { equivalent, fromLonLat, + getPointResolution, get as getProjection, getUserProjection, } from 'ol/proj.js'; +import {getCenter, getTopLeft} from 'ol/extent.js'; import {getFonts} from './text.js'; -import {getTopLeft} from 'ol/extent.js'; import {hillshade} from './shaders.js'; import { normalizeSourceUrl, @@ -907,9 +908,16 @@ export function setupLayer(glStyle, styleUrl, glLayer, options) { } else if (glSource.type == 'raster-dem' && glLayer.type == 'hillshade') { const hillshadeLayer = setupHillshadeLayer(glSource, styleUrl, options); layer = hillshadeLayer; - hillshadeLayer.getSource().on('beforeoperations', function (event) { + const source = hillshadeLayer.getSource(); + source.on('beforeoperations', function (event) { const data = event.data; - data.resolution = event.resolution; + data.resolution = getPointResolution( + options.projection || 'EPSG:3857', + event.resolution, + getCenter(event.extent), + 'm', + ); + console.log(options); const zoom = getZoomForResolution( event.resolution, options.resolutions || defaultResolutions,