partially working

This commit is contained in:
acalcutt 2024-12-21 17:07:09 -05:00 committed by Miko
parent b65ea0524f
commit 5b753cafd1
3 changed files with 43 additions and 32 deletions

View file

@ -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,35 +87,45 @@
"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": {
"source": "terrain" "source": "terrain"
}, },
"layers": [ "layers": [
{ {
"id": "background", "id": "background",
"paint": { "paint": {
{{#if is_terrainrgb}} "background-color": "hsl(190, 99%, 63%)"
"background-color": "hsl(190, 99%, 63%)" },
{{else}} "type": "background"
"background-color": "hsl(0, 100%, 25%)" },
{{/if}} {
}, "id": "hillshade",
"type": "background" "source": "hillshade",
}, "type": "hillshade",
{ "paint": {
"id": "hillshade", "hillshade-shadow-color": "hsl(39, 21%, 33%)",
"source": "hillshade", "hillshade-illumination-direction": 315,
"type": "hillshade", "hillshade-exaggeration": 0.8
"paint": { }
"hillshade-shadow-color": "hsl(39, 21%, 33%)", },
"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]
}
}
]
};
{{/is_terrain}} {{/is_terrain}}
var map = new maplibregl.Map({ var map = new maplibregl.Map({

View file

@ -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;
} }

View file

@ -116,6 +116,8 @@ export const serve_data = {
z, z,
x, x,
y, y,
{ levels: [1000] },
new AbortController(),
); );
} }
} }