isard 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +58 -0
- package/README.md +2 -2
- package/dist/animation.d.ts +18 -0
- package/dist/animation.js +84 -0
- package/dist/animation.js.map +1 -0
- package/dist/basemap.worker.d.ts +16 -1
- package/dist/basemap.worker.js +2 -2
- package/dist/basemap.worker.js.map +8 -4
- package/dist/crs.d.ts +72 -0
- package/dist/crs.js +243 -0
- package/dist/crs.js.map +1 -0
- package/dist/decoder.worker.js +4 -4
- package/dist/decoder.worker.js.map +4 -4
- package/dist/engine-loader.d.ts +27 -0
- package/dist/engine-loader.js +112 -0
- package/dist/engine-loader.js.map +1 -0
- package/dist/features.d.ts +8 -0
- package/dist/features.js +17 -10
- package/dist/features.js.map +1 -1
- package/dist/geo.d.ts +16 -0
- package/dist/geo.js +32 -0
- package/dist/geo.js.map +1 -0
- package/dist/geoplateforme.d.ts +21 -5
- package/dist/geoplateforme.js +47 -12
- package/dist/geoplateforme.js.map +1 -1
- package/dist/glyphs.d.ts +10 -3
- package/dist/glyphs.js +14 -2
- package/dist/glyphs.js.map +1 -1
- package/dist/gpx.d.ts +11 -0
- package/dist/gpx.js +74 -0
- package/dist/gpx.js.map +1 -0
- package/dist/grid.d.ts +81 -0
- package/dist/grid.js +270 -0
- package/dist/grid.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/interaction.d.ts +0 -4
- package/dist/interaction.js +8 -4
- package/dist/interaction.js.map +1 -1
- package/dist/isard_bg.wasm +0 -0
- package/dist/isard_core_bg.wasm +0 -0
- package/dist/kml.d.ts +12 -0
- package/dist/kml.js +159 -0
- package/dist/kml.js.map +1 -0
- package/dist/layers.d.ts +1 -1
- package/dist/layers.js +8 -13
- package/dist/layers.js.map +1 -1
- package/dist/lru.d.ts +22 -0
- package/dist/lru.js +52 -0
- package/dist/lru.js.map +1 -0
- package/dist/map.d.ts +16 -4
- package/dist/map.js +72 -302
- package/dist/map.js.map +1 -1
- package/dist/resample.d.ts +41 -0
- package/dist/resample.js +164 -0
- package/dist/resample.js.map +1 -0
- package/dist/settings.d.ts +39 -0
- package/dist/settings.js +104 -0
- package/dist/settings.js.map +1 -0
- package/dist/symbols.d.ts +12 -1
- package/dist/symbols.js +124 -26
- package/dist/symbols.js.map +1 -1
- package/dist/terrain.d.ts +19 -7
- package/dist/terrain.js +40 -28
- package/dist/terrain.js.map +1 -1
- package/dist/topojson.d.ts +29 -0
- package/dist/topojson.js +66 -0
- package/dist/topojson.js.map +1 -0
- package/dist/types.d.ts +12 -4
- package/dist/types.js.map +1 -1
- package/dist/vectortiles.d.ts +10 -3
- package/dist/vectortiles.js +64 -41
- package/dist/vectortiles.js.map +1 -1
- package/dist/wasm/isard.d.ts +9 -3
- package/dist/wasm/isard.js +8 -2
- package/dist/wasm/isard_core.d.ts +1 -1
- package/dist/wasm/isard_core.js +8 -2
- package/dist/wmts.d.ts +14 -0
- package/dist/wmts.js +76 -0
- package/dist/wmts.js.map +1 -0
- package/dist/xml.d.ts +26 -0
- package/dist/xml.js +109 -0
- package/dist/xml.js.map +1 -0
- package/package.json +1 -1
- package/dist/equirectangular.d.ts +0 -35
- package/dist/equirectangular.js +0 -143
- package/dist/equirectangular.js.map +0 -1
package/dist/vectortiles.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { OPENFREEMAP_ATTRIBUTION } from "./basemaps.js";
|
|
2
|
+
import { mercatorX, mercatorY } from "./geo.js";
|
|
2
3
|
import { IGN_ATTRIBUTION } from "./geoplateforme.js";
|
|
4
|
+
import { Lru } from "./lru.js";
|
|
5
|
+
import { SOURCE_CACHE } from "./resample.js";
|
|
3
6
|
import { labelFont, } from "./vectorstyle.js";
|
|
4
7
|
/** OpenFreeMap's styles: OpenStreetMap data in the OpenMapTiles schema, worldwide, free and without a key */
|
|
5
8
|
export const OPENFREEMAP_STYLES = {
|
|
@@ -69,9 +72,8 @@ export function tilePriority(z, x, y, camera) {
|
|
|
69
72
|
return 'low';
|
|
70
73
|
const n = 2 ** z;
|
|
71
74
|
const [lon, lat] = camera.center;
|
|
72
|
-
const cx = (
|
|
73
|
-
const
|
|
74
|
-
const cy = ((1 - Math.log(Math.tan(phi) + 1 / Math.cos(phi)) / Math.PI) / 2) * n;
|
|
75
|
+
const cx = mercatorX(lon) * n;
|
|
76
|
+
const cy = mercatorY(lat) * n;
|
|
75
77
|
// Across the antimeridian, the short way
|
|
76
78
|
let dx = Math.abs(x + 0.5 - cx) % n;
|
|
77
79
|
dx = Math.min(dx, n - dx);
|
|
@@ -190,6 +192,19 @@ export class BasemapWorkers {
|
|
|
190
192
|
worker.postMessage({ ...work, id });
|
|
191
193
|
});
|
|
192
194
|
}
|
|
195
|
+
/** The altitudes of a PNG relief tile `z`/`x`/`y` at `url`, decoded by a worker (see `fetchHeights`) */
|
|
196
|
+
heights(url, encoding, floor, [z, x, y], signal, owner) {
|
|
197
|
+
const work = { type: 'heights', url, encoding, ...(floor === undefined ? {} : { floor }) };
|
|
198
|
+
return this.request(this.worker(z, x, y), work, owner, signal).then((r) => ('heights' in r ? r.heights : null));
|
|
199
|
+
}
|
|
200
|
+
/** Mercator tile `z`/`x`/`y` reprojected by a worker from the source images of its plan (see `resampler`) */
|
|
201
|
+
reproject(job, [z, x, y], signal, owner) {
|
|
202
|
+
// Blocks of 4 × 4 Mercator tiles go to the same worker: neighbours share source tiles, each worker keeps its share
|
|
203
|
+
const worker = this.worker(Math.max(0, z - 2), x >> 2, y >> 2);
|
|
204
|
+
const cached = Math.max(16, Math.ceil(SOURCE_CACHE / this.workers.length));
|
|
205
|
+
const work = { type: 'reproject', job, cached };
|
|
206
|
+
return this.request(worker, work, owner, signal).then((r) => ('image' in r ? r.image : null));
|
|
207
|
+
}
|
|
193
208
|
/** Cancels the requests of an owner (the workers stop them) */
|
|
194
209
|
cancel(owner) {
|
|
195
210
|
for (const [id, p] of this.pending) {
|
|
@@ -213,6 +228,31 @@ export class BasemapWorkers {
|
|
|
213
228
|
p.reject(new DOMException('isard: vector tiles destroyed', 'AbortError'));
|
|
214
229
|
}
|
|
215
230
|
}
|
|
231
|
+
/** A tile's label candidates as features, by style layer */
|
|
232
|
+
export function tileLabels(candidates) {
|
|
233
|
+
const byLayer = new Map();
|
|
234
|
+
for (const p of candidates) {
|
|
235
|
+
const feature = {
|
|
236
|
+
type: 'Feature',
|
|
237
|
+
properties: p,
|
|
238
|
+
geometry: p.along
|
|
239
|
+
? {
|
|
240
|
+
type: 'LineString',
|
|
241
|
+
coordinates: [
|
|
242
|
+
[p.lon - p.along[0] / 2, p.lat - p.along[1] / 2],
|
|
243
|
+
[p.lon + p.along[0] / 2, p.lat + p.along[1] / 2],
|
|
244
|
+
],
|
|
245
|
+
}
|
|
246
|
+
: { type: 'Point', coordinates: [p.lon, p.lat] },
|
|
247
|
+
};
|
|
248
|
+
const list = byLayer.get(p.layer);
|
|
249
|
+
if (list)
|
|
250
|
+
list.push(feature);
|
|
251
|
+
else
|
|
252
|
+
byLayer.set(p.layer, [feature]);
|
|
253
|
+
}
|
|
254
|
+
return [...byLayer].sort((a, b) => b[0] - a[0]);
|
|
255
|
+
}
|
|
216
256
|
export class VectorTiles {
|
|
217
257
|
map;
|
|
218
258
|
pool;
|
|
@@ -386,8 +426,9 @@ export class VectorTiles {
|
|
|
386
426
|
return this.renderer((l) => l.type === 'symbol' && layers(l), []);
|
|
387
427
|
});
|
|
388
428
|
renderer.catch(() => undefined);
|
|
389
|
-
/** The labels of the tiles, the
|
|
390
|
-
|
|
429
|
+
/** The labels of the tiles, as features by style layer, the higher layers first: each list is given to the symbol
|
|
430
|
+
* layer as a group, shaped once while the tile is kept */
|
|
431
|
+
const tiles = new Lru(256);
|
|
391
432
|
let generation = 0;
|
|
392
433
|
/** The tiles whose labels are shown */
|
|
393
434
|
let shown = '';
|
|
@@ -400,12 +441,9 @@ export class VectorTiles {
|
|
|
400
441
|
const z = Math.max(0, Math.min(Math.floor(camera.zoom), maxzoom));
|
|
401
442
|
const n = 2 ** z;
|
|
402
443
|
const [west, south, east, north] = this.map.getBounds();
|
|
403
|
-
const tx = (lon) => Math.floor((
|
|
404
|
-
const ty = (lat) =>
|
|
405
|
-
|
|
406
|
-
return Math.floor(((1 - Math.log(Math.tan(phi) + 1 / Math.cos(phi)) / Math.PI) / 2) * n);
|
|
407
|
-
};
|
|
408
|
-
const [cx, cy] = [((camera.center[0] + 180) / 360) * n, ty(camera.center[1])];
|
|
444
|
+
const tx = (lon) => Math.floor(mercatorX(lon) * n);
|
|
445
|
+
const ty = (lat) => Math.floor(mercatorY(lat) * n);
|
|
446
|
+
const [cx, cy] = [mercatorX(camera.center[0]) * n, ty(camera.center[1])];
|
|
409
447
|
// The tiles of the bounds, within a window around the center: a tilted view's bounds reach far, and only the
|
|
410
448
|
// nearest `maxTiles` are kept anyway
|
|
411
449
|
const reach = Math.ceil(Math.sqrt(maxTiles)) + 2;
|
|
@@ -430,51 +468,36 @@ export class VectorTiles {
|
|
|
430
468
|
return;
|
|
431
469
|
const lists = await Promise.all(keys.map((k, index) => {
|
|
432
470
|
let p = tiles.get(k);
|
|
433
|
-
if (p)
|
|
434
|
-
// Used again: the most recent
|
|
435
|
-
tiles.delete(k);
|
|
436
|
-
tiles.set(k, p);
|
|
471
|
+
if (p)
|
|
437
472
|
return p;
|
|
438
|
-
}
|
|
439
473
|
const [tz, x, y] = k.split('/').map(Number);
|
|
440
474
|
// The nearest tiles first: the others wait for the raster tiles
|
|
441
475
|
const priority = index < 4 ? 'auto' : 'low';
|
|
442
|
-
p = this.request(tz, x, y, { type: 'labels', key, z: tz, x, y, priority }).then((r) => ('labels' in r ? r.labels : []), () => {
|
|
476
|
+
p = this.request(tz, x, y, { type: 'labels', key, z: tz, x, y, priority }).then((r) => tileLabels('labels' in r ? r.labels : []), () => {
|
|
443
477
|
// A network error is not kept: the tile is asked for again on the next update
|
|
444
478
|
tiles.delete(k);
|
|
445
479
|
return [];
|
|
446
480
|
});
|
|
447
|
-
tiles.set(k, p);
|
|
448
481
|
// A bounded cache of tiles' labels, the least recently used dropped
|
|
449
|
-
|
|
450
|
-
const oldest = tiles.keys().next().value;
|
|
451
|
-
if (oldest !== undefined)
|
|
452
|
-
tiles.delete(oldest);
|
|
453
|
-
}
|
|
482
|
+
tiles.set(k, p);
|
|
454
483
|
return p;
|
|
455
484
|
}));
|
|
456
485
|
if (run !== generation || this.destroyed)
|
|
457
486
|
return;
|
|
458
487
|
// A tile that failed is missing: the next update asks for it again
|
|
459
488
|
shown = keys.every((k) => tiles.has(k)) ? set : '';
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
[p.lon + p.along[0] / 2, p.lat + p.along[1] / 2],
|
|
473
|
-
]
|
|
474
|
-
: [p.lon, p.lat],
|
|
475
|
-
},
|
|
476
|
-
}));
|
|
477
|
-
symbol.setData(features);
|
|
489
|
+
// The labels of the higher style layers first: they win the collisions; for each style layer, the tiles nearest
|
|
490
|
+
// to the center first
|
|
491
|
+
const layerIds = [...new Set(lists.flatMap((list) => list.map(([layer]) => layer)))].sort((a, b) => b - a);
|
|
492
|
+
const groups = [];
|
|
493
|
+
for (const layer of layerIds) {
|
|
494
|
+
for (const list of lists) {
|
|
495
|
+
const group = list.find(([l]) => l === layer)?.[1];
|
|
496
|
+
if (group)
|
|
497
|
+
groups.push(group);
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
symbol.setGroups(groups);
|
|
478
501
|
};
|
|
479
502
|
// The style failed to load: reported by `ready`
|
|
480
503
|
const refresh = () => {
|
package/dist/vectortiles.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vectortiles.js","sourceRoot":"","sources":["../src/vectortiles.ts"],"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CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;QACxB,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM;YAAE,IAAI,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC;gBAAE,KAAK,CAAC,MAAM,EAAE,CAAC;QAC9E,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;QACvB,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QAC/B,0DAA0D;QAC1D,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC5E,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;QACxB,CAAC;aAAM,CAAC;YACN,8DAA8D;YAC9D,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACvB,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,SAAS;gBAAE,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;QAC/E,CAAC;QACD,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;IAC5B,CAAC;CACF","sourcesContent":["/**\n * Vector basemaps from a MapLibre style (OpenFreeMap's Positron by default): the fills, lines, circles and raster\n * layers drawn tile by tile in workers into the raster pool, so that they lie on the relief like any basemap and composite\n * with the hillshade in one pass; and the labels of the style's symbol layers in a symbol layer of their own, kept\n * above the application's layers (as MapLibre's `beforeId: firstSymbol` does), shaped and placed by the engine.\n *\n * Any subset of the style can be drawn on its own raster layer (`raster({ layers })`), at its own place in the stack:\n * rivers from the basemap's data over a flood layer, for instance, restyled with `extraLayers`.\n */\nimport type { BasemapRequest, BasemapResponse, BasemapWork, Priority, Sprite } from './basemap.worker.ts';\nimport { OPENFREEMAP_ATTRIBUTION } from './basemaps.ts';\nimport type { Feature, Size } from './features.ts';\nimport { IGN_ATTRIBUTION } from './geoplateforme.ts';\nimport type { Layer, RasterLayer } from './layers.ts';\nimport type { GeoMap } from './map.ts';\nimport type { Anchor } from './overlay.ts';\nimport type { SymbolLayer } from './symbols.ts';\nimport {\n type Json,\n type LabelCandidate,\n labelFont,\n type RasterSource,\n type Style,\n type StyleLayer,\n} from './vectorstyle.ts';\nimport type { Camera } from './wasm/isard.js';\n\n/** OpenFreeMap's styles: OpenStreetMap data in the OpenMapTiles schema, worldwide, free and without a key */\nexport const OPENFREEMAP_STYLES = {\n positron: 'https://tiles.openfreemap.org/styles/positron',\n liberty: 'https://tiles.openfreemap.org/styles/liberty',\n bright: 'https://tiles.openfreemap.org/styles/bright',\n} as const;\n\n/** PLAN.IGN vector styles of the Géoplateforme (France) */\nexport const PLAN_STYLES = {\n standard: 'https://data.geopf.fr/annexes/ressources/vectorTiles/styles/PLAN.IGN/standard.json',\n grey: 'https://data.geopf.fr/annexes/ressources/vectorTiles/styles/PLAN.IGN/gris.json',\n} as const;\n\n/** Vector basemaps by name (see `BasemapName`) */\nexport const VECTOR_BASEMAPS = {\n 'osm-positron': OPENFREEMAP_STYLES.positron,\n 'osm-liberty': OPENFREEMAP_STYLES.liberty,\n 'osm-bright': OPENFREEMAP_STYLES.bright,\n 'ign-plan-vector': PLAN_STYLES.standard,\n 'ign-plan-grey-vector': PLAN_STYLES.grey,\n} as const;\n\nexport interface VectorTilesOptions {\n /** A style URL or object (default OpenFreeMap's Positron) */\n style?: string | Style;\n /** Workers drawing the tiles (default cores - 1, 1 to 4). The vector tiles of a map share its workers (and their\n * decoded tiles); another count gives these tiles workers of their own */\n workers?: number;\n /** Where to load the worker from, when a bundler does not resolve the default URL (default the map's\n * `basemapWorkerUrl`); another URL than the map's gives these tiles workers of their own */\n workerUrl?: string | URL;\n /** Credits of the tiles, shown while its raster layers are on the map (default: OpenFreeMap's for its styles, the\n * IGN's for PLAN.IGN's) */\n attribution?: string;\n}\n\n/** The credits of a known style: OpenFreeMap's, PLAN.IGN's */\nexport function styleAttribution(style: string | Style): string | undefined {\n if (typeof style !== 'string') return undefined;\n if ((Object.values(OPENFREEMAP_STYLES) as string[]).includes(style)) return OPENFREEMAP_ATTRIBUTION;\n if ((Object.values(PLAN_STYLES) as string[]).includes(style)) return IGN_ATTRIBUTION;\n return undefined;\n}\n\n/** Text size of a style (a number, legacy stops, or the stops of a zoom expression made by the worker) as a size for\n * the symbol layer */\nfunction size(value: Json): Size {\n if (typeof value === 'number') return value;\n if (Array.isArray(value) && value.length > 0 && value.every(Array.isArray)) {\n return value.map((s) => [Number((s as Json[])[0]), Number((s as Json[])[1])] as [number, number]);\n }\n if (value && typeof value === 'object' && !Array.isArray(value) && Array.isArray(value.stops)) {\n return (value.stops as Json[]).map((s) => {\n const [z, v] = s as [number, number];\n return [Number(z), Number(v)] as [number, number];\n });\n }\n return 16;\n}\n\n/** Fetches a JSON document (a style, a TileJSON) */\nasync function json<T>(url: string): Promise<T> {\n const response = await fetch(url);\n if (!response.ok) throw new Error(`${url}: ${response.status}`);\n return (await response.json()) as T;\n}\n\n/** Default size of a basemap worker pool: cores - 1, 1 to 4 */\nexport function defaultWorkerCount(): number {\n return Math.min(4, Math.max(1, (typeof navigator !== 'undefined' ? navigator.hardwareConcurrency || 2 : 2) - 1));\n}\n\n/** Default URL of the basemap worker, next to the module */\nexport function defaultWorkerUrl(): URL {\n return new URL('./basemap.worker.js', import.meta.url);\n}\n\n/** Fetch priority of a raster tile drawn by the workers: 'high' near the center of the view, at the current zoom or\n * coarser; 'low' far from it or finer (prefetch); 'auto' between */\nexport function tilePriority(z: number, x: number, y: number, camera: Pick<Camera, 'center' | 'zoom'>): Priority {\n // A raster tile of level z covers the map at zoom z - 1\n if (z - 1 > camera.zoom + 1) return 'low';\n const n = 2 ** z;\n const [lon, lat] = camera.center;\n const cx = ((lon + 180) / 360) * n;\n const phi = (Math.max(-85.05, Math.min(85.05, lat)) * Math.PI) / 180;\n const cy = ((1 - Math.log(Math.tan(phi) + 1 / Math.cos(phi)) / Math.PI) / 2) * n;\n // Across the antimeridian, the short way\n let dx = Math.abs(x + 0.5 - cx) % n;\n dx = Math.min(dx, n - dx);\n const d = Math.hypot(dx, y + 0.5 - cy);\n if (d <= 1.5) return 'high';\n return d >= 4 ? 'low' : 'auto';\n}\n\n/** The worker of a vector tile among `count`: always the same one */\nexport function workerIndex(vz: number, vx: number, vy: number, count: number): number {\n // Unsigned: every worker gets its share\n return ((Math.imul(vx, 73856093) ^ Math.imul(vy, 19349663) ^ vz) >>> 0) % Math.max(1, count);\n}\n\n/** The worker-side key of a renderer: unique across the `VectorTiles` sharing a pool */\nexport function rendererKey(namespace: string, n: number): string {\n return `${namespace}:r${n}`;\n}\n\n/** What the pool needs of a worker (a `Worker`, or a stand-in in tests) */\nexport type PoolWorker = Pick<Worker, 'postMessage' | 'terminate' | 'onmessage' | 'onerror' | 'onmessageerror'>;\n\n/**\n * @internal Workers drawing vector tiles, shared by the `VectorTiles` of a map: each vector tile always goes to the\n * same worker, which keeps it decoded for every style drawn from it. Requests are tracked one by one, with their\n * owner, so that one `VectorTiles` going away cancels its own requests only.\n */\nexport class BasemapWorkers {\n private readonly workers: PoolWorker[];\n private readonly pending = new Map<\n number,\n { resolve: (r: BasemapResponse) => void; reject: (e: Error) => void; worker: PoolWorker; owner: object }\n >();\n private next = 1;\n private namespaces = 0;\n private terminated = false;\n\n constructor(\n readonly count: number,\n readonly url: string | URL,\n create: (url: string | URL) => PoolWorker = (u) => new Worker(u, { type: 'module' }),\n ) {\n this.workers = Array.from({ length: Math.max(1, count) }, () => {\n const worker = create(url);\n worker.onmessage = ({ data }: MessageEvent<BasemapResponse>) => {\n const p = this.pending.get(data.id);\n if (!p) return;\n this.pending.delete(data.id);\n if ('error' in data) p.reject(new Error(data.error));\n else p.resolve(data);\n };\n // A worker that fails to load (a bundler serving it from elsewhere) or to read a message fails its requests\n worker.onerror = (event) => {\n event.preventDefault();\n this.fail(worker, `the vector basemap worker ${url} failed${event.message ? `: ${event.message}` : ''}`);\n };\n worker.onmessageerror = () => this.fail(worker, `the vector basemap worker ${url} sent an unreadable message`);\n return worker;\n });\n }\n\n /** A prefix for the renderer keys of one `VectorTiles` */\n namespace(): string {\n return `v${this.namespaces++}`;\n }\n\n /** Requests in progress */\n get size(): number {\n return this.pending.size;\n }\n\n /** Rejects the requests of a failed worker */\n private fail(worker: PoolWorker, message: string): void {\n const error = new Error(\n `isard: ${message}. If a bundler moves the worker, give its URL in the \\`basemapWorkerUrl\\` option (see \"With a bundler\" in the guide)`,\n );\n for (const [id, p] of this.pending) {\n if (p.worker !== worker) continue;\n this.pending.delete(id);\n p.reject(error);\n }\n }\n\n /** The worker of a vector tile */\n worker(vz: number, vx: number, vy: number): PoolWorker {\n return this.workers[workerIndex(vz, vx, vy, this.workers.length)] ?? (this.workers[0] as PoolWorker);\n }\n\n /** Sends a message to every worker (a renderer, or its removal) */\n broadcast(message: Extract<BasemapRequest, { type: 'init' } | { type: 'drop' }>): void {\n if (this.terminated) return;\n // A renderer tells the workers how many they are: they share the decoded tiles' budget\n const sent = message.type === 'init' ? { ...message, workers: this.workers.length } : message;\n // A sprite image is copied to each worker (structured clone)\n for (const w of this.workers) w.postMessage(sent);\n }\n\n /** Asks a worker for a tile's image or labels, on behalf of `owner` */\n request(worker: PoolWorker, work: BasemapWork, owner: object, signal?: AbortSignal): Promise<BasemapResponse> {\n return new Promise<BasemapResponse>((resolve, reject) => {\n if (this.terminated) return reject(new DOMException('isard: vector tiles destroyed', 'AbortError'));\n if (signal?.aborted) return reject(new DOMException('aborted', 'AbortError'));\n const id = this.next++;\n const abort = () => {\n if (!this.pending.delete(id)) return;\n worker.postMessage({ type: 'abort', id } satisfies BasemapRequest);\n reject(new DOMException('aborted', 'AbortError'));\n };\n // The listener goes once the request is settled\n const settle = () => signal?.removeEventListener('abort', abort);\n this.pending.set(id, {\n resolve: (r) => {\n settle();\n resolve(r);\n },\n reject: (e) => {\n settle();\n reject(e);\n },\n worker,\n owner,\n });\n signal?.addEventListener('abort', abort, { once: true });\n worker.postMessage({ ...work, id } satisfies BasemapRequest);\n });\n }\n\n /** Cancels the requests of an owner (the workers stop them) */\n cancel(owner: object): void {\n for (const [id, p] of this.pending) {\n if (p.owner !== owner) continue;\n this.pending.delete(id);\n p.worker.postMessage({ type: 'abort', id } satisfies BasemapRequest);\n p.reject(new DOMException('isard: vector tiles destroyed', 'AbortError'));\n }\n }\n\n /** Stops the workers; their requests fail */\n terminate(): void {\n if (this.terminated) return;\n this.terminated = true;\n for (const w of this.workers) w.terminate();\n const pending = [...this.pending.values()];\n this.pending.clear();\n for (const p of pending) p.reject(new DOMException('isard: vector tiles destroyed', 'AbortError'));\n }\n}\n\nexport class VectorTiles {\n private readonly pool: BasemapWorkers;\n /** The pool is this instance's own (a worker count or URL other than the map's): stopped with it */\n private readonly ownPool: boolean;\n /** Prefix of its renderer keys in the pool's workers */\n private readonly namespace: string;\n private destroyed = false;\n private keys = 0;\n /** Renderers sent to the workers, dropped on destroy */\n private readonly renderers: string[] = [];\n private readonly cleanup: (() => void)[] = [];\n /** Credits of its raster layers */\n private readonly attribution: string | undefined;\n /** Its raster and label layers, removed with it */\n private readonly layers: Layer[] = [];\n /** The style once loaded, with its source resolved */\n readonly ready: Promise<{ style: Style; tiles: string; maxzoom: number; rasters: Record<string, RasterSource> }>;\n\n /**\n * Its workers are the map's (shared by every `VectorTiles` of the map, a vector tile decoded once for all of them),\n * unless `workers` or `workerUrl` asks for others than the map's: then it has workers of its own\n */\n constructor(\n private readonly map: GeoMap,\n options: VectorTilesOptions = {},\n ) {\n const { pool, own } = map.basemapWorkers(options.workers, options.workerUrl);\n this.pool = pool;\n this.ownPool = own;\n this.namespace = pool.namespace();\n const style = options.style ?? OPENFREEMAP_STYLES.positron;\n this.attribution = options.attribution ?? styleAttribution(style);\n this.ready = this.load(style);\n // Reported once here; `ready`, the raster tiles and the labels fail with it\n this.ready.catch((error: unknown) => {\n if (!this.destroyed) console.warn('isard: vector tiles', error);\n });\n }\n\n private async load(input: string | Style) {\n const style = typeof input === 'string' ? await json<Style>(input) : input;\n const [name, source] = Object.entries(style.sources).find(([, s]) => s.type === 'vector') ?? [];\n if (!name || !source) throw new Error('the style has no vector source');\n let { tiles, maxzoom } = source;\n if (!tiles && source.url) {\n const tilejson = await json<{ tiles: string[]; maxzoom?: number }>(source.url);\n tiles = tilejson.tiles;\n maxzoom ??= tilejson.maxzoom;\n }\n const template = tiles?.[0];\n if (!template) throw new Error(`source ${name} has no tiles`);\n // Its raster sources of tiles, drawn into the same images (the shaded relief of a style at low zoom)\n const rasters: Record<string, RasterSource> = {};\n for (const [key, s] of Object.entries(style.sources)) {\n const url = s.type === 'raster' ? s.tiles?.[0] : undefined;\n if (url) rasters[key] = { tiles: url, maxzoom: s.maxzoom ?? 22, tileSize: s.tileSize ?? 512 };\n }\n // Only the layers of those sources (and the background); other types (hillshade, heatmap…) are left out. The\n // application's style object stays as it is\n const layers = style.layers.filter(\n (l) =>\n l.type === 'background' ||\n (l.source === name && l.type !== 'raster') ||\n (l.type === 'raster' && l.source !== undefined && rasters[l.source] !== undefined),\n );\n return { style: { ...style, layers }, tiles: template, maxzoom: maxzoom ?? 14, rasters };\n }\n\n /** The fonts of the style's labels, for its glyphs (the first of each `text-font`, as the workers take it) */\n private static fonts(style: Style): string[] {\n const fonts = new Set<string>();\n for (const layer of style.layers) {\n const font = layer.layout?.['text-font'];\n if (layer.type === 'symbol' && Array.isArray(font) && typeof font[0] === 'string') fonts.add(labelFont(font[0]));\n }\n return [...fonts];\n }\n\n /** The style's sprite (its JSON and its image), loaded once, for the renderers that draw fill patterns */\n private sprite: Promise<Sprite | undefined> | undefined;\n\n private loadSprite(url: string): Promise<Sprite | undefined> {\n this.sprite ??= (async () => {\n try {\n const [json, png] = await Promise.all([fetch(`${url}.json`), fetch(`${url}.png`)]);\n if (!json.ok || !png.ok) return undefined;\n return { icons: await json.json(), image: await createImageBitmap(await png.blob()) };\n } catch {\n return undefined;\n }\n })();\n return this.sprite;\n }\n\n private request(vz: number, vx: number, vy: number, work: BasemapWork, signal?: AbortSignal) {\n if (this.destroyed) return Promise.reject(new DOMException('isard: vector tiles destroyed', 'AbortError'));\n return this.pool.request(this.pool.worker(vz, vx, vy), work, this, signal);\n }\n\n /** Sends a renderer of these layers to every worker; returns its key */\n private async renderer(select: (layer: StyleLayer) => boolean, extra: StyleLayer[]) {\n const { style, tiles, maxzoom, rasters } = await this.ready;\n const key = rendererKey(this.namespace, this.keys++);\n const layers = [...style.layers.filter(select), ...extra];\n const patterns = layers.some((l) => l.paint?.['fill-pattern'] !== undefined);\n // The image is downloaded once, copied to each worker\n const sprite = patterns && style.sprite ? await this.loadSprite(style.sprite) : undefined;\n if (this.destroyed) throw new DOMException('isard: vector tiles destroyed', 'AbortError');\n this.pool.broadcast({ type: 'init', key, tiles, maxzoom, layers, rasters, ...(sprite ? { sprite } : {}) });\n this.renderers.push(key);\n return { key, maxzoom };\n }\n\n /**\n * A raster layer drawing the style's fills, lines and circles (or those `layers` keeps, then `extraLayers`, of the\n * same source); `size`: texture size of its tiles (512 by default: sharp lines)\n */\n raster(\n options: {\n layers?: (layer: StyleLayer) => boolean;\n extraLayers?: StyleLayer[];\n size?: number;\n opacity?: number;\n minZoom?: number;\n maxZoom?: number;\n before?: Parameters<GeoMap['addRaster']>[0]['before'];\n } = {},\n ): RasterLayer {\n const { layers = () => true, extraLayers = [], size: texture = 512, opacity = 1, before } = options;\n const drawn = (l: StyleLayer) => l.type !== 'symbol' && layers(l);\n const renderer = this.renderer(drawn, extraLayers);\n // Its failure is reported by `ready` and each tile\n renderer.catch(() => undefined);\n const loader = async (z: number, x: number, y: number, signal: AbortSignal) => {\n const { key, maxzoom } = await renderer;\n // The vector tile it is drawn from (see the worker)\n const vz = Math.max(0, Math.min(z - 1, maxzoom));\n const shift = z - vz;\n const priority = tilePriority(z, x, y, this.map.getCamera());\n const response = await this.request(\n vz,\n x >> shift,\n y >> shift,\n { type: 'render', key, z, x, y, size: texture, priority },\n signal,\n );\n return 'image' in response ? response.image : null;\n };\n const layer = this.map.addRaster({\n url: '',\n size: texture,\n opacity,\n minZoom: options.minZoom ?? 0,\n maxZoom: options.maxZoom ?? 20,\n loader,\n ...(this.attribution ? { attribution: this.attribution } : {}),\n ...(before ? { before } : {}),\n });\n this.layers.push(layer);\n return layer;\n }\n\n /**\n * A symbol layer with the labels of the style's symbol layers (or those `layers` keeps), updated as the view\n * moves: the labels of the vector tiles in view, the higher style layers placed first. It stays above the layers\n * added after it unless one is moved over it.\n */\n labels(options: { layers?: (layer: StyleLayer) => boolean; maxTiles?: number } = {}): SymbolLayer<LabelCandidate> {\n const { layers = () => true, maxTiles = 36 } = options;\n const symbol = this.map.addSymbols<LabelCandidate>({\n data: [],\n text: (p) => p.text,\n font: (p) => p.font,\n size: (p) => size(p.size),\n color: (p) => p.color,\n haloColor: (p) => p.haloColor,\n haloWidth: (p) => p.haloWidth,\n anchor: (p) => p.anchor as Anchor,\n offset: (p) => p.offset,\n maxWidth: (p) => p.maxWidth,\n lineHeight: (p) => p.lineHeight,\n overlap: (p) => p.overlap,\n placement: 'line',\n });\n this.map.keepOnTop(symbol);\n this.layers.push(symbol);\n const renderer = this.ready.then(({ style }) => {\n // The style's fonts from its own glyphs\n if (style.glyphs) this.map.glyphs.register(style.glyphs, VectorTiles.fonts(style));\n return this.renderer((l) => l.type === 'symbol' && layers(l), []);\n });\n renderer.catch(() => undefined);\n /** The labels of the tiles, the most recently used last */\n const tiles = new Map<string, Promise<LabelCandidate[]>>();\n let generation = 0;\n /** The tiles whose labels are shown */\n let shown = '';\n const update = async () => {\n if (this.destroyed) return;\n const { key, maxzoom } = await renderer;\n const run = ++generation;\n const camera = this.map.getCamera();\n const z = Math.max(0, Math.min(Math.floor(camera.zoom), maxzoom));\n const n = 2 ** z;\n const [west, south, east, north] = this.map.getBounds();\n const tx = (lon: number) => Math.floor(((lon + 180) / 360) * n);\n const ty = (lat: number) => {\n const phi = (Math.max(-85.05, Math.min(85.05, lat)) * Math.PI) / 180;\n return Math.floor(((1 - Math.log(Math.tan(phi) + 1 / Math.cos(phi)) / Math.PI) / 2) * n);\n };\n const [cx, cy] = [((camera.center[0] + 180) / 360) * n, ty(camera.center[1])];\n // The tiles of the bounds, within a window around the center: a tilted view's bounds reach far, and only the\n // nearest `maxTiles` are kept anyway\n const reach = Math.ceil(Math.sqrt(maxTiles)) + 2;\n const [x0, x1] = [\n Math.max(0, tx(west), Math.floor(cx) - reach),\n Math.min(n - 1, tx(east), Math.floor(cx) + reach),\n ];\n const [y0, y1] = [\n Math.max(0, ty(north), Math.floor(cy) - reach),\n Math.min(n - 1, ty(south), Math.floor(cy) + reach),\n ];\n const wanted: [number, number][] = [];\n for (let y = y0; y <= y1; y += 1) for (let x = x0; x <= x1; x += 1) wanted.push([x, y]);\n // Nearest to the center first, at most `maxTiles` (tilted views reach far)\n wanted.sort(\n (a, b) => Math.hypot(a[0] + 0.5 - cx, a[1] + 0.5 - cy) - Math.hypot(b[0] + 0.5 - cx, b[1] + 0.5 - cy),\n );\n const keys = wanted.slice(0, maxTiles).map(([x, y]) => `${z}/${x}/${y}`);\n // The same tiles as the labels shown: nothing to do\n const set = keys.join(' ');\n if (set === shown) return;\n const lists = await Promise.all(\n keys.map((k, index) => {\n let p = tiles.get(k);\n if (p) {\n // Used again: the most recent\n tiles.delete(k);\n tiles.set(k, p);\n return p;\n }\n const [tz, x, y] = k.split('/').map(Number) as [number, number, number];\n // The nearest tiles first: the others wait for the raster tiles\n const priority: Priority = index < 4 ? 'auto' : 'low';\n p = this.request(tz, x, y, { type: 'labels', key, z: tz, x, y, priority }).then(\n (r) => ('labels' in r ? r.labels : []),\n () => {\n // A network error is not kept: the tile is asked for again on the next update\n tiles.delete(k);\n return [];\n },\n );\n tiles.set(k, p);\n // A bounded cache of tiles' labels, the least recently used dropped\n if (tiles.size > 256) {\n const oldest = tiles.keys().next().value;\n if (oldest !== undefined) tiles.delete(oldest);\n }\n return p;\n }),\n );\n if (run !== generation || this.destroyed) return;\n // A tile that failed is missing: the next update asks for it again\n shown = keys.every((k) => tiles.has(k)) ? set : '';\n const features: Feature<LabelCandidate>[] = lists\n .flat()\n // The labels of the higher style layers first: they win the collisions\n .sort((a, b) => b.layer - a.layer)\n .map(\n (p) =>\n ({\n type: 'Feature',\n properties: p,\n geometry: {\n type: p.along ? 'LineString' : 'Point',\n coordinates: p.along\n ? [\n [p.lon - p.along[0] / 2, p.lat - p.along[1] / 2],\n [p.lon + p.along[0] / 2, p.lat + p.along[1] / 2],\n ]\n : [p.lon, p.lat],\n },\n }) as Feature<LabelCandidate>,\n );\n symbol.setData(features);\n };\n // The style failed to load: reported by `ready`\n const refresh = () => {\n update().catch(() => undefined);\n };\n let timer = 0;\n const schedule = () => {\n if (timer) return;\n timer = window.setTimeout(() => {\n timer = 0;\n refresh();\n }, 250);\n };\n this.cleanup.push(this.map.on('move', schedule), this.map.on('moveend', refresh), () => clearTimeout(timer));\n refresh();\n return symbol;\n }\n\n /** Stops its workers' work and removes its raster and label layers from the map (those still there) */\n destroy(): void {\n if (this.destroyed) return;\n this.destroyed = true;\n for (const off of this.cleanup) off();\n this.cleanup.length = 0;\n for (const layer of this.layers) if (this.map.hasLayer(layer)) layer.remove();\n this.layers.length = 0;\n this.map.dropVectorTiles(this);\n // The page's copy of the sprite (the workers have theirs)\n this.sprite?.then((sprite) => sprite?.image.close()).catch(() => undefined);\n if (this.ownPool) {\n this.pool.terminate();\n } else {\n // Shared workers: only its requests stop and its renderers go\n this.pool.cancel(this);\n for (const key of this.renderers) this.pool.broadcast({ type: 'drop', key });\n }\n this.renderers.length = 0;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"vectortiles.js","sourceRoot":"","sources":["../src/vectortiles.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,u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IAAI,IAAI,CAAC,SAAS;YAAE,OAAO;QAC3B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,OAAO;YAAE,GAAG,EAAE,CAAC;QACtC,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;QACxB,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM;YAAE,IAAI,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC;gBAAE,KAAK,CAAC,MAAM,EAAE,CAAC;QAC9E,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;QACvB,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QAC/B,0DAA0D;QAC1D,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC5E,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;QACxB,CAAC;aAAM,CAAC;YACN,8DAA8D;YAC9D,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACvB,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,SAAS;gBAAE,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;QAC/E,CAAC;QACD,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;IAC5B,CAAC;CACF","sourcesContent":["/**\n * Vector basemaps from a MapLibre style (OpenFreeMap's Positron by default): the fills, lines, circles and raster\n * layers drawn tile by tile in workers into the raster pool, so that they lie on the relief like any basemap and\n * composite with the hillshade in one pass; and the labels of the style's symbol layers in a symbol layer of their own,\n * kept above the application's layers (as MapLibre's `beforeId: firstSymbol` does), listed by the workers, shaped in\n * the page once per vector tile, placed by the engine.\n *\n * Any subset of the style can be drawn on its own raster layer (`raster({ layers })`), at its own place in the stack:\n * rivers from the basemap's data over a flood layer, for instance, restyled with `extraLayers`.\n */\nimport type { BasemapRequest, BasemapResponse, BasemapWork, Priority, Sprite } from './basemap.worker.ts';\nimport { OPENFREEMAP_ATTRIBUTION } from './basemaps.ts';\nimport type { Feature, Size } from './features.ts';\nimport { mercatorX, mercatorY } from './geo.ts';\nimport { IGN_ATTRIBUTION } from './geoplateforme.ts';\nimport type { Layer, RasterLayer } from './layers.ts';\nimport { Lru } from './lru.ts';\nimport type { GeoMap } from './map.ts';\nimport type { Anchor } from './overlay.ts';\nimport { type Job, SOURCE_CACHE } from './resample.ts';\nimport type { SymbolLayer } from './symbols.ts';\nimport type { PngEncoding } from './terrain.ts';\nimport {\n type Json,\n type LabelCandidate,\n labelFont,\n type RasterSource,\n type Style,\n type StyleLayer,\n} from './vectorstyle.ts';\nimport type { Camera } from './wasm/isard.js';\n\n/** OpenFreeMap's styles: OpenStreetMap data in the OpenMapTiles schema, worldwide, free and without a key */\nexport const OPENFREEMAP_STYLES = {\n positron: 'https://tiles.openfreemap.org/styles/positron',\n liberty: 'https://tiles.openfreemap.org/styles/liberty',\n bright: 'https://tiles.openfreemap.org/styles/bright',\n} as const;\n\n/** PLAN.IGN vector styles of the Géoplateforme (France) */\nexport const PLAN_STYLES = {\n standard: 'https://data.geopf.fr/annexes/ressources/vectorTiles/styles/PLAN.IGN/standard.json',\n grey: 'https://data.geopf.fr/annexes/ressources/vectorTiles/styles/PLAN.IGN/gris.json',\n} as const;\n\n/** Vector basemaps by name (see `BasemapName`) */\nexport const VECTOR_BASEMAPS = {\n 'osm-positron': OPENFREEMAP_STYLES.positron,\n 'osm-liberty': OPENFREEMAP_STYLES.liberty,\n 'osm-bright': OPENFREEMAP_STYLES.bright,\n 'ign-plan-vector': PLAN_STYLES.standard,\n 'ign-plan-grey-vector': PLAN_STYLES.grey,\n} as const;\n\nexport interface VectorTilesOptions {\n /** A style URL or object (default OpenFreeMap's Positron) */\n style?: string | Style;\n /** Workers drawing the tiles (default cores - 1, 1 to 4). The vector tiles of a map share its workers (and their\n * decoded tiles); another count gives these tiles workers of their own */\n workers?: number;\n /** Where to load the worker from, when a bundler does not resolve the default URL (default the map's\n * `basemapWorkerUrl`); another URL than the map's gives these tiles workers of their own */\n workerUrl?: string | URL;\n /** Credits of the tiles, shown while its raster layers are on the map (default: OpenFreeMap's for its styles, the\n * IGN's for PLAN.IGN's) */\n attribution?: string;\n}\n\n/** The credits of a known style: OpenFreeMap's, PLAN.IGN's */\nexport function styleAttribution(style: string | Style): string | undefined {\n if (typeof style !== 'string') return undefined;\n if ((Object.values(OPENFREEMAP_STYLES) as string[]).includes(style)) return OPENFREEMAP_ATTRIBUTION;\n if ((Object.values(PLAN_STYLES) as string[]).includes(style)) return IGN_ATTRIBUTION;\n return undefined;\n}\n\n/** Text size of a style (a number, legacy stops, or the stops of a zoom expression made by the worker) as a size for\n * the symbol layer */\nfunction size(value: Json): Size {\n if (typeof value === 'number') return value;\n if (Array.isArray(value) && value.length > 0 && value.every(Array.isArray)) {\n return value.map((s) => [Number((s as Json[])[0]), Number((s as Json[])[1])] as [number, number]);\n }\n if (value && typeof value === 'object' && !Array.isArray(value) && Array.isArray(value.stops)) {\n return (value.stops as Json[]).map((s) => {\n const [z, v] = s as [number, number];\n return [Number(z), Number(v)] as [number, number];\n });\n }\n return 16;\n}\n\n/** Fetches a JSON document (a style, a TileJSON) */\nasync function json<T>(url: string): Promise<T> {\n const response = await fetch(url);\n if (!response.ok) throw new Error(`${url}: ${response.status}`);\n return (await response.json()) as T;\n}\n\n/** Default size of a basemap worker pool: cores - 1, 1 to 4 */\nexport function defaultWorkerCount(): number {\n return Math.min(4, Math.max(1, (typeof navigator !== 'undefined' ? navigator.hardwareConcurrency || 2 : 2) - 1));\n}\n\n/** Default URL of the basemap worker, next to the module */\nexport function defaultWorkerUrl(): URL {\n return new URL('./basemap.worker.js', import.meta.url);\n}\n\n/** Fetch priority of a raster tile drawn by the workers: 'high' near the center of the view, at the current zoom or\n * coarser; 'low' far from it or finer (prefetch); 'auto' between */\nexport function tilePriority(z: number, x: number, y: number, camera: Pick<Camera, 'center' | 'zoom'>): Priority {\n // A raster tile of level z covers the map at zoom z - 1\n if (z - 1 > camera.zoom + 1) return 'low';\n const n = 2 ** z;\n const [lon, lat] = camera.center;\n const cx = mercatorX(lon) * n;\n const cy = mercatorY(lat) * n;\n // Across the antimeridian, the short way\n let dx = Math.abs(x + 0.5 - cx) % n;\n dx = Math.min(dx, n - dx);\n const d = Math.hypot(dx, y + 0.5 - cy);\n if (d <= 1.5) return 'high';\n return d >= 4 ? 'low' : 'auto';\n}\n\n/** The worker of a vector tile among `count`: always the same one */\nexport function workerIndex(vz: number, vx: number, vy: number, count: number): number {\n // Unsigned: every worker gets its share\n return ((Math.imul(vx, 73856093) ^ Math.imul(vy, 19349663) ^ vz) >>> 0) % Math.max(1, count);\n}\n\n/** The worker-side key of a renderer: unique across the `VectorTiles` sharing a pool */\nexport function rendererKey(namespace: string, n: number): string {\n return `${namespace}:r${n}`;\n}\n\n/** What the pool needs of a worker (a `Worker`, or a stand-in in tests) */\nexport type PoolWorker = Pick<Worker, 'postMessage' | 'terminate' | 'onmessage' | 'onerror' | 'onmessageerror'>;\n\n/**\n * @internal Workers drawing vector tiles, shared by the `VectorTiles` of a map: each vector tile always goes to the\n * same worker, which keeps it decoded for every style drawn from it. Requests are tracked one by one, with their\n * owner, so that one `VectorTiles` going away cancels its own requests only.\n */\nexport class BasemapWorkers {\n private readonly workers: PoolWorker[];\n private readonly pending = new Map<\n number,\n { resolve: (r: BasemapResponse) => void; reject: (e: Error) => void; worker: PoolWorker; owner: object }\n >();\n private next = 1;\n private namespaces = 0;\n private terminated = false;\n\n constructor(\n readonly count: number,\n readonly url: string | URL,\n create: (url: string | URL) => PoolWorker = (u) => new Worker(u, { type: 'module' }),\n ) {\n this.workers = Array.from({ length: Math.max(1, count) }, () => {\n const worker = create(url);\n worker.onmessage = ({ data }: MessageEvent<BasemapResponse>) => {\n const p = this.pending.get(data.id);\n if (!p) return;\n this.pending.delete(data.id);\n if ('error' in data) p.reject(new Error(data.error));\n else p.resolve(data);\n };\n // A worker that fails to load (a bundler serving it from elsewhere) or to read a message fails its requests\n worker.onerror = (event) => {\n event.preventDefault();\n this.fail(worker, `the vector basemap worker ${url} failed${event.message ? `: ${event.message}` : ''}`);\n };\n worker.onmessageerror = () => this.fail(worker, `the vector basemap worker ${url} sent an unreadable message`);\n return worker;\n });\n }\n\n /** A prefix for the renderer keys of one `VectorTiles` */\n namespace(): string {\n return `v${this.namespaces++}`;\n }\n\n /** Requests in progress */\n get size(): number {\n return this.pending.size;\n }\n\n /** Rejects the requests of a failed worker */\n private fail(worker: PoolWorker, message: string): void {\n const error = new Error(\n `isard: ${message}. If a bundler moves the worker, give its URL in the \\`basemapWorkerUrl\\` option (see \"With a bundler\" in the guide)`,\n );\n for (const [id, p] of this.pending) {\n if (p.worker !== worker) continue;\n this.pending.delete(id);\n p.reject(error);\n }\n }\n\n /** The worker of a vector tile */\n worker(vz: number, vx: number, vy: number): PoolWorker {\n return this.workers[workerIndex(vz, vx, vy, this.workers.length)] ?? (this.workers[0] as PoolWorker);\n }\n\n /** Sends a message to every worker (a renderer, or its removal) */\n broadcast(message: Extract<BasemapRequest, { type: 'init' } | { type: 'drop' }>): void {\n if (this.terminated) return;\n // A renderer tells the workers how many they are: they share the decoded tiles' budget\n const sent = message.type === 'init' ? { ...message, workers: this.workers.length } : message;\n // A sprite image is copied to each worker (structured clone)\n for (const w of this.workers) w.postMessage(sent);\n }\n\n /** Asks a worker for a tile's image or labels, on behalf of `owner` */\n request(worker: PoolWorker, work: BasemapWork, owner: object, signal?: AbortSignal): Promise<BasemapResponse> {\n return new Promise<BasemapResponse>((resolve, reject) => {\n if (this.terminated) return reject(new DOMException('isard: vector tiles destroyed', 'AbortError'));\n if (signal?.aborted) return reject(new DOMException('aborted', 'AbortError'));\n const id = this.next++;\n const abort = () => {\n if (!this.pending.delete(id)) return;\n worker.postMessage({ type: 'abort', id } satisfies BasemapRequest);\n reject(new DOMException('aborted', 'AbortError'));\n };\n // The listener goes once the request is settled\n const settle = () => signal?.removeEventListener('abort', abort);\n this.pending.set(id, {\n resolve: (r) => {\n settle();\n resolve(r);\n },\n reject: (e) => {\n settle();\n reject(e);\n },\n worker,\n owner,\n });\n signal?.addEventListener('abort', abort, { once: true });\n worker.postMessage({ ...work, id } satisfies BasemapRequest);\n });\n }\n\n /** The altitudes of a PNG relief tile `z`/`x`/`y` at `url`, decoded by a worker (see `fetchHeights`) */\n heights(\n url: string,\n encoding: PngEncoding,\n floor: number | undefined,\n [z, x, y]: [number, number, number],\n signal: AbortSignal,\n owner: object,\n ): Promise<Float32Array | null> {\n const work: BasemapWork = { type: 'heights', url, encoding, ...(floor === undefined ? {} : { floor }) };\n return this.request(this.worker(z, x, y), work, owner, signal).then((r) => ('heights' in r ? r.heights : null));\n }\n\n /** Mercator tile `z`/`x`/`y` reprojected by a worker from the source images of its plan (see `resampler`) */\n reproject(\n job: Job,\n [z, x, y]: [number, number, number],\n signal: AbortSignal,\n owner: object,\n ): Promise<ImageBitmap | null> {\n // Blocks of 4 × 4 Mercator tiles go to the same worker: neighbours share source tiles, each worker keeps its share\n const worker = this.worker(Math.max(0, z - 2), x >> 2, y >> 2);\n const cached = Math.max(16, Math.ceil(SOURCE_CACHE / this.workers.length));\n const work: BasemapWork = { type: 'reproject', job, cached };\n return this.request(worker, work, owner, signal).then((r) => ('image' in r ? r.image : null));\n }\n\n /** Cancels the requests of an owner (the workers stop them) */\n cancel(owner: object): void {\n for (const [id, p] of this.pending) {\n if (p.owner !== owner) continue;\n this.pending.delete(id);\n p.worker.postMessage({ type: 'abort', id } satisfies BasemapRequest);\n p.reject(new DOMException('isard: vector tiles destroyed', 'AbortError'));\n }\n }\n\n /** Stops the workers; their requests fail */\n terminate(): void {\n if (this.terminated) return;\n this.terminated = true;\n for (const w of this.workers) w.terminate();\n const pending = [...this.pending.values()];\n this.pending.clear();\n for (const p of pending) p.reject(new DOMException('isard: vector tiles destroyed', 'AbortError'));\n }\n}\n\n/** The labels of a vector tile: features by style layer (its index in the style), the higher layers first */\ntype TileLabels = [layer: number, features: Feature<LabelCandidate>[]][];\n\n/** A tile's label candidates as features, by style layer */\nexport function tileLabels(candidates: readonly LabelCandidate[]): TileLabels {\n const byLayer = new Map<number, Feature<LabelCandidate>[]>();\n for (const p of candidates) {\n const feature: Feature<LabelCandidate> = {\n type: 'Feature',\n properties: p,\n geometry: p.along\n ? {\n type: 'LineString',\n coordinates: [\n [p.lon - p.along[0] / 2, p.lat - p.along[1] / 2],\n [p.lon + p.along[0] / 2, p.lat + p.along[1] / 2],\n ],\n }\n : { type: 'Point', coordinates: [p.lon, p.lat] },\n };\n const list = byLayer.get(p.layer);\n if (list) list.push(feature);\n else byLayer.set(p.layer, [feature]);\n }\n return [...byLayer].sort((a, b) => b[0] - a[0]);\n}\n\nexport class VectorTiles {\n private readonly pool: BasemapWorkers;\n /** The pool is this instance's own (a worker count or URL other than the map's): stopped with it */\n private readonly ownPool: boolean;\n /** Prefix of its renderer keys in the pool's workers */\n private readonly namespace: string;\n private destroyed = false;\n private keys = 0;\n /** Renderers sent to the workers, dropped on destroy */\n private readonly renderers: string[] = [];\n private readonly cleanup: (() => void)[] = [];\n /** Credits of its raster layers */\n private readonly attribution: string | undefined;\n /** Its raster and label layers, removed with it */\n private readonly layers: Layer[] = [];\n /** The style once loaded, with its source resolved */\n readonly ready: Promise<{ style: Style; tiles: string; maxzoom: number; rasters: Record<string, RasterSource> }>;\n\n /**\n * Its workers are the map's (shared by every `VectorTiles` of the map, a vector tile decoded once for all of them),\n * unless `workers` or `workerUrl` asks for others than the map's: then it has workers of its own\n */\n constructor(\n private readonly map: GeoMap,\n options: VectorTilesOptions = {},\n ) {\n const { pool, own } = map.basemapWorkers(options.workers, options.workerUrl);\n this.pool = pool;\n this.ownPool = own;\n this.namespace = pool.namespace();\n const style = options.style ?? OPENFREEMAP_STYLES.positron;\n this.attribution = options.attribution ?? styleAttribution(style);\n this.ready = this.load(style);\n // Reported once here; `ready`, the raster tiles and the labels fail with it\n this.ready.catch((error: unknown) => {\n if (!this.destroyed) console.warn('isard: vector tiles', error);\n });\n }\n\n private async load(input: string | Style) {\n const style = typeof input === 'string' ? await json<Style>(input) : input;\n const [name, source] = Object.entries(style.sources).find(([, s]) => s.type === 'vector') ?? [];\n if (!name || !source) throw new Error('the style has no vector source');\n let { tiles, maxzoom } = source;\n if (!tiles && source.url) {\n const tilejson = await json<{ tiles: string[]; maxzoom?: number }>(source.url);\n tiles = tilejson.tiles;\n maxzoom ??= tilejson.maxzoom;\n }\n const template = tiles?.[0];\n if (!template) throw new Error(`source ${name} has no tiles`);\n // Its raster sources of tiles, drawn into the same images (the shaded relief of a style at low zoom)\n const rasters: Record<string, RasterSource> = {};\n for (const [key, s] of Object.entries(style.sources)) {\n const url = s.type === 'raster' ? s.tiles?.[0] : undefined;\n if (url) rasters[key] = { tiles: url, maxzoom: s.maxzoom ?? 22, tileSize: s.tileSize ?? 512 };\n }\n // Only the layers of those sources (and the background); other types (hillshade, heatmap…) are left out. The\n // application's style object stays as it is\n const layers = style.layers.filter(\n (l) =>\n l.type === 'background' ||\n (l.source === name && l.type !== 'raster') ||\n (l.type === 'raster' && l.source !== undefined && rasters[l.source] !== undefined),\n );\n return { style: { ...style, layers }, tiles: template, maxzoom: maxzoom ?? 14, rasters };\n }\n\n /** The fonts of the style's labels, for its glyphs (the first of each `text-font`, as the workers take it) */\n private static fonts(style: Style): string[] {\n const fonts = new Set<string>();\n for (const layer of style.layers) {\n const font = layer.layout?.['text-font'];\n if (layer.type === 'symbol' && Array.isArray(font) && typeof font[0] === 'string') fonts.add(labelFont(font[0]));\n }\n return [...fonts];\n }\n\n /** The style's sprite (its JSON and its image), loaded once, for the renderers that draw fill patterns */\n private sprite: Promise<Sprite | undefined> | undefined;\n\n private loadSprite(url: string): Promise<Sprite | undefined> {\n this.sprite ??= (async () => {\n try {\n const [json, png] = await Promise.all([fetch(`${url}.json`), fetch(`${url}.png`)]);\n if (!json.ok || !png.ok) return undefined;\n return { icons: await json.json(), image: await createImageBitmap(await png.blob()) };\n } catch {\n return undefined;\n }\n })();\n return this.sprite;\n }\n\n private request(vz: number, vx: number, vy: number, work: BasemapWork, signal?: AbortSignal) {\n if (this.destroyed) return Promise.reject(new DOMException('isard: vector tiles destroyed', 'AbortError'));\n return this.pool.request(this.pool.worker(vz, vx, vy), work, this, signal);\n }\n\n /** Sends a renderer of these layers to every worker; returns its key */\n private async renderer(select: (layer: StyleLayer) => boolean, extra: StyleLayer[]) {\n const { style, tiles, maxzoom, rasters } = await this.ready;\n const key = rendererKey(this.namespace, this.keys++);\n const layers = [...style.layers.filter(select), ...extra];\n const patterns = layers.some((l) => l.paint?.['fill-pattern'] !== undefined);\n // The image is downloaded once, copied to each worker\n const sprite = patterns && style.sprite ? await this.loadSprite(style.sprite) : undefined;\n if (this.destroyed) throw new DOMException('isard: vector tiles destroyed', 'AbortError');\n this.pool.broadcast({ type: 'init', key, tiles, maxzoom, layers, rasters, ...(sprite ? { sprite } : {}) });\n this.renderers.push(key);\n return { key, maxzoom };\n }\n\n /**\n * A raster layer drawing the style's fills, lines and circles (or those `layers` keeps, then `extraLayers`, of the\n * same source); `size`: texture size of its tiles (512 by default: sharp lines)\n */\n raster(\n options: {\n layers?: (layer: StyleLayer) => boolean;\n extraLayers?: StyleLayer[];\n size?: number;\n opacity?: number;\n minZoom?: number;\n maxZoom?: number;\n before?: Parameters<GeoMap['addRaster']>[0]['before'];\n } = {},\n ): RasterLayer {\n const { layers = () => true, extraLayers = [], size: texture = 512, opacity = 1, before } = options;\n const drawn = (l: StyleLayer) => l.type !== 'symbol' && layers(l);\n const renderer = this.renderer(drawn, extraLayers);\n // Its failure is reported by `ready` and each tile\n renderer.catch(() => undefined);\n const loader = async (z: number, x: number, y: number, signal: AbortSignal) => {\n const { key, maxzoom } = await renderer;\n // The vector tile it is drawn from (see the worker)\n const vz = Math.max(0, Math.min(z - 1, maxzoom));\n const shift = z - vz;\n const priority = tilePriority(z, x, y, this.map.getCamera());\n const response = await this.request(\n vz,\n x >> shift,\n y >> shift,\n { type: 'render', key, z, x, y, size: texture, priority },\n signal,\n );\n return 'image' in response ? response.image : null;\n };\n const layer = this.map.addRaster({\n url: '',\n size: texture,\n opacity,\n minZoom: options.minZoom ?? 0,\n maxZoom: options.maxZoom ?? 20,\n loader,\n ...(this.attribution ? { attribution: this.attribution } : {}),\n ...(before ? { before } : {}),\n });\n this.layers.push(layer);\n return layer;\n }\n\n /**\n * A symbol layer with the labels of the style's symbol layers (or those `layers` keeps), updated as the view\n * moves: the labels of the vector tiles in view, the higher style layers placed first. It stays above the layers\n * added after it unless one is moved over it.\n */\n labels(options: { layers?: (layer: StyleLayer) => boolean; maxTiles?: number } = {}): SymbolLayer<LabelCandidate> {\n const { layers = () => true, maxTiles = 36 } = options;\n const symbol = this.map.addSymbols<LabelCandidate>({\n data: [],\n text: (p) => p.text,\n font: (p) => p.font,\n size: (p) => size(p.size),\n color: (p) => p.color,\n haloColor: (p) => p.haloColor,\n haloWidth: (p) => p.haloWidth,\n anchor: (p) => p.anchor as Anchor,\n offset: (p) => p.offset,\n maxWidth: (p) => p.maxWidth,\n lineHeight: (p) => p.lineHeight,\n overlap: (p) => p.overlap,\n placement: 'line',\n });\n this.map.keepOnTop(symbol);\n this.layers.push(symbol);\n const renderer = this.ready.then(({ style }) => {\n // The style's fonts from its own glyphs\n if (style.glyphs) this.map.glyphs.register(style.glyphs, VectorTiles.fonts(style));\n return this.renderer((l) => l.type === 'symbol' && layers(l), []);\n });\n renderer.catch(() => undefined);\n /** The labels of the tiles, as features by style layer, the higher layers first: each list is given to the symbol\n * layer as a group, shaped once while the tile is kept */\n const tiles = new Lru<string, Promise<TileLabels>>(256);\n let generation = 0;\n /** The tiles whose labels are shown */\n let shown = '';\n const update = async () => {\n if (this.destroyed) return;\n const { key, maxzoom } = await renderer;\n const run = ++generation;\n const camera = this.map.getCamera();\n const z = Math.max(0, Math.min(Math.floor(camera.zoom), maxzoom));\n const n = 2 ** z;\n const [west, south, east, north] = this.map.getBounds();\n const tx = (lon: number) => Math.floor(mercatorX(lon) * n);\n const ty = (lat: number) => Math.floor(mercatorY(lat) * n);\n const [cx, cy] = [mercatorX(camera.center[0]) * n, ty(camera.center[1])];\n // The tiles of the bounds, within a window around the center: a tilted view's bounds reach far, and only the\n // nearest `maxTiles` are kept anyway\n const reach = Math.ceil(Math.sqrt(maxTiles)) + 2;\n const [x0, x1] = [\n Math.max(0, tx(west), Math.floor(cx) - reach),\n Math.min(n - 1, tx(east), Math.floor(cx) + reach),\n ];\n const [y0, y1] = [\n Math.max(0, ty(north), Math.floor(cy) - reach),\n Math.min(n - 1, ty(south), Math.floor(cy) + reach),\n ];\n const wanted: [number, number][] = [];\n for (let y = y0; y <= y1; y += 1) for (let x = x0; x <= x1; x += 1) wanted.push([x, y]);\n // Nearest to the center first, at most `maxTiles` (tilted views reach far)\n wanted.sort(\n (a, b) => Math.hypot(a[0] + 0.5 - cx, a[1] + 0.5 - cy) - Math.hypot(b[0] + 0.5 - cx, b[1] + 0.5 - cy),\n );\n const keys = wanted.slice(0, maxTiles).map(([x, y]) => `${z}/${x}/${y}`);\n // The same tiles as the labels shown: nothing to do\n const set = keys.join(' ');\n if (set === shown) return;\n const lists = await Promise.all(\n keys.map((k, index) => {\n let p = tiles.get(k);\n if (p) return p;\n const [tz, x, y] = k.split('/').map(Number) as [number, number, number];\n // The nearest tiles first: the others wait for the raster tiles\n const priority: Priority = index < 4 ? 'auto' : 'low';\n p = this.request(tz, x, y, { type: 'labels', key, z: tz, x, y, priority }).then(\n (r) => tileLabels('labels' in r ? r.labels : []),\n () => {\n // A network error is not kept: the tile is asked for again on the next update\n tiles.delete(k);\n return [];\n },\n );\n // A bounded cache of tiles' labels, the least recently used dropped\n tiles.set(k, p);\n return p;\n }),\n );\n if (run !== generation || this.destroyed) return;\n // A tile that failed is missing: the next update asks for it again\n shown = keys.every((k) => tiles.has(k)) ? set : '';\n // The labels of the higher style layers first: they win the collisions; for each style layer, the tiles nearest\n // to the center first\n const layerIds = [...new Set(lists.flatMap((list) => list.map(([layer]) => layer)))].sort((a, b) => b - a);\n const groups: Feature<LabelCandidate>[][] = [];\n for (const layer of layerIds) {\n for (const list of lists) {\n const group = list.find(([l]) => l === layer)?.[1];\n if (group) groups.push(group);\n }\n }\n symbol.setGroups(groups);\n };\n // The style failed to load: reported by `ready`\n const refresh = () => {\n update().catch(() => undefined);\n };\n let timer = 0;\n const schedule = () => {\n if (timer) return;\n timer = window.setTimeout(() => {\n timer = 0;\n refresh();\n }, 250);\n };\n this.cleanup.push(this.map.on('move', schedule), this.map.on('moveend', refresh), () => clearTimeout(timer));\n refresh();\n return symbol;\n }\n\n /** Stops its workers' work and removes its raster and label layers from the map (those still there) */\n destroy(): void {\n if (this.destroyed) return;\n this.destroyed = true;\n for (const off of this.cleanup) off();\n this.cleanup.length = 0;\n for (const layer of this.layers) if (this.map.hasLayer(layer)) layer.remove();\n this.layers.length = 0;\n this.map.dropVectorTiles(this);\n // The page's copy of the sprite (the workers have theirs)\n this.sprite?.then((sprite) => sprite?.image.close()).catch(() => undefined);\n if (this.ownPool) {\n this.pool.terminate();\n } else {\n // Shared workers: only its requests stop and its renderers go\n this.pool.cancel(this);\n for (const key of this.renderers) this.pool.broadcast({ type: 'drop', key });\n }\n this.renderers.length = 0;\n }\n}\n"]}
|
package/dist/wasm/isard.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* A primitive of a tile decoded by `decodeTile`: vertices x, y, z, u, v around the anchor; the image still encoded,
|
|
6
|
+
* the same array for the primitives sharing it
|
|
7
|
+
*/
|
|
5
8
|
export interface EncodedPrimitive {
|
|
6
9
|
vertices: Float32Array<ArrayBuffer>;
|
|
7
10
|
indices: Uint32Array<ArrayBuffer>;
|
|
@@ -23,7 +26,10 @@ export interface CompressedTexture {
|
|
|
23
26
|
levels: { width: number; height: number; data: Uint8Array<ArrayBuffer> }[];
|
|
24
27
|
}
|
|
25
28
|
|
|
26
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* A primitive ready for the GPU: its image decoded (bitmap) or transcoded (texture); primitives given the same bitmap
|
|
31
|
+
* or texture object share one GPU texture
|
|
32
|
+
*/
|
|
27
33
|
export interface DecodedPrimitive {
|
|
28
34
|
vertices: Float32Array<ArrayBuffer>;
|
|
29
35
|
indices: Uint32Array<ArrayBuffer>;
|
|
@@ -298,7 +304,7 @@ export class Engine {
|
|
|
298
304
|
* atmosphere around the globe (RGB 0-1 and its strength, 4 numbers; `undefined` for an airless body), and the
|
|
299
305
|
* lowest and highest altitudes of its ground (metres: what its relief may raise into view). WGS 84, the Earth's
|
|
300
306
|
* blue halo and the range of its relief worldwide (-450 m to 8900 m) by default; set before the layers and the
|
|
301
|
-
* relief, whose shaders may take its size (`
|
|
307
|
+
* relief, whose shaders may take its size (`ISARD_CIRCUMFERENCE` of the ground layers)
|
|
302
308
|
*/
|
|
303
309
|
setBody(radius: number, flattening: number, halo: Float32Array | null | undefined, lowest: number, highest: number): void;
|
|
304
310
|
setCamera(lon: number, lat: number, zoom: number, pitch: number, bearing: number): void;
|
package/dist/wasm/isard.js
CHANGED
|
@@ -401,7 +401,7 @@ export class Engine {
|
|
|
401
401
|
* atmosphere around the globe (RGB 0-1 and its strength, 4 numbers; `undefined` for an airless body), and the
|
|
402
402
|
* lowest and highest altitudes of its ground (metres: what its relief may raise into view). WGS 84, the Earth's
|
|
403
403
|
* blue halo and the range of its relief worldwide (-450 m to 8900 m) by default; set before the layers and the
|
|
404
|
-
* relief, whose shaders may take its size (`
|
|
404
|
+
* relief, whose shaders may take its size (`ISARD_CIRCUMFERENCE` of the ground layers)
|
|
405
405
|
* @param {number} radius
|
|
406
406
|
* @param {number} flattening
|
|
407
407
|
* @param {Float32Array | null | undefined} halo
|
|
@@ -1885,6 +1885,12 @@ function __wbg_get_imports() {
|
|
|
1885
1885
|
__wbg_stencilFunc_bab7e0b7c443f093: function(arg0, arg1, arg2, arg3) {
|
|
1886
1886
|
arg0.stencilFunc(arg1 >>> 0, arg2, arg3 >>> 0);
|
|
1887
1887
|
},
|
|
1888
|
+
__wbg_stencilMask_9e18cc018897c747: function(arg0, arg1) {
|
|
1889
|
+
arg0.stencilMask(arg1 >>> 0);
|
|
1890
|
+
},
|
|
1891
|
+
__wbg_stencilMask_a22be64c66abd825: function(arg0, arg1) {
|
|
1892
|
+
arg0.stencilMask(arg1 >>> 0);
|
|
1893
|
+
},
|
|
1888
1894
|
__wbg_stencilOpSeparate_7d01185cbdb89d99: function(arg0, arg1, arg2, arg3, arg4) {
|
|
1889
1895
|
arg0.stencilOpSeparate(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, arg4 >>> 0);
|
|
1890
1896
|
},
|
|
@@ -2094,7 +2100,7 @@ function __wbg_get_imports() {
|
|
|
2094
2100
|
return ret;
|
|
2095
2101
|
},
|
|
2096
2102
|
__wbindgen_generic_0000000000000001: function(arg0, arg1) {
|
|
2097
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx:
|
|
2103
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 149, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
2098
2104
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_2e566c63402fe7fa___convert__closures_____invoke___wasm_bindgen_2e566c63402fe7fa___JsValue__core_37ee0ce0c4cd57d5___result__Result_____wasm_bindgen_2e566c63402fe7fa___JsError___true_);
|
|
2099
2105
|
return ret;
|
|
2100
2106
|
},
|
|
@@ -193,7 +193,7 @@ export class Engine {
|
|
|
193
193
|
* atmosphere around the globe (RGB 0-1 and its strength, 4 numbers; `undefined` for an airless body), and the
|
|
194
194
|
* lowest and highest altitudes of its ground (metres: what its relief may raise into view). WGS 84, the Earth's
|
|
195
195
|
* blue halo and the range of its relief worldwide (-450 m to 8900 m) by default; set before the layers and the
|
|
196
|
-
* relief, whose shaders may take its size (`
|
|
196
|
+
* relief, whose shaders may take its size (`ISARD_CIRCUMFERENCE` of the ground layers)
|
|
197
197
|
*/
|
|
198
198
|
setBody(radius: number, flattening: number, halo: Float32Array | null | undefined, lowest: number, highest: number): void;
|
|
199
199
|
setCamera(lon: number, lat: number, zoom: number, pitch: number, bearing: number): void;
|
package/dist/wasm/isard_core.js
CHANGED
|
@@ -385,7 +385,7 @@ export class Engine {
|
|
|
385
385
|
* atmosphere around the globe (RGB 0-1 and its strength, 4 numbers; `undefined` for an airless body), and the
|
|
386
386
|
* lowest and highest altitudes of its ground (metres: what its relief may raise into view). WGS 84, the Earth's
|
|
387
387
|
* blue halo and the range of its relief worldwide (-450 m to 8900 m) by default; set before the layers and the
|
|
388
|
-
* relief, whose shaders may take its size (`
|
|
388
|
+
* relief, whose shaders may take its size (`ISARD_CIRCUMFERENCE` of the ground layers)
|
|
389
389
|
* @param {number} radius
|
|
390
390
|
* @param {number} flattening
|
|
391
391
|
* @param {Float32Array | null | undefined} halo
|
|
@@ -1653,6 +1653,12 @@ function __wbg_get_imports() {
|
|
|
1653
1653
|
__wbg_stencilFunc_bab7e0b7c443f093: function(arg0, arg1, arg2, arg3) {
|
|
1654
1654
|
arg0.stencilFunc(arg1 >>> 0, arg2, arg3 >>> 0);
|
|
1655
1655
|
},
|
|
1656
|
+
__wbg_stencilMask_9e18cc018897c747: function(arg0, arg1) {
|
|
1657
|
+
arg0.stencilMask(arg1 >>> 0);
|
|
1658
|
+
},
|
|
1659
|
+
__wbg_stencilMask_a22be64c66abd825: function(arg0, arg1) {
|
|
1660
|
+
arg0.stencilMask(arg1 >>> 0);
|
|
1661
|
+
},
|
|
1656
1662
|
__wbg_stencilOpSeparate_7d01185cbdb89d99: function(arg0, arg1, arg2, arg3, arg4) {
|
|
1657
1663
|
arg0.stencilOpSeparate(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, arg4 >>> 0);
|
|
1658
1664
|
},
|
|
@@ -1856,7 +1862,7 @@ function __wbg_get_imports() {
|
|
|
1856
1862
|
return ret;
|
|
1857
1863
|
},
|
|
1858
1864
|
__wbindgen_generic_0000000000000001: function(arg0, arg1) {
|
|
1859
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx:
|
|
1865
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 78, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
1860
1866
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_2e566c63402fe7fa___convert__closures_____invoke___wasm_bindgen_2e566c63402fe7fa___JsValue__core_37ee0ce0c4cd57d5___result__Result_____wasm_bindgen_2e566c63402fe7fa___JsError___true_);
|
|
1861
1867
|
return ret;
|
|
1862
1868
|
},
|
package/dist/wmts.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { TileGrid } from './grid.ts';
|
|
2
|
+
/**
|
|
3
|
+
* The tile grid of `layer` in the capabilities document `xml`: its tile matrix set `matrixSet` (default the layer's
|
|
4
|
+
* first), with the layer's tile limits and longitude-latitude extent. Throws if the layer or the set is missing
|
|
5
|
+
*/
|
|
6
|
+
export declare function parseWmtsGrid(xml: string, layer: string, matrixSet?: string): TileGrid;
|
|
7
|
+
/**
|
|
8
|
+
* The tile grid of a WMTS layer, from the service's capabilities at `capabilities` (fetched with CORS), for
|
|
9
|
+
* `addRaster`: `await wmtsGrid('https://…/wmts?SERVICE=WMTS&REQUEST=GetCapabilities', 'LAYER', 'MATRIXSET')`. The
|
|
10
|
+
* raster's URL writes the matrix set, {z} for the matrix, {x} and {y} for the column and the row
|
|
11
|
+
*/
|
|
12
|
+
export declare function wmtsGrid(capabilities: string | URL, layer: string, matrixSet?: string, options?: {
|
|
13
|
+
signal?: AbortSignal;
|
|
14
|
+
}): Promise<TileGrid>;
|
package/dist/wmts.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The tile grid of a WMTS layer, read from the service's capabilities: its tile matrix set (CRS, levels, origin, tile
|
|
3
|
+
* sizes), the layer's limits in it and its extent, for `addRaster({ url, grid })`.
|
|
4
|
+
*/
|
|
5
|
+
import { epsgCode, isGeographic } from "./crs.js";
|
|
6
|
+
import { child, children, childText, parseXml } from "./xml.js";
|
|
7
|
+
/** Metres per degree, as WMTS counts the scale of a grid in degrees (OGC 07-057r7, 6.1) */
|
|
8
|
+
const METRES_PER_DEGREE = (2 * Math.PI * 6378137) / 360;
|
|
9
|
+
/** The size of a pixel by which WMTS turns scale denominators into resolutions, metres */
|
|
10
|
+
const PIXEL = 0.00028;
|
|
11
|
+
const numbers = (text) => (text ?? '').trim().split(/\s+/).map(Number);
|
|
12
|
+
/**
|
|
13
|
+
* The tile grid of `layer` in the capabilities document `xml`: its tile matrix set `matrixSet` (default the layer's
|
|
14
|
+
* first), with the layer's tile limits and longitude-latitude extent. Throws if the layer or the set is missing
|
|
15
|
+
*/
|
|
16
|
+
export function parseWmtsGrid(xml, layer, matrixSet) {
|
|
17
|
+
const contents = child(parseXml(xml), 'Contents');
|
|
18
|
+
const entry = children(contents, 'Layer').find((l) => childText(l, 'Identifier') === layer);
|
|
19
|
+
if (!entry)
|
|
20
|
+
throw new Error(`isard: no WMTS layer ${layer}`);
|
|
21
|
+
const links = children(entry, 'TileMatrixSetLink');
|
|
22
|
+
const link = matrixSet === undefined ? links[0] : links.find((l) => childText(l, 'TileMatrixSet') === matrixSet);
|
|
23
|
+
const name = childText(link, 'TileMatrixSet');
|
|
24
|
+
const set = children(contents, 'TileMatrixSet').find((s) => childText(s, 'Identifier') === name);
|
|
25
|
+
if (!name || !set)
|
|
26
|
+
throw new Error(`isard: no tile matrix set ${matrixSet ?? ''} for the WMTS layer ${layer}`);
|
|
27
|
+
const crs = childText(set, 'SupportedCRS') ?? '';
|
|
28
|
+
const geographic = isGeographic(crs);
|
|
29
|
+
// EPSG's geographic CRSs have their latitude first (CRS:84 and the IGN's WGS84G do not)
|
|
30
|
+
const latFirst = geographic && epsgCode(crs) === 4326 && /EPSG/i.test(crs);
|
|
31
|
+
const unit = geographic ? METRES_PER_DEGREE : 1;
|
|
32
|
+
const limits = new Map();
|
|
33
|
+
for (const l of children(child(link, 'TileMatrixSetLimits'), 'TileMatrixLimits')) {
|
|
34
|
+
const [minRow, maxRow, minCol, maxCol] = ['MinTileRow', 'MaxTileRow', 'MinTileCol', 'MaxTileCol'].map((k) => Number(childText(l, k)));
|
|
35
|
+
limits.set(childText(l, 'TileMatrix') ?? '', [minCol, minRow, maxCol, maxRow]);
|
|
36
|
+
}
|
|
37
|
+
const matrices = children(set, 'TileMatrix').map((m) => {
|
|
38
|
+
const id = childText(m, 'Identifier') ?? '';
|
|
39
|
+
const [a = 0, b = 0] = numbers(childText(m, 'TopLeftCorner'));
|
|
40
|
+
const limit = limits.get(id);
|
|
41
|
+
return {
|
|
42
|
+
id,
|
|
43
|
+
resolution: (Number(childText(m, 'ScaleDenominator')) * PIXEL) / unit,
|
|
44
|
+
origin: latFirst ? [b, a] : [a, b],
|
|
45
|
+
tileWidth: Number(childText(m, 'TileWidth') ?? 256),
|
|
46
|
+
tileHeight: Number(childText(m, 'TileHeight') ?? 256),
|
|
47
|
+
matrixWidth: Number(childText(m, 'MatrixWidth') ?? Infinity),
|
|
48
|
+
matrixHeight: Number(childText(m, 'MatrixHeight') ?? Infinity),
|
|
49
|
+
...(limit ? { limits: limit } : {}),
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
// A layer's limits leave out the matrices it does not have
|
|
53
|
+
const served = limits.size > 0 ? matrices.filter((m) => limits.has(String(m.id))) : matrices;
|
|
54
|
+
const box = child(entry, 'WGS84BoundingBox');
|
|
55
|
+
const [west, south] = numbers(childText(box, 'LowerCorner'));
|
|
56
|
+
const [east, north] = numbers(childText(box, 'UpperCorner'));
|
|
57
|
+
const bounds = [west, south, east, north];
|
|
58
|
+
return {
|
|
59
|
+
crs,
|
|
60
|
+
matrices: served,
|
|
61
|
+
name,
|
|
62
|
+
...(bounds.every(Number.isFinite) ? { bounds: bounds } : {}),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* The tile grid of a WMTS layer, from the service's capabilities at `capabilities` (fetched with CORS), for
|
|
67
|
+
* `addRaster`: `await wmtsGrid('https://…/wmts?SERVICE=WMTS&REQUEST=GetCapabilities', 'LAYER', 'MATRIXSET')`. The
|
|
68
|
+
* raster's URL writes the matrix set, {z} for the matrix, {x} and {y} for the column and the row
|
|
69
|
+
*/
|
|
70
|
+
export async function wmtsGrid(capabilities, layer, matrixSet, options = {}) {
|
|
71
|
+
const response = await fetch(capabilities, options.signal ? { signal: options.signal } : {});
|
|
72
|
+
if (!response.ok)
|
|
73
|
+
throw new Error(`isard: ${response.status} for the WMTS capabilities`);
|
|
74
|
+
return parseWmtsGrid(await response.text(), layer, matrixSet);
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=wmts.js.map
|