major performance improvements map

This commit is contained in:
Christian Beutel
2025-04-14 20:22:39 +02:00
parent a1296ebacd
commit 5390b9cf72
9 changed files with 165 additions and 17 deletions

View File

@@ -12,6 +12,7 @@
createPopupFromTrail,
FontawesomeMarker,
} from "$lib/util/maplibre_util";
import { polylineToGeoJSON } from "$lib/util/polyline_util";
import type { ElevationProfileControl } from "$lib/vendor/maplibre-elevation-profile/elevationprofile-control";
import { FullscreenControl } from "$lib/vendor/maplibre-fullscreen/fullscreen-control";
import MaplibreGraticule from "$lib/vendor/maplibre-graticule/maplibre-graticule";
@@ -182,8 +183,11 @@
}
const r: GeoJSON[] = [];
console.time("start decode")
trails.forEach((t) => {
if (t.expand?.gpx_data) {
if (t.polyline) {
r.push(polylineToGeoJSON(t.polyline, 5));
} else if (t.expand?.gpx_data) {
r.push(toGeoJson(t.expand.gpx_data) as GeoJSON);
} else if (t.lat !== null && t.lon !== null) {
r.push({
@@ -197,6 +201,8 @@
} as GeoJSON);
}
});
console.timeEnd("start decode")
return r;
}