From daed8edf01d03feb75981bb55e4b405b404a8449 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Wed, 24 Apr 2024 10:43:32 +0200 Subject: [PATCH] Document all olcs_xx properties --- CHANGES.md | 7 ++++++- PROPERTIES.md | 22 +++++++++++++++++++++- examples/customProj.js | 2 +- examples/vectors.js | 4 ++-- src/olcs/FeatureConverter.ts | 4 ++-- src/olcs/core.ts | 8 ++++---- src/olcs/core/OLImageryProvider.ts | 2 +- src/olcs/util.ts | 2 +- 8 files changed, 38 insertions(+), 13 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index c57bc4cd2..b4f75cb9e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,9 +1,14 @@ # Changelog -## v 2.19.4 + +## v 2.20.0 * Changes * Convert all image WMS sources regardless of their load functions + * Allow to force a specific tileLoadFunction using the olcs\_tileLoadFunction property + +* Breaking changes + * Rename all 'olcs.xx' properties to 'olcs\_xx' and document them in PROPERTIES.md ## v 2.19.3 diff --git a/PROPERTIES.md b/PROPERTIES.md index 41301da3e..5d5eeab22 100644 --- a/PROPERTIES.md +++ b/PROPERTIES.md @@ -33,6 +33,26 @@ 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 +## olcs_tileLoadFunction (ImageWMS sources) 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. + +## olcs_projection +Value: https://openlayers.org/en/latest/apidoc/module-ol_proj_Projection-Projection.html +Allows to use an alternative projection in CesiumJS. See the customProj example. + +## olcs_polygon_kind +Value: "rectangle" +Allows to use the Cesium Rectangle geometry instead of a polygon geometry. See the vector example. + +## olcs_3d_geometry (OL vector source) +Value: https://openlayers.org/en/latest/apidoc/module-ol_geom_Geometry-Geometry.html +Allows to use an alternative geometry in CesiumJS. + +## olcs_proxy +Value: https://cesium.com/learn/cesiumjs/ref-doc/Proxy.html +Allows to add authentication information to requests sent by CesiumJS or manipulate request. + +## olcs_extent +Value: An array of numbers representing an extent: [minx, miny, maxx, maxy] +Allows to restrict a tiled imagery layer to a rectangle. This avoid sending useless requests. diff --git a/examples/customProj.js b/examples/customProj.js index a4f08df29..623be1042 100644 --- a/examples/customProj.js +++ b/examples/customProj.js @@ -18,7 +18,7 @@ const customProjSource = new olSourceImageWMS({ url: 'https://wms.geo.admin.ch/' }); -customProjSource.set('olcs.projection', getProjection('EPSG:3857')); +customProjSource.set('olcs_projection', getProjection('EPSG:3857')); Cesium.Ion.defaultAccessToken = OLCS_ION_TOKEN; const ol2d = new olMap({ diff --git a/examples/vectors.js b/examples/vectors.js index 879f72139..a8bd8165a 100644 --- a/examples/vectors.js +++ b/examples/vectors.js @@ -246,7 +246,7 @@ const cartographicRectangleStyle = new olStyleStyle({ }); const cartographicRectangleGeometry = new olGeomPolygon([[[-5e6, 11e6], [4e6, 11e6], [4e6, 10.5e6], [-5e6, 10.5e6], [-5e6, 11e6]]]); -cartographicRectangleGeometry.set('olcs.polygon_kind', 'rectangle'); +cartographicRectangleGeometry.set('olcs_polygon_kind', 'rectangle'); const cartographicRectangle = new olFeature({ geometry: cartographicRectangleGeometry }); @@ -263,7 +263,7 @@ const cartographicRectangleGeometry2 = new olGeomMultiPolygon([ [-5e6, 11e6, 1e6], [-5e6, 11.5e6, 1e6] ]] ]); -cartographicRectangleGeometry2.set('olcs.polygon_kind', 'rectangle'); +cartographicRectangleGeometry2.set('olcs_polygon_kind', 'rectangle'); const cartographicRectangle2 = new olFeature({ geometry: cartographicRectangleGeometry2 }); diff --git a/src/olcs/FeatureConverter.ts b/src/olcs/FeatureConverter.ts index 4635703d5..16dbca25c 100644 --- a/src/olcs/FeatureConverter.ts +++ b/src/olcs/FeatureConverter.ts @@ -472,7 +472,7 @@ export default class FeatureConverter { let fillGeometry, outlineGeometry; let outlinePrimitive: GroundPolylinePrimitive; if ((olGeometry.getCoordinates()[0].length == 5) && - (feature.get('olcs.polygon_kind') === 'rectangle')) { + (feature.get('olcs_polygon_kind') === 'rectangle')) { // Create a rectangle according to the longitude and latitude curves const coordinates = olGeometry.getCoordinates()[0]; // Extract the West, South, East, North coordinates @@ -1033,7 +1033,7 @@ export default class FeatureConverter { return opt_geom; } - const geom3d: OLGeometry = feature.get('olcs.3d_geometry'); + const geom3d: OLGeometry = feature.get('olcs_3d_geometry'); if (geom3d && geom3d instanceof OLGeometry) { return geom3d; } diff --git a/src/olcs/core.ts b/src/olcs/core.ts index 9638ce2ec..bdf904699 100644 --- a/src/olcs/core.ts +++ b/src/olcs/core.ts @@ -359,9 +359,9 @@ export function sourceToImageryProvider( // Convert ImageWMS to TileWMS if (source instanceof olSourceImageWMS && source.getUrl()) { const sourceProps = { - 'olcs.proxy': source.get('olcs.proxy'), - 'olcs.extent': source.get('olcs.extent'), - 'olcs.projection': source.get('olcs.projection'), + 'olcs_proxy': source.get('olcs_proxy'), + 'olcs_extent': source.get('olcs_extent'), + 'olcs_projection': source.get('olcs_projection'), 'olcs.imagesource': source }; const imageLoadFunction = source.getImageLoadFunction(); @@ -482,7 +482,7 @@ export function tileLayerToImageryLayer(olMap: Map, olLayer: BaseLayer, viewProj const layerOptions: {rectangle?: Rectangle} = {}; - const forcedExtent = (olLayer.get('olcs.extent')); + const forcedExtent = (olLayer.get('olcs_extent')); const ext = forcedExtent || olLayer.getExtent(); if (ext) { layerOptions.rectangle = extentToRectangle(ext, viewProj); diff --git a/src/olcs/core/OLImageryProvider.ts b/src/olcs/core/OLImageryProvider.ts index 8e95630cc..34e7f51df 100644 --- a/src/olcs/core/OLImageryProvider.ts +++ b/src/olcs/core/OLImageryProvider.ts @@ -196,7 +196,7 @@ export default class OLImageryProvider implements ImageryProvider /* should not this.shouldRequestNextLevel = false; - const proxy = this.source_.get('olcs.proxy'); + const proxy = this.source_.get('olcs_proxy'); if (proxy) { if (typeof proxy === 'function') { // Duck typing a proxy diff --git a/src/olcs/util.ts b/src/olcs/util.ts index 69e3fc01b..ad39772be 100644 --- a/src/olcs/util.ts +++ b/src/olcs/util.ts @@ -41,7 +41,7 @@ export function imageRenderingValue() { * @return The projection of the source. */ export function getSourceProjection(source: Source): Projection { - return source.get('olcs.projection') as Projection || source.getProjection(); + return source.get('olcs_projection') as Projection || source.getProjection(); }