Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#10758: Support for Cesium Ion Terrain Provider #10763

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 (mandatory)
"accessToken": "", // cesium access token to be used (mandatory)
"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
Loading