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}}
|
||||||
{{#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 = {
|
var style = {
|
||||||
version: 8,
|
version: 8,
|
||||||
sources: {
|
sources: {
|
||||||
|
@ -83,6 +87,10 @@
|
||||||
"type": "raster-dem",
|
"type": "raster-dem",
|
||||||
"url": "{{public_url}}data/{{id}}.json",
|
"url": "{{public_url}}data/{{id}}.json",
|
||||||
"encoding": "{{terrain_encoding}}"
|
"encoding": "{{terrain_encoding}}"
|
||||||
|
},
|
||||||
|
"contour": {
|
||||||
|
"type": "vector",
|
||||||
|
"tiles": [ baseUrl ],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"terrain": {
|
"terrain": {
|
||||||
|
@ -92,11 +100,7 @@
|
||||||
{
|
{
|
||||||
"id": "background",
|
"id": "background",
|
||||||
"paint": {
|
"paint": {
|
||||||
{{#if is_terrainrgb}}
|
|
||||||
"background-color": "hsl(190, 99%, 63%)"
|
"background-color": "hsl(190, 99%, 63%)"
|
||||||
{{else}}
|
|
||||||
"background-color": "hsl(0, 100%, 25%)"
|
|
||||||
{{/if}}
|
|
||||||
},
|
},
|
||||||
"type": "background"
|
"type": "background"
|
||||||
},
|
},
|
||||||
|
@ -109,6 +113,16 @@
|
||||||
"hillshade-illumination-direction": 315,
|
"hillshade-illumination-direction": 315,
|
||||||
"hillshade-exaggeration": 0.8
|
"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);
|
console.log(url);
|
||||||
const $zxy = this.extractZXYFromUrlTrim(url);
|
const $zxy = this.extractZXYFromUrlTrim(url);
|
||||||
if (!$zxy) {
|
if (!$zxy) {
|
||||||
throw new Error(`Could not extract zxy from $`);
|
throw new Error(`Could not extract zxy from $url`);
|
||||||
}
|
}
|
||||||
if (abortController.signal.aborted) {
|
if (abortController.signal.aborted) {
|
||||||
return null;
|
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
|
* @returns {{z: number, x: number, y:number} | null} Returns the z,x,y of the url, or null if can't extract
|
||||||
*/
|
*/
|
||||||
_extractZXYFromUrlTrimFunction(url) {
|
_extractZXYFromUrlTrimFunction(url) {
|
||||||
const lastSlashIndex = url.lastIndexOf('/');
|
const segments = url.split('/').filter(Boolean); // Split and remove empty segments
|
||||||
if (lastSlashIndex === -1) {
|
if (segments.length < 3) {
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const segments = url.split('/');
|
|
||||||
if (segments.length <= 3) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -116,6 +116,8 @@ export const serve_data = {
|
||||||
z,
|
z,
|
||||||
x,
|
x,
|
||||||
y,
|
y,
|
||||||
|
{ levels: [1000] },
|
||||||
|
new AbortController(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue