mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2026-11-30 09:34:29 +00:00
poc
This commit is contained in:
1 parent
1bd8ac46fe
commit
2cf9a9f982
6 files changed
+545
-12
No files matched your search
@@ -10,6 +10,7 @@ import { settings } from '$lib/state/settings';
|
||||
import { tick } from 'svelte';
|
||||
import { ANCHOR_LAYER_KEY, StyleManager } from '$lib/components/map/style';
|
||||
import { MapLayerEventManager } from '$lib/components/map/map-layer-event-manager';
|
||||
import { registerOpenSatelliteProtocol } from '$lib/components/map/open-satellite';
|
||||
|
||||
const { treeFileView, elevationProfile, bottomPanelSize, rightPanelSize, distanceUnits } = settings;
|
||||
|
||||
@@ -41,6 +42,7 @@ export class MapLibreGLMap {
|
||||
geolocate: boolean
|
||||
) {
|
||||
maplibregl.setWorkerUrl(workerUrl);
|
||||
registerOpenSatelliteProtocol(maptilerKey);
|
||||
this._maptilerKey = maptilerKey;
|
||||
this._styleManager = new StyleManager(this._mapStore, this._maptilerKey);
|
||||
// MapLibre gives Safari more workers, but only recognizes it by its user agent: not
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
// Which imagery each tile of the open satellite basemap is made of.
|
||||
import assert from 'node:assert/strict';
|
||||
import { describe, it } from 'node:test';
|
||||
import { planTile } from './open-satellite';
|
||||
|
||||
function tile(lon: number, lat: number, z: number): [number, number, number] {
|
||||
const n = 2 ** z;
|
||||
const sin = Math.sin((lat * Math.PI) / 180);
|
||||
return [
|
||||
z,
|
||||
Math.floor(((lon + 180) / 360) * n),
|
||||
Math.floor((0.5 - Math.log((1 + sin) / (1 - sin)) / (4 * Math.PI)) * n),
|
||||
];
|
||||
}
|
||||
|
||||
async function plan(lon: number, lat: number, z: number) {
|
||||
const { parts, fallback } = await planTile(...tile(lon, lat, z));
|
||||
return { parts: parts.map((p) => `${p.source.id}:${p.relation}`), fallback };
|
||||
}
|
||||
|
||||
describe('planTile', () => {
|
||||
it('takes a tile inside a country from its agency alone', async () => {
|
||||
assert.deepEqual(await plan(2.35, 48.85, 15), { parts: ['fr:full'], fallback: false });
|
||||
assert.deepEqual(await plan(6.63, 46.52, 15), { parts: ['ch:full'], fallback: false });
|
||||
assert.deepEqual(await plan(4.35, 50.85, 16), { parts: ['be:full'], fallback: false });
|
||||
assert.deepEqual(await plan(21.01, 52.23, 16), { parts: ['pl:full'], fallback: false });
|
||||
});
|
||||
|
||||
it('takes a tile outside every country from the fallback', async () => {
|
||||
assert.deepEqual(await plan(-0.12, 51.5, 14), { parts: [], fallback: true });
|
||||
// Germany, which is not in the patchwork
|
||||
assert.deepEqual(await plan(9.73, 52.37, 14), { parts: [], fallback: true });
|
||||
assert.deepEqual(await plan(-30, 40, 10), { parts: [], fallback: true });
|
||||
});
|
||||
|
||||
it('puts the countries of a border tile together, over the fallback where none is', async () => {
|
||||
// Menton: France and Italy, which is not in the patchwork
|
||||
assert.deepEqual(await plan(7.5, 43.8, 12), {
|
||||
parts: ['fr:partial'],
|
||||
fallback: true,
|
||||
});
|
||||
// Basel: Switzerland, France and Germany
|
||||
assert.deepEqual(await plan(7.589, 47.5895, 14), {
|
||||
parts: ['ch:partial', 'fr:partial'],
|
||||
fallback: true,
|
||||
});
|
||||
// Somport: France and Spain, between them the whole tile
|
||||
assert.deepEqual(await plan(-0.52, 42.8, 13), {
|
||||
parts: ['fr:partial', 'es:partial'],
|
||||
fallback: false,
|
||||
});
|
||||
});
|
||||
|
||||
it('does not take a tile covering several countries from their agencies', async () => {
|
||||
assert.deepEqual(await plan(2.35, 48.85, 6), { parts: [], fallback: true });
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,444 @@
|
||||
import * as maplibregl from 'maplibre-gl';
|
||||
|
||||
/**
|
||||
* A satellite basemap made of the open imagery of national mapping agencies, drawn through a
|
||||
* custom protocol: each tile is taken from the agency whose country covers it, the tiles on a
|
||||
* border are put together on a canvas clipped to the border of each country, and only the parts
|
||||
* no open source covers are taken from the commercial fallback.
|
||||
*/
|
||||
|
||||
export const OPEN_SATELLITE_PROTOCOL = 'opensat';
|
||||
|
||||
type TileUrl = (z: number, x: number, y: number) => string;
|
||||
|
||||
type ImagerySource = {
|
||||
/** Key of the coverage in satellite-coverage.json */
|
||||
id: string;
|
||||
url: TileUrl;
|
||||
/** Below it, a tile spans too many sources and the fallback is used. */
|
||||
minzoom: number;
|
||||
/** Above it, the tile of this zoom level is scaled up. */
|
||||
maxzoom: number;
|
||||
};
|
||||
|
||||
const xyz =
|
||||
(template: string): TileUrl =>
|
||||
(z, x, y) =>
|
||||
template.replace('{z}', String(z)).replace('{x}', String(x)).replace('{y}', String(y));
|
||||
|
||||
/** In order of priority, the first one covering a point is used. */
|
||||
const sources: ImagerySource[] = [
|
||||
{
|
||||
id: 'ch',
|
||||
url: xyz(
|
||||
'https://wmts.geo.admin.ch/1.0.0/ch.swisstopo.swissimage/default/current/3857/{z}/{x}/{y}.jpeg'
|
||||
),
|
||||
minzoom: 8,
|
||||
maxzoom: 20,
|
||||
},
|
||||
{
|
||||
id: 'fr',
|
||||
url: xyz(
|
||||
'https://data.geopf.fr/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=ORTHOIMAGERY.ORTHOPHOTOS&STYLE=normal&FORMAT=image/jpeg&TILEMATRIXSET=PM&TILEMATRIX={z}&TILECOL={x}&TILEROW={y}'
|
||||
),
|
||||
minzoom: 8,
|
||||
maxzoom: 19,
|
||||
},
|
||||
{
|
||||
id: 'es',
|
||||
url: xyz(
|
||||
'https://www.ign.es/wmts/pnoa-ma?layer=OI.OrthoimageCoverage&style=default&tilematrixset=GoogleMapsCompatible&Service=WMTS&Request=GetTile&Version=1.0.0&Format=image/jpeg&TileMatrix={z}&TileCol={x}&TileRow={y}'
|
||||
),
|
||||
minzoom: 8,
|
||||
maxzoom: 19,
|
||||
},
|
||||
{
|
||||
id: 'at',
|
||||
url: xyz(
|
||||
'https://mapsneu.wien.gv.at/basemap/bmaporthofoto30cm/normal/google3857/{z}/{y}/{x}.jpeg'
|
||||
),
|
||||
minzoom: 8,
|
||||
maxzoom: 19,
|
||||
},
|
||||
{
|
||||
id: 'nl',
|
||||
url: xyz(
|
||||
'https://service.pdok.nl/hwh/luchtfotorgb/wmts/v1_0/Actueel_orthoHR/EPSG:3857/{z}/{x}/{y}.jpeg'
|
||||
),
|
||||
minzoom: 8,
|
||||
maxzoom: 19,
|
||||
},
|
||||
{
|
||||
id: 'lu',
|
||||
url: xyz(
|
||||
'https://wmts1.geoportail.lu/opendata/wmts/ortho_latest/GLOBAL_WEBMERCATOR_4_V3/{z}/{x}/{y}.jpeg'
|
||||
),
|
||||
minzoom: 8,
|
||||
maxzoom: 19,
|
||||
},
|
||||
{
|
||||
id: 'cz',
|
||||
url: xyz(
|
||||
'https://ags.cuzk.gov.cz/arcgis1/rest/services/ORTOFOTO_WM/MapServer/tile/{z}/{y}/{x}'
|
||||
),
|
||||
minzoom: 8,
|
||||
maxzoom: 19,
|
||||
},
|
||||
{
|
||||
id: 'be',
|
||||
url: xyz(
|
||||
'https://wmts.ngi.be/inspire/ortho/1.0.0/orthoimage_coverage/default/3857/latest/{z}/{y}/{x}.png'
|
||||
),
|
||||
minzoom: 8,
|
||||
maxzoom: 19,
|
||||
},
|
||||
{
|
||||
id: 'pl',
|
||||
url: xyz(
|
||||
'https://mapy.geoportal.gov.pl/wss/service/PZGIK/ORTO/WMTS/StandardResolution?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=ORTOFOTOMAPA&STYLE=default&FORMAT=image/jpeg&TILEMATRIXSET=EPSG:3857&TILEMATRIX=EPSG:3857:{z}&TILEROW={y}&TILECOL={x}'
|
||||
),
|
||||
minzoom: 8,
|
||||
maxzoom: 19,
|
||||
},
|
||||
];
|
||||
|
||||
export const openSatelliteAttribution = [
|
||||
'<a href="https://www.swisstopo.admin.ch/" target="_blank">swisstopo</a>',
|
||||
'<a href="https://geoservices.ign.fr/" target="_blank">IGN-F/Géoplateforme</a>',
|
||||
'PNOA © <a href="https://www.ign.es/" target="_blank">IGN España</a>',
|
||||
'<a href="https://basemap.at/" target="_blank">basemap.at</a>',
|
||||
'<a href="https://www.pdok.nl/" target="_blank">PDOK</a>',
|
||||
'<a href="https://geoportail.lu/" target="_blank">geoportail.lu</a>',
|
||||
'<a href="https://cuzk.gov.cz/" target="_blank">ČÚZK</a>',
|
||||
'<a href="https://www.ngi.be/" target="_blank">NGI/IGN</a>',
|
||||
'<a href="https://www.geoportal.gov.pl/" target="_blank">GUGiK</a>',
|
||||
'<a href="https://www.maptiler.com/copyright/" target="_blank">© MapTiler</a>',
|
||||
].join(', ');
|
||||
|
||||
// Geometry, in Web Mercator coordinates between 0 and 1
|
||||
|
||||
type Ring = Float64Array; // x0, y0, x1, y1, ...
|
||||
type Polygon = { rings: Ring[]; bbox: [number, number, number, number] };
|
||||
type Coverage = { polygons: Polygon[]; bbox: [number, number, number, number] };
|
||||
type Rect = [number, number, number, number]; // minX, minY, maxX, maxY
|
||||
|
||||
function mercatorX(lon: number) {
|
||||
return (lon + 180) / 360;
|
||||
}
|
||||
|
||||
function mercatorY(lat: number) {
|
||||
const sin = Math.sin((Math.max(-85.0511, Math.min(85.0511, lat)) * Math.PI) / 180);
|
||||
return 0.5 - Math.log((1 + sin) / (1 - sin)) / (4 * Math.PI);
|
||||
}
|
||||
|
||||
function emptyBBox(): [number, number, number, number] {
|
||||
return [Infinity, Infinity, -Infinity, -Infinity];
|
||||
}
|
||||
|
||||
function extend(bbox: [number, number, number, number], other: Rect) {
|
||||
bbox[0] = Math.min(bbox[0], other[0]);
|
||||
bbox[1] = Math.min(bbox[1], other[1]);
|
||||
bbox[2] = Math.max(bbox[2], other[2]);
|
||||
bbox[3] = Math.max(bbox[3], other[3]);
|
||||
}
|
||||
|
||||
function intersects(a: Rect, b: Rect) {
|
||||
return a[0] <= b[2] && b[0] <= a[2] && a[1] <= b[3] && b[1] <= a[3];
|
||||
}
|
||||
|
||||
function projectCoverage(polygons: number[][][][]): Coverage {
|
||||
const coverage: Coverage = { polygons: [], bbox: emptyBBox() };
|
||||
for (const polygon of polygons) {
|
||||
const projected: Polygon = { rings: [], bbox: emptyBBox() };
|
||||
for (const ring of polygon) {
|
||||
const array = new Float64Array(ring.length * 2);
|
||||
ring.forEach(([lon, lat], i) => {
|
||||
array[2 * i] = mercatorX(lon);
|
||||
array[2 * i + 1] = mercatorY(lat);
|
||||
extend(projected.bbox, [
|
||||
array[2 * i],
|
||||
array[2 * i + 1],
|
||||
array[2 * i],
|
||||
array[2 * i + 1],
|
||||
]);
|
||||
});
|
||||
projected.rings.push(array);
|
||||
}
|
||||
coverage.polygons.push(projected);
|
||||
extend(coverage.bbox, projected.bbox);
|
||||
}
|
||||
return coverage;
|
||||
}
|
||||
|
||||
function pointInPolygon(x: number, y: number, polygon: Polygon) {
|
||||
let inside = false;
|
||||
for (const ring of polygon.rings) {
|
||||
for (let i = 0, j = ring.length - 2; i < ring.length; j = i, i += 2) {
|
||||
const xi = ring[i],
|
||||
yi = ring[i + 1],
|
||||
xj = ring[j],
|
||||
yj = ring[j + 1];
|
||||
if (yi > y !== yj > y && x < ((xj - xi) * (y - yi)) / (yj - yi) + xi) {
|
||||
inside = !inside;
|
||||
}
|
||||
}
|
||||
}
|
||||
return inside;
|
||||
}
|
||||
|
||||
/** Whether the segment touches the rectangle (Liang–Barsky). */
|
||||
function segmentIntersectsRect(
|
||||
x0: number,
|
||||
y0: number,
|
||||
x1: number,
|
||||
y1: number,
|
||||
[minX, minY, maxX, maxY]: Rect
|
||||
) {
|
||||
let t0 = 0,
|
||||
t1 = 1;
|
||||
const dx = x1 - x0,
|
||||
dy = y1 - y0;
|
||||
const p = [-dx, dx, -dy, dy];
|
||||
const q = [x0 - minX, maxX - x0, y0 - minY, maxY - y0];
|
||||
for (let i = 0; i < 4; i++) {
|
||||
if (p[i] === 0) {
|
||||
if (q[i] < 0) return false;
|
||||
} else {
|
||||
const t = q[i] / p[i];
|
||||
if (p[i] < 0) {
|
||||
if (t > t1) return false;
|
||||
t0 = Math.max(t0, t);
|
||||
} else {
|
||||
if (t < t0) return false;
|
||||
t1 = Math.min(t1, t);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
type CoverageRelation = { relation: 'full' | 'partial' | 'none'; polygons: Polygon[] };
|
||||
|
||||
function relate(coverage: Coverage, rect: Rect): CoverageRelation {
|
||||
if (!intersects(coverage.bbox, rect)) return { relation: 'none', polygons: [] };
|
||||
const touching: Polygon[] = [];
|
||||
let crossed = false;
|
||||
for (const polygon of coverage.polygons) {
|
||||
if (!intersects(polygon.bbox, rect)) continue;
|
||||
let polygonCrossed = false;
|
||||
for (const ring of polygon.rings) {
|
||||
for (let i = 2; i < ring.length && !polygonCrossed; i += 2) {
|
||||
if (segmentIntersectsRect(ring[i - 2], ring[i - 1], ring[i], ring[i + 1], rect)) {
|
||||
polygonCrossed = true;
|
||||
}
|
||||
}
|
||||
if (polygonCrossed) break;
|
||||
}
|
||||
if (polygonCrossed) {
|
||||
crossed = true;
|
||||
touching.push(polygon);
|
||||
} else if (pointInPolygon((rect[0] + rect[2]) / 2, (rect[1] + rect[3]) / 2, polygon)) {
|
||||
// No border inside the tile, and its center is inside: the whole tile is
|
||||
return { relation: 'full', polygons: [polygon] };
|
||||
}
|
||||
}
|
||||
return crossed
|
||||
? { relation: 'partial', polygons: touching }
|
||||
: { relation: 'none', polygons: [] };
|
||||
}
|
||||
|
||||
// Coverage, loaded with the first tile
|
||||
|
||||
let coverages: Promise<Map<string, Coverage>> | null = null;
|
||||
|
||||
function getCoverages() {
|
||||
coverages ??= import('$lib/data/satellite-coverage.json').then((module) => {
|
||||
const data = module.default as unknown as Record<string, number[][][][]>;
|
||||
const result = new Map<string, Coverage>();
|
||||
for (const source of sources) {
|
||||
result.set(source.id, projectCoverage(data[source.id] ?? []));
|
||||
}
|
||||
return result;
|
||||
});
|
||||
return coverages;
|
||||
}
|
||||
|
||||
// Tiles
|
||||
|
||||
const TILE_SIZE = 256;
|
||||
|
||||
async function fetchBytes(url: string, signal: AbortSignal): Promise<ArrayBuffer | null> {
|
||||
try {
|
||||
const response = await fetch(url, { signal });
|
||||
if (!response.ok) return null;
|
||||
const contentType = response.headers.get('content-type') ?? '';
|
||||
if (!contentType.startsWith('image/')) return null;
|
||||
return await response.arrayBuffer();
|
||||
} catch (e) {
|
||||
if (signal.aborted) throw e;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/** The image of the tile, or of the part of its ancestor at the max zoom of the source. */
|
||||
async function fetchImage(
|
||||
url: TileUrl,
|
||||
maxzoom: number,
|
||||
z: number,
|
||||
x: number,
|
||||
y: number,
|
||||
signal: AbortSignal
|
||||
): Promise<{ image: ImageBitmap; sx: number; sy: number; size: number } | null> {
|
||||
const d = Math.max(0, z - maxzoom);
|
||||
const bytes = await fetchBytes(url(z - d, x >> d, y >> d), signal);
|
||||
if (!bytes) return null;
|
||||
try {
|
||||
const image = await createImageBitmap(new Blob([bytes]));
|
||||
const size = image.width / 2 ** d;
|
||||
return {
|
||||
image,
|
||||
sx: (x - ((x >> d) << d)) * size,
|
||||
sy: (y - ((y >> d) << d)) * size,
|
||||
size,
|
||||
};
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function clipTo(
|
||||
context: OffscreenCanvasRenderingContext2D,
|
||||
polygons: Polygon[],
|
||||
z: number,
|
||||
x: number,
|
||||
y: number
|
||||
) {
|
||||
const scale = 2 ** z * TILE_SIZE;
|
||||
context.beginPath();
|
||||
for (const polygon of polygons) {
|
||||
for (const ring of polygon.rings) {
|
||||
for (let i = 0; i < ring.length; i += 2) {
|
||||
const px = ring[i] * scale - x * TILE_SIZE;
|
||||
const py = ring[i + 1] * scale - y * TILE_SIZE;
|
||||
if (i === 0) context.moveTo(px, py);
|
||||
else context.lineTo(px, py);
|
||||
}
|
||||
context.closePath();
|
||||
}
|
||||
}
|
||||
context.clip('evenodd');
|
||||
}
|
||||
|
||||
/** Whether every point of a grid over the tile is in one of the partial coverages. */
|
||||
function coveredBy(partials: CoverageRelation[], rect: Rect) {
|
||||
const steps = 6;
|
||||
for (let i = 0; i < steps; i++) {
|
||||
for (let j = 0; j < steps; j++) {
|
||||
const px = rect[0] + ((i + 0.5) / steps) * (rect[2] - rect[0]);
|
||||
const py = rect[1] + ((j + 0.5) / steps) * (rect[3] - rect[1]);
|
||||
if (
|
||||
!partials.some((p) => p.polygons.some((polygon) => pointInPolygon(px, py, polygon)))
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
type TilePart = CoverageRelation & { source: ImagerySource };
|
||||
|
||||
/**
|
||||
* The sources of the tile, in drawing order: the one covering the whole tile, or those
|
||||
* covering part of it, and whether the fallback is needed below them.
|
||||
*/
|
||||
export async function planTile(
|
||||
z: number,
|
||||
x: number,
|
||||
y: number
|
||||
): Promise<{ parts: TilePart[]; fallback: boolean }> {
|
||||
const n = 2 ** z;
|
||||
const rect: Rect = [x / n, y / n, (x + 1) / n, (y + 1) / n];
|
||||
const coverageBySource = await getCoverages();
|
||||
const parts: TilePart[] = [];
|
||||
for (const source of sources) {
|
||||
if (z < source.minzoom) continue;
|
||||
const relation = relate(coverageBySource.get(source.id)!, rect);
|
||||
if (relation.relation === 'full') {
|
||||
return { parts: [{ ...relation, source }], fallback: false };
|
||||
} else if (relation.relation === 'partial') {
|
||||
parts.push({ ...relation, source });
|
||||
}
|
||||
}
|
||||
return { parts, fallback: parts.length === 0 || !coveredBy(parts, rect) };
|
||||
}
|
||||
|
||||
export function maptilerSource(maptilerKey: string): ImagerySource {
|
||||
return {
|
||||
id: 'fallback',
|
||||
url: xyz(`https://api.maptiler.com/tiles/satellite-v2/{z}/{x}/{y}.jpg?key=${maptilerKey}`),
|
||||
minzoom: 0,
|
||||
maxzoom: 20,
|
||||
};
|
||||
}
|
||||
|
||||
export async function loadTile(
|
||||
z: number,
|
||||
x: number,
|
||||
y: number,
|
||||
fallback: ImagerySource,
|
||||
signal: AbortSignal
|
||||
): Promise<ArrayBuffer | ImageBitmap> {
|
||||
const plan = await planTile(z, x, y);
|
||||
const { parts } = plan;
|
||||
|
||||
// a single tile as it is, without drawing it again
|
||||
const single =
|
||||
parts.length === 0
|
||||
? fallback
|
||||
: parts.length === 1 && !plan.fallback && parts[0].relation === 'full'
|
||||
? parts[0].source
|
||||
: null;
|
||||
if (single && z <= single.maxzoom) {
|
||||
const bytes = await fetchBytes(single.url(z, x, y), signal);
|
||||
if (bytes) return bytes;
|
||||
if (single === fallback) throw new Error(`No imagery for tile ${z}/${x}/${y}`);
|
||||
}
|
||||
|
||||
const images = await Promise.all(
|
||||
parts.map((p) => fetchImage(p.source.url, p.source.maxzoom, z, x, y, signal))
|
||||
);
|
||||
const fallbackImage =
|
||||
plan.fallback || images.some((image) => image === null)
|
||||
? await fetchImage(fallback.url, fallback.maxzoom, z, x, y, signal)
|
||||
: null;
|
||||
|
||||
const canvas = new OffscreenCanvas(TILE_SIZE, TILE_SIZE);
|
||||
const context = canvas.getContext('2d')!;
|
||||
if (fallbackImage) {
|
||||
const { image, sx, sy, size } = fallbackImage;
|
||||
context.drawImage(image, sx, sy, size, size, 0, 0, TILE_SIZE, TILE_SIZE);
|
||||
image.close();
|
||||
}
|
||||
parts.forEach((p, i) => {
|
||||
const result = images[i];
|
||||
if (!result) return;
|
||||
context.save();
|
||||
if (p.relation === 'partial') clipTo(context, p.polygons, z, x, y);
|
||||
const { image, sx, sy, size } = result;
|
||||
context.drawImage(image, sx, sy, size, size, 0, 0, TILE_SIZE, TILE_SIZE);
|
||||
context.restore();
|
||||
image.close();
|
||||
});
|
||||
return canvas.transferToImageBitmap();
|
||||
}
|
||||
|
||||
export function registerOpenSatelliteProtocol(maptilerKey: string) {
|
||||
const fallback = maptilerSource(maptilerKey);
|
||||
maplibregl.addProtocol(OPEN_SATELLITE_PROTOCOL, async (params, abortController) => {
|
||||
const match = params.url.match(/(\d+)\/(\d+)\/(\d+)$/);
|
||||
if (!match) throw new Error(`Invalid tile URL: ${params.url}`);
|
||||
const [z, x, y] = match.slice(1).map(Number);
|
||||
return { data: await loadTile(z, x, y, fallback, abortController.signal) };
|
||||
});
|
||||
}
|
||||
@@ -24,6 +24,10 @@ import {
|
||||
} from 'lucide-static';
|
||||
import { type RasterDEMSourceSpecification, type StyleSpecification } from 'maplibre-gl';
|
||||
import bikerouterGravel from '$lib/data/custom/bikerouter-gravel.json';
|
||||
import {
|
||||
OPEN_SATELLITE_PROTOCOL,
|
||||
openSatelliteAttribution,
|
||||
} from '$lib/components/map/open-satellite';
|
||||
|
||||
export const maptilerKeyPlaceHolder = 'MAPTILER_KEY';
|
||||
|
||||
@@ -32,25 +36,22 @@ export const basemaps: { [key: string]: string | StyleSpecification } = {
|
||||
libertySatellite: 'https://styles.gpx.studio/liberty-satellite.json',
|
||||
osm: 'https://styles.gpx.studio/osm.json',
|
||||
osmTopo: 'https://styles.gpx.studio/osm-topo.json',
|
||||
esriSatellite: {
|
||||
openSatellite: {
|
||||
version: 8,
|
||||
sources: {
|
||||
esriSatellite: {
|
||||
openSatellite: {
|
||||
type: 'raster',
|
||||
tiles: [
|
||||
'https://services.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer/WMTS/tile/1.0.0/World_Imagery/default/default028mm/{z}/{y}/{x}.jpg',
|
||||
],
|
||||
tiles: [`${OPEN_SATELLITE_PROTOCOL}://{z}/{x}/{y}`],
|
||||
tileSize: 256,
|
||||
maxzoom: 19,
|
||||
attribution:
|
||||
'© <a href="https://www.esri.com/" target="_blank">Esri</a>, Vantor, Earthstar Geographics, and the GIS User Community',
|
||||
attribution: openSatelliteAttribution,
|
||||
},
|
||||
},
|
||||
layers: [
|
||||
{
|
||||
id: 'esriSatellite',
|
||||
id: 'openSatellite',
|
||||
type: 'raster',
|
||||
source: 'esriSatellite',
|
||||
source: 'openSatellite',
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -365,6 +366,27 @@ export const basemaps: { [key: string]: string | StyleSpecification } = {
|
||||
},
|
||||
],
|
||||
},
|
||||
luxTopo: {
|
||||
version: 8,
|
||||
sources: {
|
||||
luxTopo: {
|
||||
type: 'raster',
|
||||
tiles: [
|
||||
'https://wmts3.geoportail.lu/mapproxy_4_v3/wmts/topogg/GLOBAL_WEBMERCATOR_4_V3/{z}/{x}/{y}.png',
|
||||
],
|
||||
tileSize: 256,
|
||||
maxzoom: 16,
|
||||
attribution: '<a href="https://geoportail.lu/" target="_blank">geoportail.lu</a>',
|
||||
},
|
||||
},
|
||||
layers: [
|
||||
{
|
||||
id: 'luxTopo',
|
||||
type: 'raster',
|
||||
source: 'luxTopo',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
export const overlays: { [key: string]: string | StyleSpecification } = {
|
||||
@@ -810,7 +832,7 @@ export const basemapTree: LayerTreeType = {
|
||||
libertySatellite: true,
|
||||
osm: true,
|
||||
osmTopo: true,
|
||||
esriSatellite: true,
|
||||
openSatellite: true,
|
||||
openStreetMap: true,
|
||||
openTopoMap: true,
|
||||
openHikingMap: true,
|
||||
@@ -833,6 +855,9 @@ export const basemapTree: LayerTreeType = {
|
||||
ignFrScan25: true,
|
||||
ignFrSatellite: true,
|
||||
},
|
||||
luxembourg: {
|
||||
luxTopo: true,
|
||||
},
|
||||
new_zealand: {
|
||||
linz: true,
|
||||
linzTopo: true,
|
||||
@@ -1036,7 +1061,7 @@ export const defaultBasemapTree: LayerTreeType = {
|
||||
libertySatellite: true,
|
||||
osm: true,
|
||||
osmTopo: true,
|
||||
esriSatellite: false,
|
||||
openSatellite: true,
|
||||
openStreetMap: true,
|
||||
openTopoMap: true,
|
||||
openHikingMap: true,
|
||||
@@ -1059,6 +1084,9 @@ export const defaultBasemapTree: LayerTreeType = {
|
||||
ignFrScan25: false,
|
||||
ignFrSatellite: false,
|
||||
},
|
||||
luxembourg: {
|
||||
luxTopo: false,
|
||||
},
|
||||
new_zealand: {
|
||||
linz: false,
|
||||
linzTopo: false,
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
{"fr":[[[[-54.1115,2.1143],[-54.1349,2.1107],[-54.1481,2.1144],[-54.1574,2.1217],[-54.1885,2.1613],[-54.1945,2.1631],[-54.21,2.1616],[-54.2638,2.1482],[-54.314,2.1549],[-54.3229,2.1573],[-54.3351,2.1639],[-54.3609,2.1882],[-54.3739,2.1965],[-54.3805,2.1977],[-54.3878,2.1963],[-54.4025,2.1971],[-54.434,2.2093],[-54.4766,2.2141],[-54.4927,2.2227],[-54.5114,2.2434],[-54.5458,2.2686],[-54.5491,2.2794],[-54.5264,2.2827],[-54.5443,2.3002],[-54.5646,2.3148],[-54.5882,2.3244],[-54.6153,2.3263],[-54.5992,2.3458],[-54.5848,2.3483],[-54.5512,2.3381],[-54.5316,2.3402],[-54.5203,2.3489],[-54.4934,2.4171],[-54.4726,2.4287],[-54.4505,2.4289],[-54.4355,2.4311],[-54.4235,2.4359],[-54.3756,2.4838],[-54.3594,2.508],[-54.3204,2.6067],[-54.2853,2.678],[-54.2125,2.7764],[-54.2047,2.7918],[-54.1889,2.8383],[-54.1822,2.8465],[-54.1702,2.8531],[-54.1896,2.8706],[-54.1913,2.8773],[-54.1907,2.8878],[-54.187,2.8993],[-54.1702,2.9254],[-54.163,2.956],[-54.1634,2.9697],[-54.1688,2.9714],[-54.1798,2.9837],[-54.1851,2.9978],[-54.1736,3.0045],[-54.1692,3.0107],[-54.1709,3.0248],[-54.177,3.0489],[-54.1907,3.0591],[-54.1885,3.0646],[-54.177,3.0728],[-54.1747,3.0939],[-54.1771,3.1166],[-54.188,3.131],[-54.2112,3.1274],[-54.1905,3.1781],[-54.1766,3.2006],[-54.14,3.245],[-54.1143,3.2854],[-54.0802,3.3097],[-54.0695,3.3271],[-54.0627,3.3467],[-54.0603,3.3642],[-54.0557,3.3777],[-54.0194,3.4154],[-54.003,3.4554],[-54.0063,3.531],[-53.9983,3.573],[-53.9903,3.5957],[-53.9888,3.611],[-53.9948,3.6236],[-54.0088,3.6379],[-54.0179,3.6415],[-54.0501,3.6345],[-54.0507,3.6406],[-54.074,3.6761],[-54.0944,3.7471],[-54.1048,3.758],[-54.1255,3.7887],[-54.1361,3.7957],[-54.1702,3.8058],[-54.1874,3.8147],[-54.1975,3.8269],[-54.2145,3.8582],[-54.218,3.8576],[-54.2222,3.8662],[-54.2411,3.8764],[-54.2658,3.9225],[-54.2865,3.9407],[-54.2931,3.9498],[-54.3039,3.9845],[-54.3102,3.9942],[-54.3444,4.0249],[-54.3539,4.0417],[-54.3552,4.0665],[-54.351,4.0821],[-54.3376,4.1166],[-54.3347,4.1317],[-54.3386,4.1523],[-54.3489,4.1605],[-54.3825,4.1696],[-54.3949,4.1779],[-54.4066,4.1915],[-54.4106,4.2086],[-54.3996,4.2273],[-54.3932,4.2444],[-54.3941,4.2698],[-54.403,4.3129],[-54.4334,4.3764],[-54.4508,4.4842],[-54.448,4.5095],[-54.4282,4.5462],[-54.4235,4.5634],[-54.4235,4.6043],[-54.4253,4.6161],[-54.4377,4.6487],[-54.4386,4.6733],[-54.4351,4.6924],[-54.4355,4.7094],[-54.4473,4.7279],[-54.457,4.7333],[-54.4673,4.7362],[-54.4754,4.7417],[-54.4787,4.7552],[-54.4787,4.8787],[-54.485,4.8928],[-54.4867,4.903],[-54.4821,4.9128],[-54.4555,4.9314],[-54.4508,4.9367],[-54.4488,4.9515],[-54.4576,4.9913],[-54.4548,5.0085],[-54.4486,5.0243],[-54.4302,5.0534],[-54.3756,5.1149],[-54.3723,5.1211],[-54.3699,5.1324],[-54.3654,5.1388],[-54.35,5.1496],[-54.3436,5.1564],[-54.332,5.1962],[-54.3113,5.2258],[-54.2692,5.2691],[-54.1905,5.3257],[-54.171,5.3484],[-54.1375,5.3601],[-54.1067,5.3812],[-54.0804,5.4079],[-54.0611,5.4365],[-54.0331,5.5054],[-54.013,5.5406],[-54.0072,5.5582],[-53.9919,5.6613],[-53.9444,5.7446],[-53.934,5.7448],[-53.8589,5.7338],[-53.8157,5.7159],[-53.8083,5.7148],[-53.8114,5.7206],[-53.8324,5.7317],[-53.8245,5.7332],[-53.8103,5.7311],[-53.7767,5.7142],[-53.7324,5.6842],[-53.6956,5.6635],[-53.5826,5.6178],[-53.5471,5.5999],[-53.5173,5.5808],[-53.4952,5.5721],[-53.4482,5.5609],[-53.4078,5.5618],[-53.3027,5.5355],[-53.2775,5.5382],[-53.2639,5.5299],[-53.2477,5.5098],[-53.2301,5.4953],[-53.2079,5.5023],[-53.2078,5.514],[-53.2252,5.5171],[-53.2648,5.5458],[-53.2827,5.5503],[-53.2895,5.5489],[-53.2914,5.5547],[-53.2812,5.5619],[-53.2715,5.5604],[-53.2517,5.5486],[-53.2212,5.5363],[-53.1776,5.5244],[-53.1302,5.5048],[-53.0825,5.4722],[-53.0462,5.4597],[-53.0058,5.4508],[-53.0014,5.4586],[-52.9946,5.4576],[-52.9651,5.4439],[-52.8965,5.4057],[-52.8291,5.3419],[-52.7832,5.3169],[-52.7529,5.2674],[-52.6812,5.2104],[-52.5409,5.079],[-52.5261,5.0707],[-52.528,5.0579],[-52.5267,5.0536],[-52.505,5.0536],[-52.4797,5.0396],[-52.4023,4.9738],[-52.38,4.9368],[-52.389,4.8959],[-52.3707,4.9072],[-52.3451,4.9429],[-52.3237,4.9506],[-52.3,4.9451],[-52.2791,4.9312],[-52.2643,4.9125],[-52.2586,4.8925],[-52.2765,4.8593],[-52.3131,4.8108],[-52.343,4.7612],[-52.3405,4.7246],[-52.3343,4.7246],[-52.3317,4.7383],[-52.3172,4.7552],[-52.3138,4.7619],[-52.3086,4.7873],[-52.3002,4.8134],[-52.2858,4.8296],[-52.2427,4.8562],[-52.2319,4.8754],[-52.2135,4.8667],[-52.1929,4.8497],[-52.1761,4.8292],[-52.1693,4.81],[-52.1595,4.7956],[-52.0941,4.7581],[-52.0602,4.7305],[-52.0245,4.6935],[-51.9963,4.6523],[-51.9849,4.6113],[-51.9796,4.5714],[-51.956,4.494],[-51.9508,4.454],[-51.9618,4.4084],[-51.9884,4.3857],[-52.0199,4.367],[-52.0463,4.3336],[-51.9856,4.3526],[-51.9514,4.3707],[-51.9365,4.3919],[-51.9249,4.4293],[-51.9228,4.4471],[-51.9313,4.5904],[-51.9254,4.6262],[-51.9092,4.6557],[-51.8964,4.6647],[-51.8812,4.6678],[-51.8648,4.6648],[-51.8483,4.6557],[-51.8015,4.6127],[-51.7931,4.6011],[-51.8008,4.5897],[-51.7735,4.552],[-51.7651,4.529],[-51.7636,4.5061],[-51.758,4.4778],[-51.7475,4.4572],[-51.731,4.4571],[-51.7Line truncated
|
||||
Reference in new issue
Block a user