Skip to content

Commit

Permalink
geosolutions-it#10758: Support for Cesium Ion Terrain Provider
Browse files Browse the repository at this point in the history
  • Loading branch information
dsuren1 committed Jan 17, 2025
1 parent e4d081e commit 7856cd0
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
18 changes: 18 additions & 0 deletions docs/developer-guide/maps-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -1232,6 +1232,24 @@ The `terrain` layer of `cesium` type allows using Cesium terrain format complian
}
```

##### Cesium Ion terrain provider

The `terrain` layer of the `cesium-ion` type enables the use of Cesium Ion terrain format-compliant services (i.e., Cesium Ion resources). The options attribute allows for the configuration and access of Ion resources and their associated assets.

```json
{
"type": "terrain",
"provider": "cesium-ion",
"visibility": true,
"options": {
"assetId": "", // cesium ion asset id to be requested
"accessToken": "", // cesium access token to be used
"server": undefined, // resource from the Cesium ion API server. Defaults to https://api.cesium.com when unspecified
"credit": "" // optional, additional credit to be displayed along side credit and attribution from ion resource
}
}
```

#### Elevation

This layer provides information related to elevation based on a provided DTM layer. **It does not provide the terrain profile for 3D visualization**, see [terrain](#terrain) layer type for this feature.
Expand Down
21 changes: 20 additions & 1 deletion web/client/components/map/cesium/plugins/TerrainLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@ function cesiumOptionsMapping(config) {
};
}

function cesiumIonOptionsMapping(config) {
const options = config.options ?? {};
return {
...(options.assetId && {
url: Cesium.IonResource.fromAssetId(options.assetId, {
accessToken: options.accessToken,
server: options.server
})
}),
credit: options.credit,
requestMetadata: options.requestMetadata
};
}

const createLayer = (config, map) => {
map.terrainProvider = undefined;
let terrainProvider;
Expand All @@ -42,6 +56,10 @@ const createLayer = (config, map) => {
terrainProvider = new Cesium.EllipsoidTerrainProvider();
break;
}
case 'cesium-ion': {
terrainProvider = new Cesium.CesiumTerrainProvider(cesiumIonOptionsMapping(config));
break;
}
default:
terrainProvider = new Cesium.EllipsoidTerrainProvider();
break;
Expand All @@ -61,7 +79,8 @@ const createLayer = (config, map) => {
const updateLayer = (layer, newOptions, oldOptions, map) => {
if (newOptions.securityToken !== oldOptions.securityToken
|| oldOptions.credits !== newOptions.credits
|| oldOptions.provider !== newOptions.provider || oldOptions.forceProxy !== newOptions.forceProxy) {
|| oldOptions.provider !== newOptions.provider
|| oldOptions.forceProxy !== newOptions.forceProxy) {
return createLayer(newOptions, map);
}
return null;
Expand Down

0 comments on commit 7856cd0

Please sign in to comment.