isard 0.2.1 → 0.4.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 +93 -0
- package/README.md +8 -4
- 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 +26 -4
- package/dist/basemap.worker.js +2 -2
- package/dist/basemap.worker.js.map +9 -5
- 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 +28 -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 +13 -3
- package/dist/glyphs.js +26 -4
- 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/icons.d.ts +146 -0
- package/dist/icons.js +333 -0
- package/dist/icons.js.map +1 -0
- package/dist/index.d.ts +11 -4
- package/dist/index.js +6 -1
- 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 +89 -2
- package/dist/layers.js +171 -15
- 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 +45 -7
- package/dist/map.js +138 -310
- 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 +54 -9
- package/dist/symbols.js +278 -55
- 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 +14 -6
- package/dist/types.js.map +1 -1
- package/dist/vectorstyle.d.ts +32 -3
- package/dist/vectorstyle.js.map +1 -1
- package/dist/vectortiles.d.ts +19 -7
- package/dist/vectortiles.js +117 -69
- package/dist/vectortiles.js.map +1 -1
- package/dist/wasm/isard.d.ts +55 -7
- package/dist/wasm/isard.js +117 -6
- package/dist/wasm/isard_core.d.ts +29 -4
- package/dist/wasm/isard_core.js +84 -5
- 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/terrain.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Altitudes encoded in the colors of PNG tiles, for the relief: Terrarium (Mapzen, the Terrain Tiles of AWS) and
|
|
3
|
+
* Terrain-RGB (Mapbox, MapTiler). The engine reads raw floats only; a loader gives it the altitudes of each tile,
|
|
4
|
+
* decoded in a worker of the map's pool (OffscreenCanvas), or in the page when the map has no workers.
|
|
5
|
+
*/
|
|
1
6
|
const SIZE = 256;
|
|
2
7
|
/** Altitudes (metres, rows from the north) of RGBA pixels in an encoding; below `floor` raised to it */
|
|
3
8
|
export function decodeHeights(rgba, encoding, floor = Number.NEGATIVE_INFINITY) {
|
|
@@ -18,39 +23,46 @@ export function decodeHeights(rgba, encoding, floor = Number.NEGATIVE_INFINITY)
|
|
|
18
23
|
}
|
|
19
24
|
return out;
|
|
20
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* The altitudes of the PNG tile at `url`: 256 × 256, null where the server has no tile; a network or server error
|
|
28
|
+
* rejects (the engine retries). Where it runs: in a worker of the map, or in the page without workers
|
|
29
|
+
*/
|
|
30
|
+
export async function fetchHeights(url, encoding, floor, signal, surface) {
|
|
31
|
+
const response = await fetch(url, { signal });
|
|
32
|
+
if (response.status === 404 || response.status === 204 || response.status === 410)
|
|
33
|
+
return null;
|
|
34
|
+
if (!response.ok)
|
|
35
|
+
throw new Error(`${response.url}: ${response.status}`);
|
|
36
|
+
// The colors as stored: no color management, no premultiplied alpha
|
|
37
|
+
const bitmap = await createImageBitmap(await response.blob(), {
|
|
38
|
+
premultiplyAlpha: 'none',
|
|
39
|
+
colorSpaceConversion: 'none',
|
|
40
|
+
});
|
|
41
|
+
try {
|
|
42
|
+
surface.canvas ??= new OffscreenCanvas(SIZE, SIZE);
|
|
43
|
+
const g = surface.canvas.getContext('2d', { willReadFrequently: true });
|
|
44
|
+
if (!g)
|
|
45
|
+
throw new Error('no 2D context');
|
|
46
|
+
// Another size is resampled to the nearest pixel: an interpolated color is no altitude
|
|
47
|
+
g.imageSmoothingEnabled = false;
|
|
48
|
+
g.clearRect(0, 0, SIZE, SIZE);
|
|
49
|
+
g.drawImage(bitmap, 0, 0, SIZE, SIZE);
|
|
50
|
+
return decodeHeights(g.getImageData(0, 0, SIZE, SIZE).data, encoding, floor);
|
|
51
|
+
}
|
|
52
|
+
finally {
|
|
53
|
+
bitmap.close();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
21
56
|
/**
|
|
22
57
|
* A loader of the engine's relief for PNG tiles of `url` ({z}, {x}, {y}) in an encoding: 256 × 256 altitudes, null
|
|
23
58
|
* where the server has no tile; a network or server error rejects (retried). `floor`: the lowest altitude kept (the
|
|
24
|
-
* sea floor of a worldwide model flattened at sea level)
|
|
59
|
+
* sea floor of a worldwide model flattened at sea level). `remote`: decodes in a worker when it can
|
|
25
60
|
*/
|
|
26
|
-
export function encodedTerrainLoader(url, encoding, floor) {
|
|
27
|
-
|
|
28
|
-
return
|
|
61
|
+
export function encodedTerrainLoader(url, encoding, floor, remote) {
|
|
62
|
+
const surface = {};
|
|
63
|
+
return (z, x, y, signal) => {
|
|
29
64
|
const tile = url.replaceAll('{z}', String(z)).replaceAll('{x}', String(x)).replaceAll('{y}', String(y));
|
|
30
|
-
|
|
31
|
-
if (response.status === 404 || response.status === 204 || response.status === 410)
|
|
32
|
-
return null;
|
|
33
|
-
if (!response.ok)
|
|
34
|
-
throw new Error(`${response.url}: ${response.status}`);
|
|
35
|
-
// The colors as stored: no color management, no premultiplied alpha
|
|
36
|
-
const bitmap = await createImageBitmap(await response.blob(), {
|
|
37
|
-
premultiplyAlpha: 'none',
|
|
38
|
-
colorSpaceConversion: 'none',
|
|
39
|
-
});
|
|
40
|
-
try {
|
|
41
|
-
canvas ??= new OffscreenCanvas(SIZE, SIZE);
|
|
42
|
-
const g = canvas.getContext('2d', { willReadFrequently: true });
|
|
43
|
-
if (!g)
|
|
44
|
-
throw new Error('no 2D context');
|
|
45
|
-
// Another size is resampled to the nearest pixel: an interpolated color is no altitude
|
|
46
|
-
g.imageSmoothingEnabled = false;
|
|
47
|
-
g.clearRect(0, 0, SIZE, SIZE);
|
|
48
|
-
g.drawImage(bitmap, 0, 0, SIZE, SIZE);
|
|
49
|
-
return decodeHeights(g.getImageData(0, 0, SIZE, SIZE).data, encoding, floor);
|
|
50
|
-
}
|
|
51
|
-
finally {
|
|
52
|
-
bitmap.close();
|
|
53
|
-
}
|
|
65
|
+
return remote?.(tile, encoding, floor, [z, x, y], signal) ?? fetchHeights(tile, encoding, floor, signal, surface);
|
|
54
66
|
};
|
|
55
67
|
}
|
|
56
68
|
//# sourceMappingURL=terrain.js.map
|
package/dist/terrain.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"terrain.js","sourceRoot":"","sources":["../src/terrain.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"terrain.js","sourceRoot":"","sources":["../src/terrain.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,MAAM,IAAI,GAAG,GAAG,CAAC;AAEjB,wGAAwG;AACxG,MAAM,UAAU,aAAa,CAC3B,IAAoC,EACpC,QAAqB,EACrB,KAAK,GAAG,MAAM,CAAC,iBAAiB;IAEhC,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC;IAC3B,MAAM,GAAG,GAAG,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC;IAChC,iEAAiE;IACjE,IAAI,QAAQ,KAAK,WAAW,EAAE,CAAC;QAC7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;YAC7C,MAAM,CAAC,GAAI,IAAI,CAAC,CAAC,CAAY,GAAG,GAAG,GAAI,IAAI,CAAC,CAAC,GAAG,CAAC,CAAY,GAAI,IAAI,CAAC,CAAC,GAAG,CAAC,CAAY,GAAG,GAAG,GAAG,KAAK,CAAC;YACtG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;QACjC,CAAC;IACH,CAAC;SAAM,CAAC;QACN,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAA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CAAC;AACJ,CAAC","sourcesContent":["/**\n * Altitudes encoded in the colors of PNG tiles, for the relief: Terrarium (Mapzen, the Terrain Tiles of AWS) and\n * Terrain-RGB (Mapbox, MapTiler). The engine reads raw floats only; a loader gives it the altitudes of each tile,\n * decoded in a worker of the map's pool (OffscreenCanvas), or in the page when the map has no workers.\n */\n\n/** The encodings of altitudes in the colors of PNG tiles */\nexport type PngEncoding = 'terrarium' | 'mapbox';\n\nconst SIZE = 256;\n\n/** Altitudes (metres, rows from the north) of RGBA pixels in an encoding; below `floor` raised to it */\nexport function decodeHeights(\n rgba: Uint8ClampedArray | Uint8Array,\n encoding: PngEncoding,\n floor = Number.NEGATIVE_INFINITY,\n): Float32Array {\n const n = rgba.length >> 2;\n const out = new Float32Array(n);\n // A loop per encoding, without allocations: 65 536 pixels a tile\n if (encoding === 'terrarium') {\n for (let i = 0, j = 0; i < n; i += 1, j += 4) {\n const h = (rgba[j] as number) * 256 + (rgba[j + 1] as number) + (rgba[j + 2] as number) / 256 - 32768;\n out[i] = h > floor ? h : floor;\n }\n } else {\n for (let i = 0, j = 0; i < n; i += 1, j += 4) {\n const h = -10000 + ((rgba[j] as number) * 65536 + (rgba[j + 1] as number) * 256 + (rgba[j + 2] as number)) * 0.1;\n out[i] = h > floor ? h : floor;\n }\n }\n return out;\n}\n\n/** Where the tiles are drawn and read back, made on first use and kept (each tile drawn and read at once) */\nexport interface Surface {\n canvas?: OffscreenCanvas;\n}\n\n/**\n * The altitudes of the PNG tile at `url`: 256 × 256, null where the server has no tile; a network or server error\n * rejects (the engine retries). Where it runs: in a worker of the map, or in the page without workers\n */\nexport async function fetchHeights(\n url: string,\n encoding: PngEncoding,\n floor: number | undefined,\n signal: AbortSignal,\n surface: Surface,\n): Promise<Float32Array | null> {\n const response = await fetch(url, { signal });\n if (response.status === 404 || response.status === 204 || response.status === 410) return null;\n if (!response.ok) throw new Error(`${response.url}: ${response.status}`);\n // The colors as stored: no color management, no premultiplied alpha\n const bitmap = await createImageBitmap(await response.blob(), {\n premultiplyAlpha: 'none',\n colorSpaceConversion: 'none',\n });\n try {\n surface.canvas ??= new OffscreenCanvas(SIZE, SIZE);\n const g = surface.canvas.getContext('2d', { willReadFrequently: true });\n if (!g) throw new Error('no 2D context');\n // Another size is resampled to the nearest pixel: an interpolated color is no altitude\n g.imageSmoothingEnabled = false;\n g.clearRect(0, 0, SIZE, SIZE);\n g.drawImage(bitmap, 0, 0, SIZE, SIZE);\n return decodeHeights(g.getImageData(0, 0, SIZE, SIZE).data, encoding, floor);\n } finally {\n bitmap.close();\n }\n}\n\n/** `fetchHeights` run in a worker for tile `z`/`x`/`y`; undefined when the map has no workers (run in the page) */\nexport type RemoteHeights = (\n url: string,\n encoding: PngEncoding,\n floor: number | undefined,\n tile: [z: number, x: number, y: number],\n signal: AbortSignal,\n) => Promise<Float32Array | null> | undefined;\n\n/**\n * A loader of the engine's relief for PNG tiles of `url` ({z}, {x}, {y}) in an encoding: 256 × 256 altitudes, null\n * where the server has no tile; a network or server error rejects (retried). `floor`: the lowest altitude kept (the\n * sea floor of a worldwide model flattened at sea level). `remote`: decodes in a worker when it can\n */\nexport function encodedTerrainLoader(\n url: string,\n encoding: PngEncoding,\n floor?: number,\n remote?: RemoteHeights,\n): (z: number, x: number, y: number, signal: AbortSignal) => Promise<Float32Array | null> {\n const surface: Surface = {};\n return (z, x, y, signal) => {\n const tile = url.replaceAll('{z}', String(z)).replaceAll('{x}', String(x)).replaceAll('{y}', String(y));\n return remote?.(tile, encoding, floor, [z, x, y], signal) ?? fetchHeights(tile, encoding, floor, signal, surface);\n };\n}\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TopoJSON to GeoJSON, for the feature layers: `map.addFills({ data: parseTopoJson(topology, 'counties') })`.
|
|
3
|
+
*/
|
|
4
|
+
import type { FeatureCollection, Properties } from './features.ts';
|
|
5
|
+
/** A TopoJSON geometry object (arcs by index, `~i` for arc i reversed; positions quantized with a transform) */
|
|
6
|
+
export interface TopoGeometry {
|
|
7
|
+
type: 'Point' | 'MultiPoint' | 'LineString' | 'MultiLineString' | 'Polygon' | 'MultiPolygon' | 'GeometryCollection' | null;
|
|
8
|
+
id?: string | number;
|
|
9
|
+
properties?: Properties;
|
|
10
|
+
coordinates?: number[] | number[][];
|
|
11
|
+
arcs?: number[] | number[][] | number[][][];
|
|
12
|
+
geometries?: TopoGeometry[];
|
|
13
|
+
}
|
|
14
|
+
/** A TopoJSON topology */
|
|
15
|
+
export interface Topology {
|
|
16
|
+
type: 'Topology';
|
|
17
|
+
/** Quantized positions: x × scale + translate (arcs delta-encoded) */
|
|
18
|
+
transform?: {
|
|
19
|
+
scale: [number, number];
|
|
20
|
+
translate: [number, number];
|
|
21
|
+
};
|
|
22
|
+
arcs: number[][][];
|
|
23
|
+
objects: Record<string, TopoGeometry>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The features of object `name` of a TopoJSON topology (default its first object): a GeometryCollection gives one
|
|
27
|
+
* feature per geometry, another geometry one feature; arcs are stitched and dequantized, ids and properties kept
|
|
28
|
+
*/
|
|
29
|
+
export declare function parseTopoJson<P = Properties>(topology: Topology, name?: string): FeatureCollection<P>;
|
package/dist/topojson.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The features of object `name` of a TopoJSON topology (default its first object): a GeometryCollection gives one
|
|
3
|
+
* feature per geometry, another geometry one feature; arcs are stitched and dequantized, ids and properties kept
|
|
4
|
+
*/
|
|
5
|
+
export function parseTopoJson(topology, name) {
|
|
6
|
+
const object = name === undefined ? Object.values(topology.objects)[0] : topology.objects[name];
|
|
7
|
+
if (!object)
|
|
8
|
+
throw new Error(`isard: no TopoJSON object ${name ?? ''}`);
|
|
9
|
+
const { scale = [1, 1], translate = [0, 0] } = topology.transform ?? {};
|
|
10
|
+
const quantized = topology.transform !== undefined;
|
|
11
|
+
const at = (p) => [p[0] ?? 0, p[1] ?? 0, ...p.slice(2)];
|
|
12
|
+
// The arcs decoded once
|
|
13
|
+
const arcs = topology.arcs.map((arc) => {
|
|
14
|
+
let [x, y] = [0, 0];
|
|
15
|
+
return arc.map((p) => {
|
|
16
|
+
if (!quantized)
|
|
17
|
+
return at(p);
|
|
18
|
+
x += p[0] ?? 0;
|
|
19
|
+
y += p[1] ?? 0;
|
|
20
|
+
return [x * scale[0] + translate[0], y * scale[1] + translate[1], ...p.slice(2)];
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
const position = (p) => quantized ? [(p[0] ?? 0) * scale[0] + translate[0], (p[1] ?? 0) * scale[1] + translate[1], ...p.slice(2)] : at(p);
|
|
24
|
+
/** A line from arcs, each after the first without its first point (the last of the one before) */
|
|
25
|
+
const stitch = (indices) => {
|
|
26
|
+
const out = [];
|
|
27
|
+
for (const i of indices) {
|
|
28
|
+
const arc = arcs[i < 0 ? ~i : i] ?? [];
|
|
29
|
+
const points = i < 0 ? [...arc].reverse() : arc;
|
|
30
|
+
out.push(...(out.length > 0 ? points.slice(1) : points));
|
|
31
|
+
}
|
|
32
|
+
return out;
|
|
33
|
+
};
|
|
34
|
+
const geometry = (g) => {
|
|
35
|
+
switch (g.type) {
|
|
36
|
+
case 'Point':
|
|
37
|
+
return { type: 'Point', coordinates: position(g.coordinates) };
|
|
38
|
+
case 'MultiPoint':
|
|
39
|
+
return { type: 'MultiPoint', coordinates: g.coordinates.map(position) };
|
|
40
|
+
case 'LineString':
|
|
41
|
+
return { type: 'LineString', coordinates: stitch(g.arcs) };
|
|
42
|
+
case 'MultiLineString':
|
|
43
|
+
return { type: 'MultiLineString', coordinates: g.arcs.map(stitch) };
|
|
44
|
+
case 'Polygon':
|
|
45
|
+
return { type: 'Polygon', coordinates: g.arcs.map(stitch) };
|
|
46
|
+
case 'MultiPolygon':
|
|
47
|
+
return { type: 'MultiPolygon', coordinates: g.arcs.map((p) => p.map(stitch)) };
|
|
48
|
+
case 'GeometryCollection':
|
|
49
|
+
return {
|
|
50
|
+
type: 'GeometryCollection',
|
|
51
|
+
geometries: (g.geometries ?? []).map(geometry).filter((c) => c !== null),
|
|
52
|
+
};
|
|
53
|
+
default:
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const feature = (g) => ({
|
|
58
|
+
type: 'Feature',
|
|
59
|
+
geometry: geometry(g),
|
|
60
|
+
properties: (g.properties ?? {}),
|
|
61
|
+
...(g.id === undefined ? {} : { id: g.id }),
|
|
62
|
+
});
|
|
63
|
+
const features = object.type === 'GeometryCollection' ? (object.geometries ?? []).map(feature) : [feature(object)];
|
|
64
|
+
return { type: 'FeatureCollection', features };
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=topojson.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"topojson.js","sourceRoot":"","sources":["../src/topojson.ts"],"names":[],"mappings":"AAgCA;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAiB,QAAkB,EAAE,IAAa;IAC7E,MAAM,MAAM,GAAG,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAChG,IAAI,CAAC,MAAM;QAAE,MAAM,IAAI,KAAK,CAAC,6BAA6B,IAAI,IAAI,EAAE,EAAE,CAAC,CAAC;IACxE,MAAM,EAAE,KAAK,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,SAAS,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,QAAQ,CAAC,SAAS,IAAI,EAAE,CAAC;IACxE,MAAM,SAAS,GAAG,QAAQ,CAAC,SAAS,KAAK,SAAS,CAAC;IACnD,MAAM,EAAE,GAAG,CAAC,CAAW,EAAY,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC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sourcesContent":["/**\n * TopoJSON to GeoJSON, for the feature layers: `map.addFills({ data: parseTopoJson(topology, 'counties') })`.\n */\nimport type { Feature, FeatureCollection, Geometry, Position, Properties } from './features.ts';\n\n/** A TopoJSON geometry object (arcs by index, `~i` for arc i reversed; positions quantized with a transform) */\nexport interface TopoGeometry {\n type:\n | 'Point'\n | 'MultiPoint'\n | 'LineString'\n | 'MultiLineString'\n | 'Polygon'\n | 'MultiPolygon'\n | 'GeometryCollection'\n | null;\n id?: string | number;\n properties?: Properties;\n coordinates?: number[] | number[][];\n arcs?: number[] | number[][] | number[][][];\n geometries?: TopoGeometry[];\n}\n\n/** A TopoJSON topology */\nexport interface Topology {\n type: 'Topology';\n /** Quantized positions: x × scale + translate (arcs delta-encoded) */\n transform?: { scale: [number, number]; translate: [number, number] };\n arcs: number[][][];\n objects: Record<string, TopoGeometry>;\n}\n\n/**\n * The features of object `name` of a TopoJSON topology (default its first object): a GeometryCollection gives one\n * feature per geometry, another geometry one feature; arcs are stitched and dequantized, ids and properties kept\n */\nexport function parseTopoJson<P = Properties>(topology: Topology, name?: string): FeatureCollection<P> {\n const object = name === undefined ? Object.values(topology.objects)[0] : topology.objects[name];\n if (!object) throw new Error(`isard: no TopoJSON object ${name ?? ''}`);\n const { scale = [1, 1], translate = [0, 0] } = topology.transform ?? {};\n const quantized = topology.transform !== undefined;\n const at = (p: number[]): Position => [p[0] ?? 0, p[1] ?? 0, ...p.slice(2)];\n // The arcs decoded once\n const arcs = topology.arcs.map((arc) => {\n let [x, y] = [0, 0];\n return arc.map((p): Position => {\n if (!quantized) return at(p);\n x += p[0] ?? 0;\n y += p[1] ?? 0;\n return [x * scale[0] + translate[0], y * scale[1] + translate[1], ...p.slice(2)];\n });\n });\n const position = (p: number[]): Position =>\n quantized ? [(p[0] ?? 0) * scale[0] + translate[0], (p[1] ?? 0) * scale[1] + translate[1], ...p.slice(2)] : at(p);\n /** A line from arcs, each after the first without its first point (the last of the one before) */\n const stitch = (indices: number[]): Position[] => {\n const out: Position[] = [];\n for (const i of indices) {\n const arc = arcs[i < 0 ? ~i : i] ?? [];\n const points = i < 0 ? [...arc].reverse() : arc;\n out.push(...(out.length > 0 ? points.slice(1) : points));\n }\n return out;\n };\n const geometry = (g: TopoGeometry): Geometry | null => {\n switch (g.type) {\n case 'Point':\n return { type: 'Point', coordinates: position(g.coordinates as number[]) };\n case 'MultiPoint':\n return { type: 'MultiPoint', coordinates: (g.coordinates as number[][]).map(position) };\n case 'LineString':\n return { type: 'LineString', coordinates: stitch(g.arcs as number[]) };\n case 'MultiLineString':\n return { type: 'MultiLineString', coordinates: (g.arcs as number[][]).map(stitch) };\n case 'Polygon':\n return { type: 'Polygon', coordinates: (g.arcs as number[][]).map(stitch) };\n case 'MultiPolygon':\n return { type: 'MultiPolygon', coordinates: (g.arcs as number[][][]).map((p) => p.map(stitch)) };\n case 'GeometryCollection':\n return {\n type: 'GeometryCollection',\n geometries: (g.geometries ?? []).map(geometry).filter((c) => c !== null),\n };\n default:\n return null;\n }\n };\n const feature = (g: TopoGeometry): Feature<P> => ({\n type: 'Feature',\n geometry: geometry(g),\n properties: (g.properties ?? {}) as P,\n ...(g.id === undefined ? {} : { id: g.id }),\n });\n const features = object.type === 'GeometryCollection' ? (object.geometries ?? []).map(feature) : [feature(object)];\n return { type: 'FeatureCollection', features };\n}\n"]}
|
package/dist/types.d.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import type { AttributionOptions } from './controls.ts';
|
|
3
3
|
import type { DecoderUrls } from './decoders.ts';
|
|
4
4
|
import type { Feature, Ramp, Size } from './features.ts';
|
|
5
|
+
import type { TileGrid } from './grid.ts';
|
|
5
6
|
import type { Layer } from './layers.ts';
|
|
6
7
|
import type { Camera, Engine } from './wasm/isard.js';
|
|
7
8
|
export type LonLat = [lon: number, lat: number];
|
|
@@ -103,19 +104,24 @@ export interface GeoMapOptions extends Partial<Camera> {
|
|
|
103
104
|
* resolve the default URL. Maps load it first, and the engine with 3D Tiles (`wasmUrl`) for their first 3D Tiles
|
|
104
105
|
* layer only */
|
|
105
106
|
coreWasmUrl?: string | URL;
|
|
106
|
-
/** Load the engine with 3D Tiles from the start (default false: it is loaded when the first 3D Tiles layer
|
|
107
|
-
* the map then moving its camera and layers onto it, a stall of about a frame or two). For a map that shows 3D Tiles
|
|
107
|
+
/** Load the engine with 3D Tiles from the start (default false: it is loaded when the first 3D Tiles layer or glTF
|
|
108
|
+
* model is added, the map then moving its camera and layers onto it, a stall of about a frame or two). For a map that shows 3D Tiles
|
|
108
109
|
* at once: one engine downloaded instead of two. `'preload'`: the map starts on the engine without 3D Tiles and
|
|
109
110
|
* downloads and compiles the other once idle, without running it: its first 3D Tiles layer does not wait for the
|
|
110
111
|
* download (for a map that will show 3D Tiles later, on demand) */
|
|
111
112
|
tiles3d?: boolean | 'preload';
|
|
112
113
|
/** Where to load the vector basemap worker from, when a bundler does not resolve the default URL */
|
|
113
114
|
basemapWorkerUrl?: string | URL;
|
|
115
|
+
/** Texture size of the vector basemap's tiles, pixels (default 512: lines and edges sharp at every zoom on a screen
|
|
116
|
+
* of pixel ratio 1). 256: a quarter of the drawing in the workers, of the uploads and of the GPU memory, for lines
|
|
117
|
+
* and edges a little softer between two zoom levels (the tiles are shown 181 to 362 CSS pixels wide) */
|
|
118
|
+
basemapTileSize?: number;
|
|
114
119
|
/** Glyphs of the symbol layers: a URL with `{fontstack}` and `{range}` (MapLibre's glyph format; default
|
|
115
120
|
* OpenFreeMap's fonts, Noto Sans). A vector basemap's labels take the glyphs of its style */
|
|
116
121
|
glyphs?: string;
|
|
117
122
|
/** Workers decoding 3D Tiles off the main thread: a count, or false to decode on the main thread (default: cores - 1,
|
|
118
|
-
* 1 to 4)
|
|
123
|
+
* 1 to 4). False (or 0) also decodes the PNG relief and reprojects the equirectangular rasters on the main thread,
|
|
124
|
+
* else done by the vector basemap's workers */
|
|
119
125
|
workers?: number | false;
|
|
120
126
|
/** Where to load the decoding worker from, when a bundler does not resolve the default URL */
|
|
121
127
|
workerUrl?: string | URL;
|
|
@@ -179,9 +185,11 @@ export interface FlyToOptions extends AnimationOptions {
|
|
|
179
185
|
/**
|
|
180
186
|
* Tile grid of a raster's URL. 'mercator': Web Mercator (XYZ, WMTS PM), the engine's own. 'equirectangular':
|
|
181
187
|
* longitudes and latitudes (Plate Carrée, EPSG:4326-like), two 256 px tiles side by side at level 0, rows from the
|
|
182
|
-
* north (NASA's Trek WMTS, WorldCRS84Quad)
|
|
188
|
+
* north (NASA's Trek WMTS, WorldCRS84Quad). A `TileGrid`: the tile matrices of a WMTS in any CRS (Lambert-93…), or a
|
|
189
|
+
* WMS asked for each tile's box in its CRS. The last two are reprojected into Web Mercator tiles by the map's workers
|
|
190
|
+
* (in the page with `workers: false`).
|
|
183
191
|
*/
|
|
184
|
-
export type RasterGrid = 'mercator' | 'equirectangular';
|
|
192
|
+
export type RasterGrid = 'mercator' | 'equirectangular' | TileGrid;
|
|
185
193
|
/** What `RasterLayer.setStyle` changes */
|
|
186
194
|
export interface RasterStyle {
|
|
187
195
|
opacity: number;
|
|
@@ -192,7 +200,7 @@ export interface RasterOptions {
|
|
|
192
200
|
/** Tile URL with {z}, {x} and {y} (256 px tiles); unused with a `loader` */
|
|
193
201
|
url: string;
|
|
194
202
|
/** Tile grid of `url` (default 'mercator'); with 'equirectangular', `minZoom` and `maxZoom` are levels of that
|
|
195
|
-
* grid */
|
|
203
|
+
* grid; with a `TileGrid`, they are map zooms, by default those its matrices span */
|
|
196
204
|
grid?: RasterGrid;
|
|
197
205
|
minZoom?: number;
|
|
198
206
|
maxZoom?: number;
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["/** Public types of the `isard` package */\nimport type { AttributionOptions } from './controls.ts';\nimport type { DecoderUrls } from './decoders.ts';\nimport type { Feature, Ramp, Size } from './features.ts';\nimport type { Layer } from './layers.ts';\nimport type { Camera, Engine } from './wasm/isard.js';\n\nexport type LonLat = [lon: number, lat: number];\nexport type Point = [x: number, y: number];\n\n/**\n * The named basemaps. OpenFreeMap's vector styles, OpenStreetMap data worldwide, their labels above the other layers:\n * `osm-positron` (light grey, quiet: data over it reads first), `osm-liberty` and `osm-bright` (in colour). The\n * Géoplateforme's (IGN, France): rasters (`ign-plan`, `ign-plan-grey`, `ign-ortho`, the aerial photographs) or vector\n * tiles with their labels (`ign-plan-vector`, `ign-plan-grey-vector`, the PLAN.IGN styles).\n */\nexport type BasemapName =\n | 'osm-positron'\n | 'osm-liberty'\n | 'osm-bright'\n | 'ign-plan'\n | 'ign-plan-grey'\n | 'ign-ortho'\n | 'ign-plan-vector'\n | 'ign-plan-grey-vector'\n | 'none';\n\n/**\n * @deprecated The former names of the Géoplateforme basemaps, still accepted (with a warning): the same names with the\n * `ign-` prefix (`'plan-grey'` is `'ign-plan-grey'`)\n */\nexport type LegacyBasemap = 'plan' | 'plan-grey' | 'plan-vector' | 'plan-grey-vector' | 'ortho';\n\n/** A basemap by name (see `BasemapName`; the former names of `LegacyBasemap` are deprecated) */\nexport type Basemap = BasemapName | LegacyBasemap;\n\n/**\n * The Earth's named terrain models. `'terrain-tiles'`: worldwide, the Terrain Tiles of AWS's open data registry\n * (SRTM, EU-DEM, GMTED… merged by Mapzen, 30 m in most places), the sea floor flattened at sea level. `'ign'`: France,\n * the IGN's RGE ALTI from the Géoplateforme (1 to 5 m), raised by the RAF20 geoid to heights above the ellipsoid.\n */\nexport type TerrainModel = 'terrain-tiles' | 'ign';\n\n/** How tiles encode their altitudes: `'float32'`, raw little-endian floats (`image/x-bil;bits=32`, an ArcGIS raw\n * grid); `'terrarium'`, the colors of a PNG, `R × 256 + G + B / 256 - 32768`; `'mapbox'`, those of Terrain-RGB,\n * `(R × 65536 + G × 256 + B) / 10 - 10000` */\nexport type TerrainEncoding = 'float32' | 'terrarium' | 'mapbox';\n\n/**\n * How tiles load and show. 'immediate' (default): everything visible loads, tiles show as soon as they arrive.\n * 'smooth': during flights the levels flown through are skipped, off-center tiles wait while the camera moves, tiles\n * fade in; fewer downloads, for slow networks or GPUs.\n */\nexport type LoadingMode = 'immediate' | 'smooth';\n\n/** 'globe': a sphere at low zoom, blending into Web Mercator between zooms 5 and 7 */\nexport type Projection = 'globe' | 'mercator';\n\n/** A body to draw the map on, other than the named ones (`CelestialBody`) */\nexport interface BodyOptions {\n /** Equatorial radius, metres */\n radius: number;\n /** Flattening of its ellipsoid, 0 for a sphere (default 0) */\n flattening?: number;\n /** An atmosphere: its halo around the globe, true for the Earth's light blue, or a CSS color (its alpha the\n * halo's strength) (default false) */\n atmosphere?: boolean | string;\n /** Color of the globe where no tile covers it (past the Web Mercator latitudes, 85°), a CSS color (default\n * `#808080`) */\n color?: string;\n /** Lowest and highest altitudes of its ground, metres around the ellipsoid: what its relief may raise into view\n * (default ±1 % of the radius) */\n relief?: [lowest: number, highest: number];\n}\n\n/**\n * The body the map is drawn on: 'earth' (WGS 84, the default), 'moon' (a sphere of 1 737 400 m, no atmosphere),\n * 'mars' (a sphere of 3 396 190 m, its equatorial radius, a thin dusty halo; planetocentric latitudes) or another\n * one. Zoom levels keep their meaning on screen (the Web Mercator tile pyramid), their metres follow the body:\n * altitudes, relief, buildings, 3D Tiles. Off the Earth, the map has none of the Earth's defaults: no basemap, no\n * credits, and space for its background; the Moon and Mars have NASA's relief for `terrain: true`.\n */\nexport type CelestialBody = 'earth' | 'moon' | 'mars' | BodyOptions;\n\nexport interface GeoMapOptions extends Partial<Camera> {\n /** The body the map is drawn on (default 'earth'); set at creation */\n body?: CelestialBody;\n /** Default 'globe' */\n projection?: Projection;\n /** Default 'immediate' */\n loading?: LoadingMode;\n /** The basemap (default 'osm-positron'; 'none' off the Earth) */\n basemap?: Basemap;\n /** Opacity of the IGN hillshade over the basemap (France, Géoplateforme), 0 for none (default 0) */\n hillshade?: number;\n /** Color behind the map (sky of tilted flat views), a CSS color (default `#f2f2f0`; black off the Earth) */\n background?: string;\n /** Space behind the globe: stars and atmosphere halo, fading out as the globe turns flat (default true) */\n sky?: boolean;\n /** Relief under the basemap: true for the body's terrain model (on the Earth the worldwide Terrain Tiles; NASA's on\n * the Moon and Mars: LOLA, MOLA), one of the Earth's models by name (`'ign'`: France, RGE ALTI), or its options\n * (default false; on another body, its `url` is required). Network layers are draped on it */\n terrain?: boolean | TerrainModel | TerrainOptions;\n minZoom?: number;\n maxZoom?: number;\n /** Highest pitch, degrees, up to 85 (default 70) */\n maxPitch?: number;\n /** Sky over the plane, seen when the camera is tilted towards the horizon, and the fog the ground fades into\n * (MapLibre's `setSky`); default none: the background color */\n atmosphere?: AtmosphereOptions;\n /** Mouse, touch and keyboard controls (default true) */\n interactive?: boolean;\n /** Keyboard controls once the map has the focus (it is reached with Tab): arrows pan, Shift + arrows rotate and\n * tilt, + and - zoom (Shift: two levels), 0 faces north and levels the view (default true; none when not\n * `interactive`) */\n keyboard?: boolean;\n /** Accessible name of the map, read by screen readers (default 'Map') */\n ariaLabel?: string;\n /** Where to load the engine with 3D Tiles from (`isard_bg.wasm`), when a bundler does not resolve the default URL.\n * Given without `coreWasmUrl`, maps load this engine from the start */\n wasmUrl?: string | URL;\n /** Where to load the engine without 3D Tiles from (`isard_core_bg.wasm`, a third smaller), when a bundler does not\n * resolve the default URL. Maps load it first, and the engine with 3D Tiles (`wasmUrl`) for their first 3D Tiles\n * layer only */\n coreWasmUrl?: string | URL;\n /** Load the engine with 3D Tiles from the start (default false: it is loaded when the first 3D Tiles layer is added,\n * the map then moving its camera and layers onto it, a stall of about a frame or two). For a map that shows 3D Tiles\n * at once: one engine downloaded instead of two. `'preload'`: the map starts on the engine without 3D Tiles and\n * downloads and compiles the other once idle, without running it: its first 3D Tiles layer does not wait for the\n * download (for a map that will show 3D Tiles later, on demand) */\n tiles3d?: boolean | 'preload';\n /** Where to load the vector basemap worker from, when a bundler does not resolve the default URL */\n basemapWorkerUrl?: string | URL;\n /** Glyphs of the symbol layers: a URL with `{fontstack}` and `{range}` (MapLibre's glyph format; default\n * OpenFreeMap's fonts, Noto Sans). A vector basemap's labels take the glyphs of its style */\n glyphs?: string;\n /** Workers decoding 3D Tiles off the main thread: a count, or false to decode on the main thread (default: cores - 1,\n * 1 to 4) */\n workers?: number | false;\n /** Where to load the decoding worker from, when a bundler does not resolve the default URL */\n workerUrl?: string | URL;\n /** Folders of the Draco and Basis Universal decoders, loaded by the workers on first use (default: the official\n * builds on gstatic.com and jsDelivr; self-host them for offline or locked-down networks). They run through\n * `new Function`: a Content Security Policy needs `'unsafe-eval'` (see `DecoderUrls`) */\n decoders?: Partial<DecoderUrls>;\n /** Credits at the bottom right: false for none, or its options (default true: the credits of the basemap,\n * hillshade and relief in use, compact on maps narrower than 640 px) */\n attributionControl?: boolean | AttributionOptions;\n}\n\nexport interface TerrainOptions {\n /** One of the Earth's named models (default `'terrain-tiles'` on the Earth); unused with a `url` */\n model?: TerrainModel;\n /** Altitudes of 256 × 256 tiles in `encoding`: a WMS GetMap URL with {bbox} (EPSG:3857 on the Earth, the body's\n * Mercator metres elsewhere: the sphere of its radius), a tile URL with {z}, {x} and {y}, or an ArcGIS image service\n * (a URL ending in `/ImageServer`), asked for raw altitudes in the body's Mercator (default: the `model`'s; on the\n * Moon and Mars, NASA's Trek LOLA and MOLA models) */\n url?: string;\n /** How the tiles of `url` encode their altitudes (default `'float32'`); `'terrarium'` and `'mapbox'` take a URL with\n * {z}, {x} and {y} */\n encoding?: TerrainEncoding;\n /** Vertical exaggeration, 1 for the true relief (default 1) */\n exaggeration?: number;\n /** Finest level of the relief, up to 15 (default 15; 14 for the Terrain Tiles, 8 for the Moon's and Mars's models). It\n * starts at level 6 on the Earth, coarser on bodies of a larger relief for their size (3 on the Moon and Mars) */\n maxZoom?: number;\n /** Altitudes over mainland France raised by the height of the RAF20 geoid (the French one, 0 away from France), to\n * heights above the ellipsoid (those of 3D Tiles); false keeps the altitudes as served (NGF-IGN69 for the IGN's)\n * (default true for the `'ign'` model, false otherwise) */\n geoid?: boolean;\n}\n\n/** Sky, horizon and fog over the plane, with the names and meanings of MapLibre's `setSky` */\nexport interface AtmosphereOptions {\n /** A CSS color (default `#9cc7ec`) */\n skyColor?: string;\n /** (default `#e8f1f8`) */\n horizonColor?: string;\n /** (default `#f2f5f8`) */\n fogColor?: string;\n /** Blend from the horizon to the sky color, share of the field of view above the horizon, 0-1 (default 0.6) */\n skyHorizonBlend?: number;\n /** Blend from the horizon to the fog color below the horizon, 0-1 (default 0.7) */\n horizonFogBlend?: number;\n /** Share of the distance to the far plane over which the ground fades into the fog, 0-1 (default 0.4) */\n fogGroundBlend?: number;\n}\n\n/** Animation of a camera move */\nexport interface AnimationOptions {\n /** Milliseconds */\n duration?: number;\n /** Progress over time, both 0 to 1 */\n easing?: (t: number) => number;\n}\n\nexport interface FlyToOptions extends AnimationOptions {\n /** How far the flight zooms out on its way, as MapLibre's `curve` (default 1.42) */\n curve?: number;\n /** Average speed in screens per second when `duration` is not given (default 1.2) */\n speed?: number;\n}\n\n/**\n * Tile grid of a raster's URL. 'mercator': Web Mercator (XYZ, WMTS PM), the engine's own. 'equirectangular':\n * longitudes and latitudes (Plate Carrée, EPSG:4326-like), two 256 px tiles side by side at level 0, rows from the\n * north (NASA's Trek WMTS, WorldCRS84Quad), reprojected in the page into Web Mercator tiles.\n */\nexport type RasterGrid = 'mercator' | 'equirectangular';\n\n/** What `RasterLayer.setStyle` changes */\nexport interface RasterStyle {\n opacity: number;\n /** 0 = greyscale, 1 = original colors */\n saturation: number;\n}\n\nexport interface RasterOptions {\n /** Tile URL with {z}, {x} and {y} (256 px tiles); unused with a `loader` */\n url: string;\n /** Tile grid of `url` (default 'mercator'); with 'equirectangular', `minZoom` and `maxZoom` are levels of that\n * grid */\n grid?: RasterGrid;\n minZoom?: number;\n maxZoom?: number;\n opacity?: number;\n /** 0 = greyscale, 1 = original colors */\n saturation?: number;\n /** Side of the tiles' textures, pixels (default 256): more for sharper tiles drawn by a `loader` */\n size?: number;\n /** Draws each tile instead of fetching `url`: an image of `size` × `size`, null for nothing there; a rejection is\n * retried like a network error */\n loader?: (z: number, x: number, y: number, signal: AbortSignal) => Promise<ImageBitmap | null>;\n /** Credits of the tiles, HTML: shown by the attribution control while the layer is on the map */\n attribution?: string;\n}\n\nexport interface NetworkStyle {\n /** Line width, CSS pixels, or zoom stops `[[zoom, width], …]` (default 2) */\n width: Size;\n /** Values above are drawn as unreached (default 1800) */\n max: number;\n /** Darker line every `contour` value units, 0 for none (default 0) */\n contour: number;\n opacity: number;\n /** Width of the halo drawn under the lines, CSS pixels or zoom stops, 0 for none (default 0): wide and faint, the\n * reached streets add up into a heat map that fills the blocks */\n halo: Size;\n /** Opacity of the halo at the middle of a line, fading quadratically to its sides (default 0.11) */\n haloOpacity: number;\n /** Colors from 0 to `max`: `[[fraction of max, color], …]` (default green to red) */\n ramp: Ramp | undefined;\n /** Color of the parts beyond `max` or unreached (default `rgba(140, 140, 140, 0.25)`) */\n unreachedColor: string;\n /** Share of `max` over which the colors fade out before it, 0 to 1 (default 0) */\n fade: number;\n}\n\nexport interface NetworkOptions extends Partial<NetworkStyle> {\n /** Node coordinates in degrees: lon0, lat0, lon1, lat1… */\n nodes: Float64Array;\n /** Edges as node index pairs: a0, b0, a1, b1… */\n edges: Uint32Array;\n /** Line of each edge, from A to B: the points of edge e are `points[start[e] .. start[e + 1]]` (lon, lat pairs,\n * counted in points); with fewer than two points an edge is straight. Default: all straight. */\n lines?: { start: Uint32Array; points: Float64Array };\n /** Per edge, the cost of travelling it from A to B then from B to A, in value units (Infinity: closed that way;\n * closed both ways: not drawn). A point along an edge then takes the quickest way there, min(value(A) + cost from\n * A, value(B) + cost from B), as a travel time does. Without costs, values are interpolated along the edges. */\n costs?: Float32Array;\n /** Width factor of each edge (default 1): rail lines wider than streets */\n edgeWidths?: Float32Array;\n}\n\nexport interface Tiles3dStyle {\n /** Screen-space error (CSS pixels) above which a tile is refined: 16 by default, lower is finer and heavier */\n maxScreenSpaceError: number;\n opacity: number;\n}\n\nexport interface Tiles3dOptions extends Partial<Tiles3dStyle> {\n /** URL of a `tileset.json` (3D Tiles 1.0 b3dm or 1.1 glb meshes, external tilesets) */\n url: string;\n}\n\nexport interface MapPointerEvent {\n point: Point;\n /** Undefined above the horizon */\n lonLat: LonLat | undefined;\n}\n\n/** What 'hoverfeature' found under the pointer */\nexport interface MapHoverFeatureEvent extends MapPointerEvent {\n /** The feature under the pointer (see `GeoMap.pickFeature`), undefined if none */\n hit: FeatureHit | undefined;\n}\n\n/** A picked feature: its layer handle, its index there and, for line, circle and fill layers, the feature itself */\nexport interface FeatureHit {\n layer: Layer;\n index: number;\n feature: Feature | undefined;\n}\n\nexport interface MapEvents {\n /** The camera started moving (a gesture, an animation or `setCamera`) */\n movestart: Camera;\n /** The camera moved */\n move: Camera;\n /** The camera stopped: no gesture held, no animation running */\n moveend: Camera;\n /** The map changed size (CSS pixels) */\n resize: { width: number; height: number };\n /** The pointer moved over the map (at most once per frame, not while dragging) */\n hover: MapPointerEvent;\n /** What is under the pointer, picked without stalling the GPU: a frame or two after 'hover', only while listened to\n * (radius and layers in `GeoMap.hoverPicking`) */\n hoverfeature: MapHoverFeatureEvent;\n /** Click without drag */\n click: MapPointerEvent;\n /** A frame was drawn; duration of the engine call in milliseconds */\n render: { ms: number };\n /** Everything in view is loaded and drawn, nothing moves: the end of a load, once after each change (as MapLibre's\n * `idle`). Tiles requested by the first frame count, so it never fires before they arrive. */\n idle: Record<string, never>;\n /** The pointer left the canvas (a mouse going out of the map, or onto a control or marker) */\n leave: Record<string, never>;\n}\n\n/** What a layer handle needs from its map */\nexport interface LayerHost {\n readonly engine: Engine;\n requestRender(): void;\n /** Forgets a removed layer */\n detach(layer: object): void;\n /** Moves a layer under `before`, or on top */\n moveLayer(layer: object, before: object | undefined): void;\n /** A layer created again in the engine (new id): put at the place of its old id, which is removed */\n replaceLayer(layer: object, old: number): void;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["/** Public types of the `isard` package */\nimport type { AttributionOptions } from './controls.ts';\nimport type { DecoderUrls } from './decoders.ts';\nimport type { Feature, Ramp, Size } from './features.ts';\nimport type { TileGrid } from './grid.ts';\nimport type { Layer } from './layers.ts';\nimport type { Camera, Engine } from './wasm/isard.js';\n\nexport type LonLat = [lon: number, lat: number];\nexport type Point = [x: number, y: number];\n\n/**\n * The named basemaps. OpenFreeMap's vector styles, OpenStreetMap data worldwide, their labels above the other layers:\n * `osm-positron` (light grey, quiet: data over it reads first), `osm-liberty` and `osm-bright` (in colour). The\n * Géoplateforme's (IGN, France): rasters (`ign-plan`, `ign-plan-grey`, `ign-ortho`, the aerial photographs) or vector\n * tiles with their labels (`ign-plan-vector`, `ign-plan-grey-vector`, the PLAN.IGN styles).\n */\nexport type BasemapName =\n | 'osm-positron'\n | 'osm-liberty'\n | 'osm-bright'\n | 'ign-plan'\n | 'ign-plan-grey'\n | 'ign-ortho'\n | 'ign-plan-vector'\n | 'ign-plan-grey-vector'\n | 'none';\n\n/**\n * @deprecated The former names of the Géoplateforme basemaps, still accepted (with a warning): the same names with the\n * `ign-` prefix (`'plan-grey'` is `'ign-plan-grey'`)\n */\nexport type LegacyBasemap = 'plan' | 'plan-grey' | 'plan-vector' | 'plan-grey-vector' | 'ortho';\n\n/** A basemap by name (see `BasemapName`; the former names of `LegacyBasemap` are deprecated) */\nexport type Basemap = BasemapName | LegacyBasemap;\n\n/**\n * The Earth's named terrain models. `'terrain-tiles'`: worldwide, the Terrain Tiles of AWS's open data registry\n * (SRTM, EU-DEM, GMTED… merged by Mapzen, 30 m in most places), the sea floor flattened at sea level. `'ign'`: France,\n * the IGN's RGE ALTI from the Géoplateforme (1 to 5 m), raised by the RAF20 geoid to heights above the ellipsoid.\n */\nexport type TerrainModel = 'terrain-tiles' | 'ign';\n\n/** How tiles encode their altitudes: `'float32'`, raw little-endian floats (`image/x-bil;bits=32`, an ArcGIS raw\n * grid); `'terrarium'`, the colors of a PNG, `R × 256 + G + B / 256 - 32768`; `'mapbox'`, those of Terrain-RGB,\n * `(R × 65536 + G × 256 + B) / 10 - 10000` */\nexport type TerrainEncoding = 'float32' | 'terrarium' | 'mapbox';\n\n/**\n * How tiles load and show. 'immediate' (default): everything visible loads, tiles show as soon as they arrive.\n * 'smooth': during flights the levels flown through are skipped, off-center tiles wait while the camera moves, tiles\n * fade in; fewer downloads, for slow networks or GPUs.\n */\nexport type LoadingMode = 'immediate' | 'smooth';\n\n/** 'globe': a sphere at low zoom, blending into Web Mercator between zooms 5 and 7 */\nexport type Projection = 'globe' | 'mercator';\n\n/** A body to draw the map on, other than the named ones (`CelestialBody`) */\nexport interface BodyOptions {\n /** Equatorial radius, metres */\n radius: number;\n /** Flattening of its ellipsoid, 0 for a sphere (default 0) */\n flattening?: number;\n /** An atmosphere: its halo around the globe, true for the Earth's light blue, or a CSS color (its alpha the\n * halo's strength) (default false) */\n atmosphere?: boolean | string;\n /** Color of the globe where no tile covers it (past the Web Mercator latitudes, 85°), a CSS color (default\n * `#808080`) */\n color?: string;\n /** Lowest and highest altitudes of its ground, metres around the ellipsoid: what its relief may raise into view\n * (default ±1 % of the radius) */\n relief?: [lowest: number, highest: number];\n}\n\n/**\n * The body the map is drawn on: 'earth' (WGS 84, the default), 'moon' (a sphere of 1 737 400 m, no atmosphere),\n * 'mars' (a sphere of 3 396 190 m, its equatorial radius, a thin dusty halo; planetocentric latitudes) or another\n * one. Zoom levels keep their meaning on screen (the Web Mercator tile pyramid), their metres follow the body:\n * altitudes, relief, buildings, 3D Tiles. Off the Earth, the map has none of the Earth's defaults: no basemap, no\n * credits, and space for its background; the Moon and Mars have NASA's relief for `terrain: true`.\n */\nexport type CelestialBody = 'earth' | 'moon' | 'mars' | BodyOptions;\n\nexport interface GeoMapOptions extends Partial<Camera> {\n /** The body the map is drawn on (default 'earth'); set at creation */\n body?: CelestialBody;\n /** Default 'globe' */\n projection?: Projection;\n /** Default 'immediate' */\n loading?: LoadingMode;\n /** The basemap (default 'osm-positron'; 'none' off the Earth) */\n basemap?: Basemap;\n /** Opacity of the IGN hillshade over the basemap (France, Géoplateforme), 0 for none (default 0) */\n hillshade?: number;\n /** Color behind the map (sky of tilted flat views), a CSS color (default `#f2f2f0`; black off the Earth) */\n background?: string;\n /** Space behind the globe: stars and atmosphere halo, fading out as the globe turns flat (default true) */\n sky?: boolean;\n /** Relief under the basemap: true for the body's terrain model (on the Earth the worldwide Terrain Tiles; NASA's on\n * the Moon and Mars: LOLA, MOLA), one of the Earth's models by name (`'ign'`: France, RGE ALTI), or its options\n * (default false; on another body, its `url` is required). Network layers are draped on it */\n terrain?: boolean | TerrainModel | TerrainOptions;\n minZoom?: number;\n maxZoom?: number;\n /** Highest pitch, degrees, up to 85 (default 70) */\n maxPitch?: number;\n /** Sky over the plane, seen when the camera is tilted towards the horizon, and the fog the ground fades into\n * (MapLibre's `setSky`); default none: the background color */\n atmosphere?: AtmosphereOptions;\n /** Mouse, touch and keyboard controls (default true) */\n interactive?: boolean;\n /** Keyboard controls once the map has the focus (it is reached with Tab): arrows pan, Shift + arrows rotate and\n * tilt, + and - zoom (Shift: two levels), 0 faces north and levels the view (default true; none when not\n * `interactive`) */\n keyboard?: boolean;\n /** Accessible name of the map, read by screen readers (default 'Map') */\n ariaLabel?: string;\n /** Where to load the engine with 3D Tiles from (`isard_bg.wasm`), when a bundler does not resolve the default URL.\n * Given without `coreWasmUrl`, maps load this engine from the start */\n wasmUrl?: string | URL;\n /** Where to load the engine without 3D Tiles from (`isard_core_bg.wasm`, a third smaller), when a bundler does not\n * resolve the default URL. Maps load it first, and the engine with 3D Tiles (`wasmUrl`) for their first 3D Tiles\n * layer only */\n coreWasmUrl?: string | URL;\n /** Load the engine with 3D Tiles from the start (default false: it is loaded when the first 3D Tiles layer or glTF\n * model is added, the map then moving its camera and layers onto it, a stall of about a frame or two). For a map that shows 3D Tiles\n * at once: one engine downloaded instead of two. `'preload'`: the map starts on the engine without 3D Tiles and\n * downloads and compiles the other once idle, without running it: its first 3D Tiles layer does not wait for the\n * download (for a map that will show 3D Tiles later, on demand) */\n tiles3d?: boolean | 'preload';\n /** Where to load the vector basemap worker from, when a bundler does not resolve the default URL */\n basemapWorkerUrl?: string | URL;\n /** Texture size of the vector basemap's tiles, pixels (default 512: lines and edges sharp at every zoom on a screen\n * of pixel ratio 1). 256: a quarter of the drawing in the workers, of the uploads and of the GPU memory, for lines\n * and edges a little softer between two zoom levels (the tiles are shown 181 to 362 CSS pixels wide) */\n basemapTileSize?: number;\n /** Glyphs of the symbol layers: a URL with `{fontstack}` and `{range}` (MapLibre's glyph format; default\n * OpenFreeMap's fonts, Noto Sans). A vector basemap's labels take the glyphs of its style */\n glyphs?: string;\n /** Workers decoding 3D Tiles off the main thread: a count, or false to decode on the main thread (default: cores - 1,\n * 1 to 4). False (or 0) also decodes the PNG relief and reprojects the equirectangular rasters on the main thread,\n * else done by the vector basemap's workers */\n workers?: number | false;\n /** Where to load the decoding worker from, when a bundler does not resolve the default URL */\n workerUrl?: string | URL;\n /** Folders of the Draco and Basis Universal decoders, loaded by the workers on first use (default: the official\n * builds on gstatic.com and jsDelivr; self-host them for offline or locked-down networks). They run through\n * `new Function`: a Content Security Policy needs `'unsafe-eval'` (see `DecoderUrls`) */\n decoders?: Partial<DecoderUrls>;\n /** Credits at the bottom right: false for none, or its options (default true: the credits of the basemap,\n * hillshade and relief in use, compact on maps narrower than 640 px) */\n attributionControl?: boolean | AttributionOptions;\n}\n\nexport interface TerrainOptions {\n /** One of the Earth's named models (default `'terrain-tiles'` on the Earth); unused with a `url` */\n model?: TerrainModel;\n /** Altitudes of 256 × 256 tiles in `encoding`: a WMS GetMap URL with {bbox} (EPSG:3857 on the Earth, the body's\n * Mercator metres elsewhere: the sphere of its radius), a tile URL with {z}, {x} and {y}, or an ArcGIS image service\n * (a URL ending in `/ImageServer`), asked for raw altitudes in the body's Mercator (default: the `model`'s; on the\n * Moon and Mars, NASA's Trek LOLA and MOLA models) */\n url?: string;\n /** How the tiles of `url` encode their altitudes (default `'float32'`); `'terrarium'` and `'mapbox'` take a URL with\n * {z}, {x} and {y} */\n encoding?: TerrainEncoding;\n /** Vertical exaggeration, 1 for the true relief (default 1) */\n exaggeration?: number;\n /** Finest level of the relief, up to 15 (default 15; 14 for the Terrain Tiles, 8 for the Moon's and Mars's models). It\n * starts at level 6 on the Earth, coarser on bodies of a larger relief for their size (3 on the Moon and Mars) */\n maxZoom?: number;\n /** Altitudes over mainland France raised by the height of the RAF20 geoid (the French one, 0 away from France), to\n * heights above the ellipsoid (those of 3D Tiles); false keeps the altitudes as served (NGF-IGN69 for the IGN's)\n * (default true for the `'ign'` model, false otherwise) */\n geoid?: boolean;\n}\n\n/** Sky, horizon and fog over the plane, with the names and meanings of MapLibre's `setSky` */\nexport interface AtmosphereOptions {\n /** A CSS color (default `#9cc7ec`) */\n skyColor?: string;\n /** (default `#e8f1f8`) */\n horizonColor?: string;\n /** (default `#f2f5f8`) */\n fogColor?: string;\n /** Blend from the horizon to the sky color, share of the field of view above the horizon, 0-1 (default 0.6) */\n skyHorizonBlend?: number;\n /** Blend from the horizon to the fog color below the horizon, 0-1 (default 0.7) */\n horizonFogBlend?: number;\n /** Share of the distance to the far plane over which the ground fades into the fog, 0-1 (default 0.4) */\n fogGroundBlend?: number;\n}\n\n/** Animation of a camera move */\nexport interface AnimationOptions {\n /** Milliseconds */\n duration?: number;\n /** Progress over time, both 0 to 1 */\n easing?: (t: number) => number;\n}\n\nexport interface FlyToOptions extends AnimationOptions {\n /** How far the flight zooms out on its way, as MapLibre's `curve` (default 1.42) */\n curve?: number;\n /** Average speed in screens per second when `duration` is not given (default 1.2) */\n speed?: number;\n}\n\n/**\n * Tile grid of a raster's URL. 'mercator': Web Mercator (XYZ, WMTS PM), the engine's own. 'equirectangular':\n * longitudes and latitudes (Plate Carrée, EPSG:4326-like), two 256 px tiles side by side at level 0, rows from the\n * north (NASA's Trek WMTS, WorldCRS84Quad). A `TileGrid`: the tile matrices of a WMTS in any CRS (Lambert-93…), or a\n * WMS asked for each tile's box in its CRS. The last two are reprojected into Web Mercator tiles by the map's workers\n * (in the page with `workers: false`).\n */\nexport type RasterGrid = 'mercator' | 'equirectangular' | TileGrid;\n\n/** What `RasterLayer.setStyle` changes */\nexport interface RasterStyle {\n opacity: number;\n /** 0 = greyscale, 1 = original colors */\n saturation: number;\n}\n\nexport interface RasterOptions {\n /** Tile URL with {z}, {x} and {y} (256 px tiles); unused with a `loader` */\n url: string;\n /** Tile grid of `url` (default 'mercator'); with 'equirectangular', `minZoom` and `maxZoom` are levels of that\n * grid; with a `TileGrid`, they are map zooms, by default those its matrices span */\n grid?: RasterGrid;\n minZoom?: number;\n maxZoom?: number;\n opacity?: number;\n /** 0 = greyscale, 1 = original colors */\n saturation?: number;\n /** Side of the tiles' textures, pixels (default 256): more for sharper tiles drawn by a `loader` */\n size?: number;\n /** Draws each tile instead of fetching `url`: an image of `size` × `size`, null for nothing there; a rejection is\n * retried like a network error */\n loader?: (z: number, x: number, y: number, signal: AbortSignal) => Promise<ImageBitmap | null>;\n /** Credits of the tiles, HTML: shown by the attribution control while the layer is on the map */\n attribution?: string;\n}\n\nexport interface NetworkStyle {\n /** Line width, CSS pixels, or zoom stops `[[zoom, width], …]` (default 2) */\n width: Size;\n /** Values above are drawn as unreached (default 1800) */\n max: number;\n /** Darker line every `contour` value units, 0 for none (default 0) */\n contour: number;\n opacity: number;\n /** Width of the halo drawn under the lines, CSS pixels or zoom stops, 0 for none (default 0): wide and faint, the\n * reached streets add up into a heat map that fills the blocks */\n halo: Size;\n /** Opacity of the halo at the middle of a line, fading quadratically to its sides (default 0.11) */\n haloOpacity: number;\n /** Colors from 0 to `max`: `[[fraction of max, color], …]` (default green to red) */\n ramp: Ramp | undefined;\n /** Color of the parts beyond `max` or unreached (default `rgba(140, 140, 140, 0.25)`) */\n unreachedColor: string;\n /** Share of `max` over which the colors fade out before it, 0 to 1 (default 0) */\n fade: number;\n}\n\nexport interface NetworkOptions extends Partial<NetworkStyle> {\n /** Node coordinates in degrees: lon0, lat0, lon1, lat1… */\n nodes: Float64Array;\n /** Edges as node index pairs: a0, b0, a1, b1… */\n edges: Uint32Array;\n /** Line of each edge, from A to B: the points of edge e are `points[start[e] .. start[e + 1]]` (lon, lat pairs,\n * counted in points); with fewer than two points an edge is straight. Default: all straight. */\n lines?: { start: Uint32Array; points: Float64Array };\n /** Per edge, the cost of travelling it from A to B then from B to A, in value units (Infinity: closed that way;\n * closed both ways: not drawn). A point along an edge then takes the quickest way there, min(value(A) + cost from\n * A, value(B) + cost from B), as a travel time does. Without costs, values are interpolated along the edges. */\n costs?: Float32Array;\n /** Width factor of each edge (default 1): rail lines wider than streets */\n edgeWidths?: Float32Array;\n}\n\nexport interface Tiles3dStyle {\n /** Screen-space error (CSS pixels) above which a tile is refined: 16 by default, lower is finer and heavier */\n maxScreenSpaceError: number;\n opacity: number;\n}\n\nexport interface Tiles3dOptions extends Partial<Tiles3dStyle> {\n /** URL of a `tileset.json` (3D Tiles 1.0 b3dm or 1.1 glb meshes, external tilesets) */\n url: string;\n}\n\nexport interface MapPointerEvent {\n point: Point;\n /** Undefined above the horizon */\n lonLat: LonLat | undefined;\n}\n\n/** What 'hoverfeature' found under the pointer */\nexport interface MapHoverFeatureEvent extends MapPointerEvent {\n /** The feature under the pointer (see `GeoMap.pickFeature`), undefined if none */\n hit: FeatureHit | undefined;\n}\n\n/** A picked feature: its layer handle, its index there and, for line, circle and fill layers, the feature itself */\nexport interface FeatureHit {\n layer: Layer;\n index: number;\n feature: Feature | undefined;\n}\n\nexport interface MapEvents {\n /** The camera started moving (a gesture, an animation or `setCamera`) */\n movestart: Camera;\n /** The camera moved */\n move: Camera;\n /** The camera stopped: no gesture held, no animation running */\n moveend: Camera;\n /** The map changed size (CSS pixels) */\n resize: { width: number; height: number };\n /** The pointer moved over the map (at most once per frame, not while dragging) */\n hover: MapPointerEvent;\n /** What is under the pointer, picked without stalling the GPU: a frame or two after 'hover', only while listened to\n * (radius and layers in `GeoMap.hoverPicking`) */\n hoverfeature: MapHoverFeatureEvent;\n /** Click without drag */\n click: MapPointerEvent;\n /** A frame was drawn; duration of the engine call in milliseconds */\n render: { ms: number };\n /** Everything in view is loaded and drawn, nothing moves: the end of a load, once after each change (as MapLibre's\n * `idle`). Tiles requested by the first frame count, so it never fires before they arrive. */\n idle: Record<string, never>;\n /** The pointer left the canvas (a mouse going out of the map, or onto a control or marker) */\n leave: Record<string, never>;\n}\n\n/** What a layer handle needs from its map */\nexport interface LayerHost {\n readonly engine: Engine;\n requestRender(): void;\n /** Forgets a removed layer */\n detach(layer: object): void;\n /** Moves a layer under `before`, or on top */\n moveLayer(layer: object, before: object | undefined): void;\n /** A layer created again in the engine (new id): put at the place of its old id, which is removed */\n replaceLayer(layer: object, old: number): void;\n}\n"]}
|
package/dist/vectorstyle.d.ts
CHANGED
|
@@ -25,7 +25,11 @@ export interface Style {
|
|
|
25
25
|
}>;
|
|
26
26
|
layers: StyleLayer[];
|
|
27
27
|
glyphs?: string;
|
|
28
|
-
sprite
|
|
28
|
+
/** One sprite's URL (without extension), or several with their ids (`id:name` names their images) */
|
|
29
|
+
sprite?: string | {
|
|
30
|
+
id: string;
|
|
31
|
+
url: string;
|
|
32
|
+
}[];
|
|
29
33
|
}
|
|
30
34
|
/** A raster source of a style: its tile URL, its deepest level and the CSS pixels of its tiles (MapLibre's
|
|
31
35
|
* `tileSize`: 512 by default) */
|
|
@@ -34,15 +38,40 @@ export interface RasterSource {
|
|
|
34
38
|
maxzoom: number;
|
|
35
39
|
tileSize: number;
|
|
36
40
|
}
|
|
41
|
+
/** How a label's text or icon meets the others (`*-allow-overlap` and `*-ignore-placement`, see `Overlap`) */
|
|
42
|
+
export type CandidateOverlap = boolean | 'allow' | 'ignore';
|
|
43
|
+
/** The icon of a label, in style terms evaluated at the tile's zoom */
|
|
44
|
+
export interface CandidateIcon {
|
|
45
|
+
/** Its image in the style's sprite */
|
|
46
|
+
image: string;
|
|
47
|
+
/** A number, or zoom stops */
|
|
48
|
+
size: Json;
|
|
49
|
+
anchor: string;
|
|
50
|
+
offset: [number, number];
|
|
51
|
+
rotate: number;
|
|
52
|
+
/** `map` or `viewport` (`auto` resolved) */
|
|
53
|
+
alignment: 'map' | 'viewport';
|
|
54
|
+
overlap: CandidateOverlap;
|
|
55
|
+
optional: boolean;
|
|
56
|
+
fit: 'none' | 'width' | 'height' | 'both';
|
|
57
|
+
padding: [number, number, number, number];
|
|
58
|
+
color: string;
|
|
59
|
+
opacity: number;
|
|
60
|
+
}
|
|
37
61
|
/** A label to shape and place, in style terms evaluated at the tile's zoom */
|
|
38
62
|
export interface LabelCandidate {
|
|
39
63
|
/** Index of its style layer: higher ones are placed first */
|
|
40
64
|
layer: number;
|
|
65
|
+
/** Its text, empty for an icon alone */
|
|
41
66
|
text: string;
|
|
42
67
|
lon: number;
|
|
43
68
|
lat: number;
|
|
44
|
-
/**
|
|
69
|
+
/** On a line: the direction there (degrees of longitude and latitude) */
|
|
45
70
|
along?: [number, number];
|
|
71
|
+
/** Its text runs along the line (`symbol-placement: line`, `text-rotation-alignment` not `viewport`) */
|
|
72
|
+
textAlong?: boolean;
|
|
73
|
+
textOptional?: boolean;
|
|
74
|
+
icon?: CandidateIcon;
|
|
46
75
|
font: string;
|
|
47
76
|
size: Json;
|
|
48
77
|
color: string;
|
|
@@ -52,7 +81,7 @@ export interface LabelCandidate {
|
|
|
52
81
|
offset: [number, number];
|
|
53
82
|
maxWidth: number;
|
|
54
83
|
lineHeight: number;
|
|
55
|
-
overlap:
|
|
84
|
+
overlap: CandidateOverlap;
|
|
56
85
|
}
|
|
57
86
|
/** What expressions see of a feature */
|
|
58
87
|
export interface Context {
|