From b5db06d2596af90244e19cf825250c2942025e0b Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Wed, 24 Apr 2024 09:47:18 +0200 Subject: [PATCH] Add olcs_tileLoadFunction customization --- PROPERTIES.md | 11 ++++++----- src/olcs/core.ts | 13 +++++++------ 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/PROPERTIES.md b/PROPERTIES.md index 3c05e3baf..41301da3e 100644 --- a/PROPERTIES.md +++ b/PROPERTIES.md @@ -1,13 +1,13 @@ -# OLCEsium Properties +# OLCEsium Properties -## olcs_extruded_height +## olcs_extruded_height Value: number The distance in meters between the polygon's extruded face and the ellipsoid surface. Check buildings example for usage in context. ## olcs_shadows Value: boolean -Enables shadow casting in 3D. Can be either applied to the entire feature set or by feature individually. +Enables shadow casting in 3D. Can be either applied to the entire feature set or by feature individually. In order for it to work, [shadowMap](https://cesium.com/learn/cesiumjs/ref-doc/Scene.html?classFilter=scene#shadowMap) needs to be enabled in the Cesium scene. To use the sun as light source, enable [enableLighting](https://cesium.com/learn/cesiumjs/ref-doc/Globe.html#enableLighting) on the Globe. Check buildings example for usage in context. @@ -33,5 +33,6 @@ Value: number Allows you to set a minimum zoom level for rendering 3D tiles in the Cesium view. This property helps to control the level of detail displayed in the 3D view based on the current zoom level. Check mvt example for usage in context. - - +## olcs_tileLoadFunction +Value: https://openlayers.org/en/latest/apidoc/module-ol_Tile.html#~LoadFunction +Allows to use a custom function, for example when converting a WMS image source to a tiled one. diff --git a/src/olcs/core.ts b/src/olcs/core.ts index 54ab07391..9638ce2ec 100644 --- a/src/olcs/core.ts +++ b/src/olcs/core.ts @@ -365,16 +365,17 @@ export function sourceToImageryProvider( 'olcs.imagesource': source }; const imageLoadFunction = source.getImageLoadFunction(); + const tileLoadFunction = source.get('olcs_tileLoadFunction') || function tileLoadFunction(tile: ImageTile, src: string) { + // An imageLoadFunction takes an ImageWrapperm which has a getImage method. + // A tile also has a getImage method. + // We incorrectly passe a tile as an ImageWrapper and hopes for the best. + imageLoadFunction(tile as any, src); + }; source = new olSourceTileWMS({ url: source.getUrl(), attributions: source.getAttributions(), projection: source.getProjection(), - tileLoadFunction(tile: ImageTile, src: string) { - // An imageLoadFunction takes an ImageWrapperm which has a getImage method. - // A tile also has a getImage method. - // We incorrectly passe a tile as an ImageWrapper and hopes for the best. - imageLoadFunction(tile as any, src); - }, + tileLoadFunction, params: source.getParams() }); source.setProperties(sourceProps);