Skip to content

Commit

Permalink
Document all olcs_xx properties
Browse files Browse the repository at this point in the history
  • Loading branch information
gberaudo committed Apr 24, 2024
1 parent b5db06d commit daed8ed
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 13 deletions.
7 changes: 6 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
22 changes: 21 additions & 1 deletion PROPERTIES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 1 addition & 1 deletion examples/customProj.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
4 changes: 2 additions & 2 deletions examples/vectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
Expand All @@ -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
});
Expand Down
4 changes: 2 additions & 2 deletions src/olcs/FeatureConverter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down
8 changes: 4 additions & 4 deletions src/olcs/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/olcs/core/OLImageryProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/olcs/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}


Expand Down

0 comments on commit daed8ed

Please sign in to comment.