partially working
This commit is contained in:
parent
b65ea0524f
commit
5b753cafd1
3 changed files with 43 additions and 32 deletions
|
@ -71,6 +71,10 @@
|
|||
};
|
||||
{{/is_terrain}}
|
||||
{{#is_terrain}}
|
||||
let baseUrl = window.location.origin;
|
||||
console.log(baseUrl);
|
||||
baseUrl = baseUrl + "/data/{{id}}/contour/{z}/{x}/{y}"
|
||||
console.log(baseUrl);
|
||||
var style = {
|
||||
version: 8,
|
||||
sources: {
|
||||
|
@ -83,6 +87,10 @@
|
|||
"type": "raster-dem",
|
||||
"url": "{{public_url}}data/{{id}}.json",
|
||||
"encoding": "{{terrain_encoding}}"
|
||||
},
|
||||
"contour": {
|
||||
"type": "vector",
|
||||
"tiles": [ baseUrl ],
|
||||
}
|
||||
},
|
||||
"terrain": {
|
||||
|
@ -92,11 +100,7 @@
|
|||
{
|
||||
"id": "background",
|
||||
"paint": {
|
||||
{{#if is_terrainrgb}}
|
||||
"background-color": "hsl(190, 99%, 63%)"
|
||||
{{else}}
|
||||
"background-color": "hsl(0, 100%, 25%)"
|
||||
{{/if}}
|
||||
},
|
||||
"type": "background"
|
||||
},
|
||||
|
@ -109,6 +113,16 @@
|
|||
"hillshade-illumination-direction": 315,
|
||||
"hillshade-exaggeration": 0.8
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "contours",
|
||||
"type": "line",
|
||||
"source": "contour",
|
||||
"source-layer": "contours",
|
||||
"paint": {
|
||||
"line-opacity": 0.5,
|
||||
"line-width": ["match", ["get", "level"], 1, 1, 0.5]
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
|
|
@ -99,7 +99,7 @@ export class LocalDemManager {
|
|||
console.log(url);
|
||||
const $zxy = this.extractZXYFromUrlTrim(url);
|
||||
if (!$zxy) {
|
||||
throw new Error(`Could not extract zxy from $`);
|
||||
throw new Error(`Could not extract zxy from $url`);
|
||||
}
|
||||
if (abortController.signal.aborted) {
|
||||
return null;
|
||||
|
@ -173,13 +173,8 @@ export class LocalDemManager {
|
|||
* @returns {{z: number, x: number, y:number} | null} Returns the z,x,y of the url, or null if can't extract
|
||||
*/
|
||||
_extractZXYFromUrlTrimFunction(url) {
|
||||
const lastSlashIndex = url.lastIndexOf('/');
|
||||
if (lastSlashIndex === -1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const segments = url.split('/');
|
||||
if (segments.length <= 3) {
|
||||
const segments = url.split('/').filter(Boolean); // Split and remove empty segments
|
||||
if (segments.length < 3) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -116,6 +116,8 @@ export const serve_data = {
|
|||
z,
|
||||
x,
|
||||
y,
|
||||
{ levels: [1000] },
|
||||
new AbortController(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue