Skip to content

Commit

Permalink
feat(landing): Add LINZ-Terrain-Prod for debug 3d map with production…
Browse files Browse the repository at this point in the history
… elevation data. BM-1058 (#3323)

### Motivation

We want debug page to view terrain for individual config files that
doesn't have elevation tileset inside. Using the same logic of
linz-aerial slider and get the elevation data from the production or dev
config based on the host.

### Modifications

Add a new LINZ-Terrain-Prod source layer in the terrain and hillshade
dropdown that points to the basemaps production data for debugging.

### Verification

![image](https://github.com/user-attachments/assets/a8888c20-8e52-4c00-b5c2-f938b3c7a3d3)
  • Loading branch information
Wentao-Kuang authored Aug 11, 2024
1 parent 5206338 commit 6ff7d14
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
29 changes: 27 additions & 2 deletions packages/landing/src/components/debug.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export interface DebugState {
const HillShadeLayerId = 'debug-hillshade';
/** dynamic hillshade sources are prefixed with this key */
const HillShadePrefix = '__hillshade-';
/** dynamic linz-elevation source key */
const elevationProdId = 'LINZ-Terrain-Prod';

interface DropDownContext {
/** Label for the drop down */
Expand Down Expand Up @@ -350,12 +352,35 @@ export class Debug extends Component<{ map: maplibregl.Map }, DebugState> {
});
}

/**
* Add a terrain source that points to production elevation data for debug
*/
ensureElevationProd(): void {
const map = this.props.map;
// Enable default linz-elevation terrain
if (map.getSource(elevationProdId) == null) {
const url = WindowUrl.toTileUrl({
urlType: MapOptionType.TileRaster,
tileMatrix: Config.map.tileMatrix,
layerId: 'elevation',
pipeline: 'terrain-rgb',
imageFormat: 'png',
});
map.addSource(elevationProdId, {
type: 'raster-dem',
tiles: [url],
tileSize: 256,
});
}
}

setTerrainShown(sourceId: string | null): void {
this.ensureElevationProd();
// Avoid to set debug.terrain for dynamic source, this will return null from the getStyle API with random terrain parameter
Config.map.setDebug('debug.terrain', sourceId);

const map = this.props.map;
const isTurnOff = sourceId === 'off' || sourceId == null;

const isTurnOff = sourceId === 'off' || sourceId == null;
const currentTerrain = map.getTerrain();
if (isTurnOff) {
map.setTerrain(null);
Expand Down
3 changes: 2 additions & 1 deletion packages/landing/src/config.map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ export class MapConfig extends Emitter<MapConfigEvents> {
if (opts.tileMatrix.identifier !== GoogleTms.identifier) urlParams.append('tileMatrix', opts.tileMatrix.identifier);
// Config by far the longest so make it the last parameter
if (opts.config) urlParams.append('config', ensureBase58(opts.config));
if (opts.terrain) urlParams.append('terrain', opts.terrain);
// We don't need to set terrain parameter for debug, as we got debug.terrain parameter to replace
if (opts.terrain && !opts.isDebug) urlParams.append('terrain', opts.terrain);

ConfigDebug.toUrl(opts.debug, urlParams);
return urlParams.toString();
Expand Down

0 comments on commit 6ff7d14

Please sign in to comment.