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.
Files changed (93) hide show
  1. package/CHANGELOG.md +93 -0
  2. package/README.md +8 -4
  3. package/dist/animation.d.ts +18 -0
  4. package/dist/animation.js +84 -0
  5. package/dist/animation.js.map +1 -0
  6. package/dist/basemap.worker.d.ts +26 -4
  7. package/dist/basemap.worker.js +2 -2
  8. package/dist/basemap.worker.js.map +9 -5
  9. package/dist/crs.d.ts +72 -0
  10. package/dist/crs.js +243 -0
  11. package/dist/crs.js.map +1 -0
  12. package/dist/decoder.worker.js +4 -4
  13. package/dist/decoder.worker.js.map +4 -4
  14. package/dist/engine-loader.d.ts +28 -0
  15. package/dist/engine-loader.js +112 -0
  16. package/dist/engine-loader.js.map +1 -0
  17. package/dist/features.d.ts +8 -0
  18. package/dist/features.js +17 -10
  19. package/dist/features.js.map +1 -1
  20. package/dist/geo.d.ts +16 -0
  21. package/dist/geo.js +32 -0
  22. package/dist/geo.js.map +1 -0
  23. package/dist/geoplateforme.d.ts +21 -5
  24. package/dist/geoplateforme.js +47 -12
  25. package/dist/geoplateforme.js.map +1 -1
  26. package/dist/glyphs.d.ts +13 -3
  27. package/dist/glyphs.js +26 -4
  28. package/dist/glyphs.js.map +1 -1
  29. package/dist/gpx.d.ts +11 -0
  30. package/dist/gpx.js +74 -0
  31. package/dist/gpx.js.map +1 -0
  32. package/dist/grid.d.ts +81 -0
  33. package/dist/grid.js +270 -0
  34. package/dist/grid.js.map +1 -0
  35. package/dist/icons.d.ts +146 -0
  36. package/dist/icons.js +333 -0
  37. package/dist/icons.js.map +1 -0
  38. package/dist/index.d.ts +11 -4
  39. package/dist/index.js +6 -1
  40. package/dist/index.js.map +1 -1
  41. package/dist/interaction.d.ts +0 -4
  42. package/dist/interaction.js +8 -4
  43. package/dist/interaction.js.map +1 -1
  44. package/dist/isard_bg.wasm +0 -0
  45. package/dist/isard_core_bg.wasm +0 -0
  46. package/dist/kml.d.ts +12 -0
  47. package/dist/kml.js +159 -0
  48. package/dist/kml.js.map +1 -0
  49. package/dist/layers.d.ts +89 -2
  50. package/dist/layers.js +171 -15
  51. package/dist/layers.js.map +1 -1
  52. package/dist/lru.d.ts +22 -0
  53. package/dist/lru.js +52 -0
  54. package/dist/lru.js.map +1 -0
  55. package/dist/map.d.ts +45 -7
  56. package/dist/map.js +138 -310
  57. package/dist/map.js.map +1 -1
  58. package/dist/resample.d.ts +41 -0
  59. package/dist/resample.js +164 -0
  60. package/dist/resample.js.map +1 -0
  61. package/dist/settings.d.ts +39 -0
  62. package/dist/settings.js +104 -0
  63. package/dist/settings.js.map +1 -0
  64. package/dist/symbols.d.ts +54 -9
  65. package/dist/symbols.js +278 -55
  66. package/dist/symbols.js.map +1 -1
  67. package/dist/terrain.d.ts +19 -7
  68. package/dist/terrain.js +40 -28
  69. package/dist/terrain.js.map +1 -1
  70. package/dist/topojson.d.ts +29 -0
  71. package/dist/topojson.js +66 -0
  72. package/dist/topojson.js.map +1 -0
  73. package/dist/types.d.ts +14 -6
  74. package/dist/types.js.map +1 -1
  75. package/dist/vectorstyle.d.ts +32 -3
  76. package/dist/vectorstyle.js.map +1 -1
  77. package/dist/vectortiles.d.ts +19 -7
  78. package/dist/vectortiles.js +117 -69
  79. package/dist/vectortiles.js.map +1 -1
  80. package/dist/wasm/isard.d.ts +55 -7
  81. package/dist/wasm/isard.js +117 -6
  82. package/dist/wasm/isard_core.d.ts +29 -4
  83. package/dist/wasm/isard_core.js +84 -5
  84. package/dist/wmts.d.ts +14 -0
  85. package/dist/wmts.js +76 -0
  86. package/dist/wmts.js.map +1 -0
  87. package/dist/xml.d.ts +26 -0
  88. package/dist/xml.js +109 -0
  89. package/dist/xml.js.map +1 -0
  90. package/package.json +1 -1
  91. package/dist/equirectangular.d.ts +0 -35
  92. package/dist/equirectangular.js +0 -143
  93. package/dist/equirectangular.js.map +0 -1
@@ -0,0 +1,28 @@
1
+ import { TileLoader } from './loader.ts';
2
+ import type { GeoMapOptions } from './types.ts';
3
+ import type { Camera, Engine } from './wasm/isard.js';
4
+ /** The class of an engine build: its constructor and its static `customMatrix` (custom layers) */
5
+ export type EngineClass = (new (canvas: HTMLCanvasElement, redraw: () => void) => Engine) & Pick<typeof Engine, 'customMatrix'>;
6
+ /** An engine loaded: its compiled module and its class */
7
+ export interface Bindings {
8
+ module: WebAssembly.Module;
9
+ Engine: EngineClass;
10
+ }
11
+ /** `core`: the engine without 3D Tiles; `full`: with them */
12
+ export type EngineKind = 'core' | 'full';
13
+ /** Where a build of the engine is loaded from: the option, or next to the module */
14
+ export declare function engineUrl(kind: EngineKind, options: Pick<GeoMapOptions, 'wasmUrl' | 'coreWasmUrl'>): string | URL;
15
+ /** A build compiled and instantiated with its bindings (once per page, unless it failed) */
16
+ export declare function loadEngine(kind: EngineKind, url: string | URL): Promise<Bindings>;
17
+ /** The full engine for a map on the core one, resolved in a task of its own, not in the one that instantiated it:
18
+ * the map rebuilt on it there, two shorter tasks */
19
+ export declare function loadFullEngineLater(url: string | URL): Promise<Bindings>;
20
+ /** Downloads and compiles the full engine when the page is idle, without running it; a failure is left to the first
21
+ * 3D Tiles layer, which tries again */
22
+ export declare function preloadFullEngine(url: string | URL, wanted: () => boolean): void;
23
+ /** The decoding workers of 3D Tiles, running the full engine's module, unless turned off (`workers: false` or 0, or
24
+ * no workers in this environment) */
25
+ export declare function startTileLoader(module: WebAssembly.Module, options: Pick<GeoMapOptions, 'workers' | 'workerUrl' | 'decoders'>, engine: Engine): TileLoader | undefined;
26
+ /** The engine of a destroyed map: every method a no-op returning undefined, but the camera (the last one) and the
27
+ * bounds, which late callers read */
28
+ export declare function destroyedEngine(camera: Camera): Engine;
@@ -0,0 +1,112 @@
1
+ /**
2
+ * The two builds of the engine, downloaded, compiled and instantiated once per page; the decoding workers of 3D Tiles
3
+ * that run the full one; the engine of a destroyed map.
4
+ */
5
+ import { DEFAULT_DECODERS } from "./decoders.js";
6
+ import { TileLoader } from "./loader.js";
7
+ import { defaultWorkerCount } from "./vectortiles.js";
8
+ /** The two builds of the engine, each compiled once per page: `core` without 3D Tiles (a third smaller), loaded by
9
+ * every map; `full` with them, loaded for the first 3D Tiles layer, its module shared with the decoding workers. The
10
+ * core engine has the same API but the 3D Tiles methods: its class is typed as the full one. */
11
+ const engines = {};
12
+ /** The modules compiled (downloaded and compiled off the main thread, not instantiated): `tiles3d: 'preload'`
13
+ * compiles the full engine ahead, its first 3D Tiles layer then only instantiates it */
14
+ const modules = {};
15
+ /** @internal Forgets the engines loaded (tests) */
16
+ export function forgetEngines() {
17
+ for (const kind of ['core', 'full']) {
18
+ delete engines[kind];
19
+ delete modules[kind];
20
+ }
21
+ }
22
+ /** Where a build of the engine is loaded from: the option, or next to the module */
23
+ export function engineUrl(kind, options) {
24
+ return kind === 'full'
25
+ ? (options.wasmUrl ?? new URL('./isard_bg.wasm', import.meta.url))
26
+ : (options.coreWasmUrl ?? new URL('./isard_core_bg.wasm', import.meta.url));
27
+ }
28
+ /** Downloads and compiles a build (once per page, unless it failed: a later call tries again) */
29
+ function compileEngine(kind, url) {
30
+ const compiled = modules[kind];
31
+ if (compiled)
32
+ return compiled;
33
+ const compiling = compile(url).catch((error) => {
34
+ // A later call tries again (a network error, a wrong URL fixed)
35
+ delete modules[kind];
36
+ throw error;
37
+ });
38
+ modules[kind] = compiling;
39
+ return compiling;
40
+ }
41
+ /** A build compiled and instantiated with its bindings (once per page, unless it failed) */
42
+ export function loadEngine(kind, url) {
43
+ const loaded = engines[kind];
44
+ if (loaded)
45
+ return loaded;
46
+ const loading = (async () => {
47
+ // The bindings by dynamic import: an application bundles the ones it loads only
48
+ const [module, bindings] = await Promise.all([
49
+ compileEngine(kind, url),
50
+ kind === 'core' ? import('./wasm/isard_core.js') : import('./wasm/isard.js'),
51
+ ]);
52
+ await bindings.default({ module_or_path: module });
53
+ return { module, Engine: bindings.Engine };
54
+ })().catch((error) => {
55
+ delete engines[kind];
56
+ throw error;
57
+ });
58
+ engines[kind] = loading;
59
+ return loading;
60
+ }
61
+ /** The full engine for a map on the core one, resolved in a task of its own, not in the one that instantiated it:
62
+ * the map rebuilt on it there, two shorter tasks */
63
+ export function loadFullEngineLater(url) {
64
+ return loadEngine('full', url).then((bindings) => new Promise((resolve) => setTimeout(() => resolve(bindings), 0)));
65
+ }
66
+ /** Downloads and compiles the full engine when the page is idle, without running it; a failure is left to the first
67
+ * 3D Tiles layer, which tries again */
68
+ export function preloadFullEngine(url, wanted) {
69
+ const start = () => {
70
+ if (wanted())
71
+ compileEngine('full', url).catch(() => undefined);
72
+ };
73
+ if (typeof requestIdleCallback === 'function')
74
+ requestIdleCallback(start, { timeout: 2000 });
75
+ else
76
+ setTimeout(start, 0);
77
+ }
78
+ async function compile(url) {
79
+ const response = await fetch(url);
80
+ if (!response.ok)
81
+ throw new Error(`isard: failed to load the engine from ${url}: ${response.status}`);
82
+ try {
83
+ return await WebAssembly.compileStreaming(response.clone());
84
+ }
85
+ catch {
86
+ // Servers that do not send application/wasm
87
+ return WebAssembly.compile(await response.arrayBuffer());
88
+ }
89
+ }
90
+ /** The decoding workers of 3D Tiles, running the full engine's module, unless turned off (`workers: false` or 0, or
91
+ * no workers in this environment) */
92
+ export function startTileLoader(module, options, engine) {
93
+ const { workers: count, workerUrl, decoders } = options;
94
+ const workers = count ?? defaultWorkerCount();
95
+ if (workers === false || workers <= 0 || typeof Worker === 'undefined')
96
+ return undefined;
97
+ return new TileLoader(module, workerUrl ?? new URL('./decoder.worker.js', import.meta.url), workers, { ...DEFAULT_DECODERS, ...decoders }, engine.textureFormats());
98
+ }
99
+ /** The engine of a destroyed map: every method a no-op returning undefined, but the camera (the last one) and the
100
+ * bounds, which late callers read */
101
+ export function destroyedEngine(camera) {
102
+ return new Proxy({}, {
103
+ get: (_, name) => {
104
+ if (name === 'camera')
105
+ return () => camera;
106
+ if (name === 'bounds')
107
+ return () => Float64Array.of(-180, -85, 180, 85);
108
+ return () => undefined;
109
+ },
110
+ });
111
+ }
112
+ //# sourceMappingURL=engine-loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine-loader.js","sourceRoot":"","sources":["../src/engine-loader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAmBtD;;gGAEgG;AAChG,MAAM,OAAO,GAA2D,EAAE,CAAC;AAC3E;wFACwF;AACxF,MAAM,OAAO,GAA+E,EAAE,CAAC;AAE/F,mDAAmD;AACnD,MAAM,UAAU,aAAa;IAC3B,KAAK,MAAM,IAAI,IAAI,CAAC,MAAM,EAAE,MAAM,CAAU,EAAE,CAAC;QAC7C,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC;QACrB,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,CAAC;AACH,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,SAAS,CAAC,IAAgB,EAAE,OAAuD;IACjG,OAAO,IAAI,KAAK,MAAM;QACpB,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,IAAI,IAAI,GAAG,CAAC,iBAAiB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAClE,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,IAAI,IAAI,GAAG,CAAC,sBAAsB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAChF,CAAC;AAED,iGAAiG;AACjG,SAAS,aAAa,CAAC,IAAgB,EAAE,GAAiB;IACxD,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAC9B,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAA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CAAC;IAC9C,IAAI,OAAO,KAAK,KAAK,IAAI,OAAO,IAAI,CAAC,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE,OAAO,SAAS,CAAC;IACzF,OAAO,IAAI,UAAU,CACnB,MAAM,EACN,SAAS,IAAI,IAAI,GAAG,CAAC,qBAAqB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAC5D,OAAO,EACP,EAAE,GAAG,gBAAgB,EAAE,GAAG,QAAQ,EAAE,EACpC,MAAM,CAAC,cAAc,EAAE,CACxB,CAAC;AACJ,CAAC;AAED;qCACqC;AACrC,MAAM,UAAU,eAAe,CAAC,MAAc;IAC5C,OAAO,IAAI,KAAK,CACd,EAAE,EACF;QACE,GAAG,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE;YACf,IAAI,IAAI,KAAK,QAAQ;gBAAE,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC;YAC3C,IAAI,IAAI,KAAK,QAAQ;gBAAE,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;YACxE,OAAO,GAAG,EAAE,CAAC,SAAS,CAAC;QACzB,CAAC;KACF,CACQ,CAAC;AACd,CAAC","sourcesContent":["/**\n * The two builds of the engine, downloaded, compiled and instantiated once per page; the decoding workers of 3D Tiles\n * that run the full one; the engine of a destroyed map.\n */\nimport { DEFAULT_DECODERS } from './decoders.ts';\nimport { TileLoader } from './loader.ts';\nimport type { GeoMapOptions } from './types.ts';\nimport { defaultWorkerCount } from './vectortiles.ts';\nimport type { Camera, Engine } from './wasm/isard.js';\n\n/** The class of an engine build: its constructor and its static `customMatrix` (custom layers) */\nexport type EngineClass = (new (\n canvas: HTMLCanvasElement,\n redraw: () => void,\n) => Engine) &\n Pick<typeof Engine, 'customMatrix'>;\n\n/** An engine loaded: its compiled module and its class */\nexport interface Bindings {\n module: WebAssembly.Module;\n Engine: EngineClass;\n}\n\n/** `core`: the engine without 3D Tiles; `full`: with them */\nexport type EngineKind = 'core' | 'full';\n\n/** The two builds of the engine, each compiled once per page: `core` without 3D Tiles (a third smaller), loaded by\n * every map; `full` with them, loaded for the first 3D Tiles layer, its module shared with the decoding workers. The\n * core engine has the same API but the 3D Tiles methods: its class is typed as the full one. */\nconst engines: { core?: Promise<Bindings>; full?: Promise<Bindings> } = {};\n/** The modules compiled (downloaded and compiled off the main thread, not instantiated): `tiles3d: 'preload'`\n * compiles the full engine ahead, its first 3D Tiles layer then only instantiates it */\nconst modules: { core?: Promise<WebAssembly.Module>; full?: Promise<WebAssembly.Module> } = {};\n\n/** @internal Forgets the engines loaded (tests) */\nexport function forgetEngines(): void {\n for (const kind of ['core', 'full'] as const) {\n delete engines[kind];\n delete modules[kind];\n }\n}\n\n/** Where a build of the engine is loaded from: the option, or next to the module */\nexport function engineUrl(kind: EngineKind, options: Pick<GeoMapOptions, 'wasmUrl' | 'coreWasmUrl'>): string | URL {\n return kind === 'full'\n ? (options.wasmUrl ?? new URL('./isard_bg.wasm', import.meta.url))\n : (options.coreWasmUrl ?? new URL('./isard_core_bg.wasm', import.meta.url));\n}\n\n/** Downloads and compiles a build (once per page, unless it failed: a later call tries again) */\nfunction compileEngine(kind: EngineKind, url: string | URL): Promise<WebAssembly.Module> {\n const compiled = modules[kind];\n if (compiled) return compiled;\n const compiling = compile(url).catch((error: unknown) => {\n // A later call tries again (a network error, a wrong URL fixed)\n delete modules[kind];\n throw error;\n });\n modules[kind] = compiling;\n return compiling;\n}\n\n/** A build compiled and instantiated with its bindings (once per page, unless it failed) */\nexport function loadEngine(kind: EngineKind, url: string | URL): Promise<Bindings> {\n const loaded = engines[kind];\n if (loaded) return loaded;\n const loading = (async () => {\n // The bindings by dynamic import: an application bundles the ones it loads only\n const [module, bindings] = await Promise.all([\n compileEngine(kind, url),\n kind === 'core' ? import('./wasm/isard_core.js') : import('./wasm/isard.js'),\n ]);\n await bindings.default({ module_or_path: module });\n return { module, Engine: bindings.Engine as unknown as EngineClass };\n })().catch((error: unknown) => {\n delete engines[kind];\n throw error;\n });\n engines[kind] = loading;\n return loading;\n}\n\n/** The full engine for a map on the core one, resolved in a task of its own, not in the one that instantiated it:\n * the map rebuilt on it there, two shorter tasks */\nexport function loadFullEngineLater(url: string | URL): Promise<Bindings> {\n return loadEngine('full', url).then(\n (bindings) => new Promise<Bindings>((resolve) => setTimeout(() => resolve(bindings), 0)),\n );\n}\n\n/** Downloads and compiles the full engine when the page is idle, without running it; a failure is left to the first\n * 3D Tiles layer, which tries again */\nexport function preloadFullEngine(url: string | URL, wanted: () => boolean): void {\n const start = () => {\n if (wanted()) compileEngine('full', url).catch(() => undefined);\n };\n if (typeof requestIdleCallback === 'function') requestIdleCallback(start, { timeout: 2000 });\n else setTimeout(start, 0);\n}\n\nasync function compile(url: string | URL): Promise<WebAssembly.Module> {\n const response = await fetch(url);\n if (!response.ok) throw new Error(`isard: failed to load the engine from ${url}: ${response.status}`);\n try {\n return await WebAssembly.compileStreaming(response.clone());\n } catch {\n // Servers that do not send application/wasm\n return WebAssembly.compile(await response.arrayBuffer());\n }\n}\n\n/** The decoding workers of 3D Tiles, running the full engine's module, unless turned off (`workers: false` or 0, or\n * no workers in this environment) */\nexport function startTileLoader(\n module: WebAssembly.Module,\n options: Pick<GeoMapOptions, 'workers' | 'workerUrl' | 'decoders'>,\n engine: Engine,\n): TileLoader | undefined {\n const { workers: count, workerUrl, decoders } = options;\n const workers = count ?? defaultWorkerCount();\n if (workers === false || workers <= 0 || typeof Worker === 'undefined') return undefined;\n return new TileLoader(\n module,\n workerUrl ?? new URL('./decoder.worker.js', import.meta.url),\n workers,\n { ...DEFAULT_DECODERS, ...decoders },\n engine.textureFormats(),\n );\n}\n\n/** The engine of a destroyed map: every method a no-op returning undefined, but the camera (the last one) and the\n * bounds, which late callers read */\nexport function destroyedEngine(camera: Camera): Engine {\n return new Proxy(\n {},\n {\n get: (_, name) => {\n if (name === 'camera') return () => camera;\n if (name === 'bounds') return () => Float64Array.of(-180, -85, 180, 85);\n return () => undefined;\n },\n },\n ) as Engine;\n}\n"]}
@@ -38,6 +38,14 @@ export interface Feature<P = Properties> {
38
38
  export interface FeatureCollection<P = Properties> {
39
39
  type: 'FeatureCollection';
40
40
  features: Feature<P>[];
41
+ /** The CRS of the coordinates, a legacy member (GeoJSON of 2008, the output of a WFS in another CRS): the feature
42
+ * layers reproject a collection that names one (see `reproject`) */
43
+ crs?: {
44
+ type: 'name';
45
+ properties: {
46
+ name: string;
47
+ };
48
+ };
41
49
  }
42
50
  /** What a feature layer takes: a collection, its features, or one feature */
43
51
  export type FeatureData<P = Properties> = FeatureCollection<P> | Feature<P>[] | Feature<P>;
package/dist/features.js CHANGED
@@ -5,6 +5,8 @@
5
5
  * textures, and restyling, recoloring by values or filtering never touches the geometry.
6
6
  */
7
7
  import { parseCssColor } from "./color.js";
8
+ import { crsOf, reproject } from "./crs.js";
9
+ import { mercatorX, mercatorY } from "./geo.js";
8
10
  import { Layer } from "./layers.js";
9
11
  const BASE = {
10
12
  opacity: 1,
@@ -79,16 +81,21 @@ export function evaluate(value, properties, index) {
79
81
  return typeof value === 'function' ? value(properties, index) : value;
80
82
  }
81
83
  // ── Geometry ──
82
- const MAX_LAT = 85.051128779806589;
83
- const mercX = (lon) => (lon + 180) / 360;
84
- const mercY = (lat) => {
85
- const phi = (Math.max(-MAX_LAT, Math.min(MAX_LAT, lat)) * Math.PI) / 180;
86
- return 0.5 - Math.log(Math.tan(Math.PI / 4 + phi / 2)) / (2 * Math.PI);
87
- };
84
+ /** Collections in another CRS, reprojected once (the layers read their data again) */
85
+ const reprojected = new WeakMap();
88
86
  export function featuresOf(data) {
89
87
  if (Array.isArray(data))
90
88
  return data;
91
- return data.type === 'FeatureCollection' ? data.features : [data];
89
+ if (data.type !== 'FeatureCollection')
90
+ return [data];
91
+ if (crsOf(data) === undefined)
92
+ return data.features;
93
+ let features = reprojected.get(data);
94
+ if (!features) {
95
+ features = reproject(data).features;
96
+ reprojected.set(data, features);
97
+ }
98
+ return features;
92
99
  }
93
100
  /** Every geometry of a feature, collections flattened */
94
101
  function* geometries(geometry) {
@@ -129,7 +136,7 @@ function lineGeometry(features) {
129
136
  start.push(points.length / 2);
130
137
  feature.push(f);
131
138
  for (const [lon, lat] of coords)
132
- points.push(mercX(lon), mercY(lat));
139
+ points.push(mercatorX(lon), mercatorY(lat));
133
140
  };
134
141
  features.forEach((f, i) => {
135
142
  for (const g of geometries(f.geometry)) {
@@ -154,7 +161,7 @@ function pointGeometry(features) {
154
161
  const points = new Grow(new Float64Array(1024));
155
162
  const feature = new Grow(new Uint32Array(64));
156
163
  const point = ([lon, lat], f) => {
157
- points.push(mercX(lon), mercY(lat));
164
+ points.push(mercatorX(lon), mercatorY(lat));
158
165
  feature.push(f);
159
166
  };
160
167
  features.forEach((f, i) => {
@@ -179,7 +186,7 @@ export function polygonGeometry(features) {
179
186
  for (const ring of rings) {
180
187
  ringStart.push(points.length / 2);
181
188
  for (const [lon, lat] of ring)
182
- points.push(mercX(lon), mercY(lat));
189
+ points.push(mercatorX(lon), mercatorY(lat));
183
190
  }
184
191
  };
185
192
  features.forEach((f, i) => {
@@ -1 +1 @@
1
- {"version":3,"file":"features.js","sourceRoot":"","sources":["../src/features.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAgGpC,MAAM,IAAI,GAAsB;IAC9B,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,EAAE;IACX,OAAO,EAAE,IAAI;IACb,MAAM,EAAE,SAAS;IACjB,IAAI,EAAE,SAAS;CAChB,CAAC;AAEF,eAAe;AAEf,iFAAiF;AACjF,MAAM,UAAU,UAAU,CAAC,KAAa;IACtC,OAAO,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE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S,EAAE,CAAC,CAAC,YAAY,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC;IACxE,CAAC;IAES,YAAY,CAAC,UAAa,EAAE,KAAa;QACjD,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACvE,CAAC;IAES,UAAU,KAAU,CAAC;CAChC;AAED,MAAM,UAAU,SAAS,CAAI,OAAuB;IAClD,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IACjD,OAAO,EAAE,GAAI,IAA6B,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,CAAC;AAClG,CAAC;AAED,MAAM,UAAU,WAAW,CAAI,OAAyB;IACtD,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IACjD,OAAO;QACL,GAAI,IAA6B;QACjC,KAAK,EAAE,MAAM;QACb,MAAM,EAAE,CAAC;QACT,WAAW,EAAE,MAAM;QACnB,WAAW,EAAE,CAAC;QACd,SAAS,EAAE,UAAU;QACrB,GAAG,IAAI;KACR,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,SAAS,CAAI,OAAuB;IAClD,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IACjD,OAAO,EAAE,GAAI,IAA6B,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,CAAC;AACvE,CAAC","sourcesContent":["/**\n * Feature layers: lines, circles and fills from GeoJSON, styled per feature. A style value is a constant, zoom stops\n * (`[[zoom, value], …]`, linear in between, as MapLibre's `interpolate linear zoom`), or a function of the feature\n * returning either, evaluated once per feature when the data or the style change: the engine keeps the result in\n * textures, and restyling, recoloring by values or filtering never touches the geometry.\n */\n\nimport { parseCssColor } from './color.ts';\nimport { Layer } from './layers.ts';\nimport type { LayerHost } from './types.ts';\nimport type { Engine } from './wasm/isard.js';\n\n// ── GeoJSON (the parts used here) ──\n\nexport type Position = [lon: number, lat: number, ...rest: number[]];\nexport type Geometry =\n | { type: 'Point'; coordinates: Position }\n | { type: 'MultiPoint'; coordinates: Position[] }\n | { type: 'LineString'; coordinates: Position[] }\n | { type: 'MultiLineString'; coordinates: Position[][] }\n | { type: 'Polygon'; coordinates: Position[][] }\n | { type: 'MultiPolygon'; coordinates: Position[][][] }\n | { type: 'GeometryCollection'; geometries: Geometry[] };\nexport type Properties = Record<string, unknown>;\nexport interface Feature<P = Properties> {\n type: 'Feature';\n geometry: Geometry | null;\n properties: P;\n id?: string | number;\n}\nexport interface FeatureCollection<P = Properties> {\n type: 'FeatureCollection';\n features: Feature<P>[];\n}\n/** What a feature layer takes: a collection, its features, or one feature */\nexport type FeatureData<P = Properties> = FeatureCollection<P> | Feature<P>[] | Feature<P>;\n\n// ── Style values ──\n\n/** Zoom stops: `[[zoom, value], …]` in increasing zooms, up to four, linear in between, constant outside */\nexport type Stops = [zoom: number, value: number][];\n/** A size: CSS pixels, or zoom stops */\nexport type Size = number | Stops;\n/** A value for all features, or a function of each feature (its properties and its index in the data) */\nexport type Styled<T, P = Properties> = T | ((properties: P, index: number) => T);\n/** Colors of values: `[[value, color], …]` in increasing values, linear in between */\nexport type Ramp = [value: number, color: string][];\n\nexport interface FeatureLayerStyle<P = Properties> {\n /** Layer opacity, 0 to 1, or zoom stops (a layer fading in past a zoom) (default 1) */\n opacity: Size;\n /** Zooms the layer shows in: from `minZoom` (included) to `maxZoom` (excluded) */\n minZoom: number;\n maxZoom: number;\n visible: boolean;\n /** Features drawn; the others hidden (default all) */\n filter: ((properties: P, index: number) => boolean) | undefined;\n /** Colors of the values given by `setValues`: a feature with a value takes its color here, the others keep theirs */\n ramp: Ramp | undefined;\n}\n\nexport interface LineStyle<P = Properties> extends FeatureLayerStyle<P> {\n /** CSS color: `#rgb`, `#rrggbb`, `#rrggbbaa`, `rgb()`, `rgba()` (default `#000`) */\n color: Styled<string, P>;\n /** CSS pixels (default 1) */\n width: Styled<Size, P>;\n /** Dash and gap, in line widths (MapLibre's `line-dasharray`); undefined: solid */\n dash: [dash: number, gap: number] | undefined;\n}\n\nexport interface CircleStyle<P = Properties> extends FeatureLayerStyle<P> {\n color: Styled<string, P>;\n /** CSS pixels (default 5) */\n radius: Styled<Size, P>;\n strokeColor: Styled<string, P>;\n /** CSS pixels (default 0) */\n strokeWidth: Styled<Size, P>;\n /** `'viewport'` (default): discs facing the screen; `'map'`: lying on the ground (MapLibre's\n * `circle-pitch-alignment`) */\n alignment: 'viewport' | 'map';\n}\n\nexport interface FillStyle<P = Properties> extends FeatureLayerStyle<P> {\n color: Styled<string, P>;\n}\n\n/** Where a new layer goes: under `before`, or on top of the others */\nexport interface Placement {\n before?: Layer;\n}\n\nexport interface LineOptions<P = Properties> extends Partial<LineStyle<P>>, Placement {\n /** LineString and MultiLineString features; the rings of Polygon and MultiPolygon features are drawn as lines */\n data: FeatureData<P>;\n}\nexport interface CircleOptions<P = Properties> extends Partial<CircleStyle<P>>, Placement {\n /** Point and MultiPoint features */\n data: FeatureData<P>;\n}\nexport interface FillOptions<P = Properties> extends Partial<FillStyle<P>>, Placement {\n /** Polygon and MultiPolygon features */\n data: FeatureData<P>;\n}\n\nconst BASE: FeatureLayerStyle = {\n opacity: 1,\n minZoom: 0,\n maxZoom: 24,\n visible: true,\n filter: undefined,\n ramp: undefined,\n};\n\n// ── Colors ──\n\n/** A CSS color to RGBA 0-1 (see `parseCssColor`); black if unknown or missing */\nexport function parseColor(color: string): [r: number, g: number, b: number, a: number] {\n return parseCssColor(color) ?? [0, 0, 0, 1];\n}\n\n/** 256 RGBA texels of a ramp over its value range, and that range */\nexport function rampTexels(ramp: Ramp): { rgba: Uint8Array; min: number; max: number } {\n const stops = ramp.map(([v, c]) => [v, parseColor(c)] as const).sort((a, b) => a[0] - b[0]);\n const min = stops[0]?.[0] ?? 0;\n const max = stops.at(-1)?.[0] ?? 1;\n const rgba = new Uint8Array(256 * 4);\n for (let i = 0; i < 256; i += 1) {\n const v = min + ((max - min) * i) / 255;\n let k = 0;\n while (k + 1 < stops.length && (stops[k + 1]?.[0] ?? 0) < v) k += 1;\n const [v0, c0] = stops[k] ?? [min, [0, 0, 0, 1]];\n const [v1, c1] = stops[k + 1] ?? [v0, c0];\n const t = v1 > v0 ? Math.max(0, Math.min(1, (v - v0) / (v1 - v0))) : 0;\n for (let j = 0; j < 4; j += 1)\n rgba[i * 4 + j] = Math.round(((c0[j] ?? 0) + ((c1[j] ?? 0) - (c0[j] ?? 0)) * t) * 255);\n }\n return { rgba, min, max };\n}\n\n/** Up to four stops as zooms then values, constant if a number */\nexport function stops(size: Size): [number, number, number, number, number, number, number, number] {\n if (!Array.isArray(size)) {\n // A style function may return nothing for a feature without the property: 0\n const v = Number.isFinite(size) ? size : 0;\n return [0, 0, 0, 0, v, v, v, v];\n }\n // More than four: resampled at four zooms over their range\n let s = size;\n if (s.length > 4) {\n const z0 = s[0]?.[0] ?? 0;\n const z1 = s.at(-1)?.[0] ?? 0;\n s = [0, 1, 2, 3].map((k): [number, number] => {\n const z = z0 + ((z1 - z0) * k) / 3;\n return [z, interpolate(size, z)];\n });\n }\n const at = (k: number) => s[Math.min(k, s.length - 1)] ?? [0, 0];\n return [at(0)[0], at(1)[0], at(2)[0], at(3)[0], at(0)[1], at(1)[1], at(2)[1], at(3)[1]];\n}\n\n/** Value of zoom stops at a zoom */\nexport function interpolate(size: Size, zoom: number): number {\n if (typeof size === 'number') return size;\n const first = size[0];\n if (!first) return 0;\n if (zoom <= first[0]) return first[1];\n for (let k = 1; k < size.length; k += 1) {\n const [z0, v0] = size[k - 1] ?? first;\n const [z1, v1] = size[k] ?? first;\n if (zoom <= z1) return v0 + ((v1 - v0) * (zoom - z0)) / Math.max(z1 - z0, 1e-9);\n }\n return size.at(-1)?.[1] ?? 0;\n}\n\nexport function evaluate<T, P>(value: Styled<T, P>, properties: P, index: number): T {\n return typeof value === 'function' ? (value as (p: P, i: number) => T)(properties, index) : value;\n}\n\n// ── Geometry ──\n\nconst MAX_LAT = 85.051128779806589;\nconst mercX = (lon: number) => (lon + 180) / 360;\nconst mercY = (lat: number) => {\n const phi = (Math.max(-MAX_LAT, Math.min(MAX_LAT, lat)) * Math.PI) / 180;\n return 0.5 - Math.log(Math.tan(Math.PI / 4 + phi / 2)) / (2 * Math.PI);\n};\n\nexport function featuresOf<P>(data: FeatureData<P>): Feature<P>[] {\n if (Array.isArray(data)) return data;\n return data.type === 'FeatureCollection' ? data.features : [data];\n}\n\n/** Every geometry of a feature, collections flattened */\nfunction* geometries(geometry: Geometry | null): Generator<Geometry> {\n if (!geometry) return;\n if (geometry.type === 'GeometryCollection') for (const g of geometry.geometries) yield* geometries(g);\n else yield geometry;\n}\n\n/** A growable typed array */\nclass Grow<T extends Float64Array | Uint32Array> {\n length = 0;\n constructor(public data: T) {}\n push(...values: number[]): void {\n if (this.length + values.length > this.data.length) {\n const next = new (this.data.constructor as new (n: number) => T)(\n Math.max(16, this.data.length * 2, this.length + values.length),\n );\n next.set(this.data);\n this.data = next;\n }\n for (const v of values) this.data[this.length++] = v;\n }\n done(): T {\n return this.data.subarray(0, this.length) as T;\n }\n}\n\n/** Lines of the features: points (Mercator), first point of each line, feature of each line */\nfunction lineGeometry(features: Feature<unknown>[]) {\n const points = new Grow(new Float64Array(1024));\n const start = new Grow(new Uint32Array(64));\n const feature = new Grow(new Uint32Array(64));\n const line = (coords: Position[], f: number) => {\n start.push(points.length / 2);\n feature.push(f);\n for (const [lon, lat] of coords) points.push(mercX(lon), mercY(lat));\n };\n features.forEach((f, i) => {\n for (const g of geometries(f.geometry)) {\n if (g.type === 'LineString') line(g.coordinates, i);\n else if (g.type === 'MultiLineString') for (const l of g.coordinates) line(l, i);\n else if (g.type === 'Polygon') for (const r of g.coordinates) line(r, i);\n else if (g.type === 'MultiPolygon') for (const p of g.coordinates) for (const r of p) line(r, i);\n }\n });\n start.push(points.length / 2);\n return { points: points.done(), start: start.done(), feature: feature.done() };\n}\n\nfunction pointGeometry(features: Feature<unknown>[]) {\n const points = new Grow(new Float64Array(1024));\n const feature = new Grow(new Uint32Array(64));\n const point = ([lon, lat]: Position, f: number) => {\n points.push(mercX(lon), mercY(lat));\n feature.push(f);\n };\n features.forEach((f, i) => {\n for (const g of geometries(f.geometry)) {\n if (g.type === 'Point') point(g.coordinates, i);\n else if (g.type === 'MultiPoint') for (const p of g.coordinates) point(p, i);\n }\n });\n return { points: points.done(), feature: feature.done() };\n}\n\nexport function polygonGeometry(features: Feature<unknown>[]) {\n const points = new Grow(new Float64Array(1024));\n const ringStart = new Grow(new Uint32Array(64));\n const polygonStart = new Grow(new Uint32Array(64));\n const feature = new Grow(new Uint32Array(64));\n const polygon = (rings: Position[][], f: number) => {\n polygonStart.push(ringStart.length);\n feature.push(f);\n for (const ring of rings) {\n ringStart.push(points.length / 2);\n for (const [lon, lat] of ring) points.push(mercX(lon), mercY(lat));\n }\n };\n features.forEach((f, i) => {\n for (const g of geometries(f.geometry)) {\n if (g.type === 'Polygon') polygon(g.coordinates, i);\n else if (g.type === 'MultiPolygon') for (const p of g.coordinates) polygon(p, i);\n }\n });\n ringStart.push(points.length / 2);\n polygonStart.push(ringStart.length - 1);\n return {\n points: points.done(),\n ringStart: ringStart.done(),\n polygonStart: polygonStart.done(),\n feature: feature.done(),\n };\n}\n\n// ── Layers ──\n\n/** Floats per feature in the engine's style (see `setFeatureStyle`) */\nexport const FLOATS = 32;\n\n/** What every feature layer shares: its data, its style in the engine, values, filter */\nexport abstract class FeatureLayer<P, S extends FeatureLayerStyle<P>> extends Layer {\n protected list: Feature<P>[];\n protected values: Float32Array | undefined;\n\n /** @internal */\n constructor(\n map: LayerHost,\n data: FeatureData<P>,\n protected style: S,\n ) {\n super(map);\n this.list = featuresOf(data);\n }\n\n /** The features, in the order of the data (their index is what `pick` returns) */\n get features(): readonly Feature<P>[] {\n return this.list;\n }\n\n /** The feature of a picked index */\n featureAt(index: number): Feature<P> | undefined {\n return this.list[index];\n }\n\n /** Replaces the features; the style is evaluated again for them */\n setData(data: FeatureData<P>): void {\n const before = this.list.length;\n this.list = featuresOf(data);\n if (this.list.length !== before) this.values = undefined;\n // A new feature count needs new textures: the layer is created again at its place\n if (this.list.length !== before) this.recreate();\n else {\n this.upload(this.map.engine, this.id);\n this.applyStyle(this.map.engine, this.id);\n }\n this.map.requestRender();\n }\n\n setStyle(style: Partial<S>): void {\n this.style = { ...this.style, ...style };\n this.applyStyle(this.map.engine, this.id);\n this.map.requestRender();\n }\n\n /** One value per feature (in data order), colored through the style's `ramp`; NaN keeps a feature's color */\n setValues(values: Float32Array | undefined): void {\n this.values = values;\n this.map.engine.setFeatureValues(this.id, values ?? new Float32Array(this.list.length).fill(Number.NaN));\n this.map.requestRender();\n }\n\n /** Shows only the features the predicate keeps; undefined shows them all */\n setFilter(filter: ((properties: P, index: number) => boolean) | undefined): void {\n this.style = { ...this.style, filter };\n this.map.engine.setFeatureMask(this.id, this.mask());\n this.map.requestRender();\n }\n\n setVisible(visible: boolean): void {\n this.setStyle({ visible } as Partial<S>);\n }\n\n private mask(): Uint8Array {\n const { filter } = this.style;\n const mask = new Uint8Array(this.list.length).fill(255);\n if (filter)\n this.list.forEach((f, i) => {\n if (!filter(f.properties, i)) mask[i] = 0;\n });\n return mask;\n }\n\n /** Recreated in the engine at the same place (a new feature count) */\n private recreate(): void {\n const engine = this.map.engine;\n const old = this.id;\n this.attach(engine);\n this.map.replaceLayer(this, old);\n }\n\n /** @internal */\n protected create(engine: Engine): number {\n const id = this.add(engine);\n this.applyStyle(engine, id);\n if (this.values) engine.setFeatureValues(id, this.values);\n return id;\n }\n\n /** @internal Adds the geometry to the engine, returns the layer id */\n protected abstract add(engine: Engine): number;\n /** @internal Sends the geometry again (same feature count) */\n protected abstract upload(engine: Engine, id: number): void;\n /** Two colors and two sizes of a feature */\n protected abstract featureStyle(\n properties: P,\n index: number,\n ): [color: string, second: string, size: Size, second: Size];\n /** @internal Layer-specific settings (dashes, alignment) */\n protected abstract applyExtra(engine: Engine, id: number): void;\n\n /** @internal */\n protected applyStyle(engine: Engine, id: number): void {\n const out = new Float32Array(this.list.length * FLOATS);\n this.list.forEach((f, i) => {\n const [color, second, size, size2] = this.featureStyle(f.properties, i);\n const o = i * FLOATS;\n out.set(parseColor(color), o);\n out.set(parseColor(second), o + 4);\n out.set(stops(size), o + 8);\n out.set(stops(size2), o + 16);\n });\n engine.setFeatureStyle(id, out);\n engine.setFeatureMask(id, this.mask());\n const { ramp, opacity, minZoom, maxZoom, visible } = this.style;\n const r = ramp && rampTexels(ramp);\n engine.setFeatureRamp(id, r?.rgba, r?.min ?? 0, r?.max ?? 1);\n engine.setFeatureLayer(id, Float32Array.from(stops(opacity)), minZoom, maxZoom, visible);\n this.applyExtra(engine, id);\n }\n}\n\nexport class LineLayer<P = Properties> extends FeatureLayer<P, LineStyle<P>> {\n /** @internal */\n protected add(engine: Engine): number {\n const g = lineGeometry(this.list);\n return engine.addLines(g.points, g.start, g.feature, this.list.length);\n }\n\n /** @internal */\n protected upload(engine: Engine, id: number): void {\n const g = lineGeometry(this.list);\n engine.setLines(id, g.points, g.start, g.feature);\n }\n\n protected featureStyle(properties: P, index: number): [string, string, Size, Size] {\n const { color, width } = this.style;\n return [evaluate(color, properties, index), '#000', evaluate(width, properties, index), 0];\n }\n\n /** @internal */\n protected applyExtra(engine: Engine, id: number): void {\n const [dash, gap] = this.style.dash ?? [0, 0];\n engine.setLineDash(id, dash, gap);\n }\n}\n\nexport class CircleLayer<P = Properties> extends FeatureLayer<P, CircleStyle<P>> {\n /** @internal */\n protected add(engine: Engine): number {\n const g = pointGeometry(this.list);\n return engine.addCircles(g.points, g.feature, this.list.length);\n }\n\n /** @internal */\n protected upload(engine: Engine, id: number): void {\n const g = pointGeometry(this.list);\n engine.setCircles(id, g.points, g.feature);\n }\n\n protected featureStyle(properties: P, index: number): [string, string, Size, Size] {\n const { color, strokeColor, radius, strokeWidth } = this.style;\n return [\n evaluate(color, properties, index),\n evaluate(strokeColor, properties, index),\n evaluate(radius, properties, index),\n evaluate(strokeWidth, properties, index),\n ];\n }\n\n /** @internal */\n protected applyExtra(engine: Engine, id: number): void {\n engine.setCircleAlignment(id, this.style.alignment === 'map');\n }\n}\n\nexport class FillLayer<P = Properties> extends FeatureLayer<P, FillStyle<P>> {\n /** @internal */\n protected add(engine: Engine): number {\n const g = polygonGeometry(this.list);\n return engine.addFills(g.points, g.ringStart, g.polygonStart, g.feature, this.list.length);\n }\n\n /** @internal */\n protected upload(engine: Engine, id: number): void {\n const g = polygonGeometry(this.list);\n engine.setFills(id, g.points, g.ringStart, g.polygonStart, g.feature);\n }\n\n protected featureStyle(properties: P, index: number): [string, string, Size, Size] {\n return [evaluate(this.style.color, properties, index), '#000', 0, 0];\n }\n\n protected applyExtra(): void {}\n}\n\nexport function lineStyle<P>(options: LineOptions<P>): LineStyle<P> {\n const { data: _, before: __, ...rest } = options;\n return { ...(BASE as FeatureLayerStyle<P>), color: '#000', width: 1, dash: undefined, ...rest };\n}\n\nexport function circleStyle<P>(options: CircleOptions<P>): CircleStyle<P> {\n const { data: _, before: __, ...rest } = options;\n return {\n ...(BASE as FeatureLayerStyle<P>),\n color: '#000',\n radius: 5,\n strokeColor: '#fff',\n strokeWidth: 0,\n alignment: 'viewport',\n ...rest,\n };\n}\n\nexport function fillStyle<P>(options: FillOptions<P>): FillStyle<P> {\n const { data: _, before: __, ...rest } = options;\n return { ...(BASE as FeatureLayerStyle<P>), color: '#000', ...rest };\n}\n"]}
1
+ {"version":3,"file":"features.js","sourceRoot":"","sources":["../src/features.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,EAA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ClD,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IACjD,OAAO,EAAE,GAAI,IAA6B,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,CAAC;AACvE,CAAC","sourcesContent":["/**\n * Feature layers: lines, circles and fills from GeoJSON, styled per feature. A style value is a constant, zoom stops\n * (`[[zoom, value], …]`, linear in between, as MapLibre's `interpolate linear zoom`), or a function of the feature\n * returning either, evaluated once per feature when the data or the style change: the engine keeps the result in\n * textures, and restyling, recoloring by values or filtering never touches the geometry.\n */\n\nimport { parseCssColor } from './color.ts';\nimport { crsOf, reproject } from './crs.ts';\nimport { mercatorX, mercatorY } from './geo.ts';\nimport { Layer } from './layers.ts';\nimport type { LayerHost } from './types.ts';\nimport type { Engine } from './wasm/isard.js';\n\n// ── GeoJSON (the parts used here) ──\n\nexport type Position = [lon: number, lat: number, ...rest: number[]];\nexport type Geometry =\n | { type: 'Point'; coordinates: Position }\n | { type: 'MultiPoint'; coordinates: Position[] }\n | { type: 'LineString'; coordinates: Position[] }\n | { type: 'MultiLineString'; coordinates: Position[][] }\n | { type: 'Polygon'; coordinates: Position[][] }\n | { type: 'MultiPolygon'; coordinates: Position[][][] }\n | { type: 'GeometryCollection'; geometries: Geometry[] };\nexport type Properties = Record<string, unknown>;\nexport interface Feature<P = Properties> {\n type: 'Feature';\n geometry: Geometry | null;\n properties: P;\n id?: string | number;\n}\nexport interface FeatureCollection<P = Properties> {\n type: 'FeatureCollection';\n features: Feature<P>[];\n /** The CRS of the coordinates, a legacy member (GeoJSON of 2008, the output of a WFS in another CRS): the feature\n * layers reproject a collection that names one (see `reproject`) */\n crs?: { type: 'name'; properties: { name: string } };\n}\n/** What a feature layer takes: a collection, its features, or one feature */\nexport type FeatureData<P = Properties> = FeatureCollection<P> | Feature<P>[] | Feature<P>;\n\n// ── Style values ──\n\n/** Zoom stops: `[[zoom, value], …]` in increasing zooms, up to four, linear in between, constant outside */\nexport type Stops = [zoom: number, value: number][];\n/** A size: CSS pixels, or zoom stops */\nexport type Size = number | Stops;\n/** A value for all features, or a function of each feature (its properties and its index in the data) */\nexport type Styled<T, P = Properties> = T | ((properties: P, index: number) => T);\n/** Colors of values: `[[value, color], …]` in increasing values, linear in between */\nexport type Ramp = [value: number, color: string][];\n\nexport interface FeatureLayerStyle<P = Properties> {\n /** Layer opacity, 0 to 1, or zoom stops (a layer fading in past a zoom) (default 1) */\n opacity: Size;\n /** Zooms the layer shows in: from `minZoom` (included) to `maxZoom` (excluded) */\n minZoom: number;\n maxZoom: number;\n visible: boolean;\n /** Features drawn; the others hidden (default all) */\n filter: ((properties: P, index: number) => boolean) | undefined;\n /** Colors of the values given by `setValues`: a feature with a value takes its color here, the others keep theirs */\n ramp: Ramp | undefined;\n}\n\nexport interface LineStyle<P = Properties> extends FeatureLayerStyle<P> {\n /** CSS color: `#rgb`, `#rrggbb`, `#rrggbbaa`, `rgb()`, `rgba()` (default `#000`) */\n color: Styled<string, P>;\n /** CSS pixels (default 1) */\n width: Styled<Size, P>;\n /** Dash and gap, in line widths (MapLibre's `line-dasharray`); undefined: solid */\n dash: [dash: number, gap: number] | undefined;\n}\n\nexport interface CircleStyle<P = Properties> extends FeatureLayerStyle<P> {\n color: Styled<string, P>;\n /** CSS pixels (default 5) */\n radius: Styled<Size, P>;\n strokeColor: Styled<string, P>;\n /** CSS pixels (default 0) */\n strokeWidth: Styled<Size, P>;\n /** `'viewport'` (default): discs facing the screen; `'map'`: lying on the ground (MapLibre's\n * `circle-pitch-alignment`) */\n alignment: 'viewport' | 'map';\n}\n\nexport interface FillStyle<P = Properties> extends FeatureLayerStyle<P> {\n color: Styled<string, P>;\n}\n\n/** Where a new layer goes: under `before`, or on top of the others */\nexport interface Placement {\n before?: Layer;\n}\n\nexport interface LineOptions<P = Properties> extends Partial<LineStyle<P>>, Placement {\n /** LineString and MultiLineString features; the rings of Polygon and MultiPolygon features are drawn as lines */\n data: FeatureData<P>;\n}\nexport interface CircleOptions<P = Properties> extends Partial<CircleStyle<P>>, Placement {\n /** Point and MultiPoint features */\n data: FeatureData<P>;\n}\nexport interface FillOptions<P = Properties> extends Partial<FillStyle<P>>, Placement {\n /** Polygon and MultiPolygon features */\n data: FeatureData<P>;\n}\n\nconst BASE: FeatureLayerStyle = {\n opacity: 1,\n minZoom: 0,\n maxZoom: 24,\n visible: true,\n filter: undefined,\n ramp: undefined,\n};\n\n// ── Colors ──\n\n/** A CSS color to RGBA 0-1 (see `parseCssColor`); black if unknown or missing */\nexport function parseColor(color: string): [r: number, g: number, b: number, a: number] {\n return parseCssColor(color) ?? [0, 0, 0, 1];\n}\n\n/** 256 RGBA texels of a ramp over its value range, and that range */\nexport function rampTexels(ramp: Ramp): { rgba: Uint8Array; min: number; max: number } {\n const stops = ramp.map(([v, c]) => [v, parseColor(c)] as const).sort((a, b) => a[0] - b[0]);\n const min = stops[0]?.[0] ?? 0;\n const max = stops.at(-1)?.[0] ?? 1;\n const rgba = new Uint8Array(256 * 4);\n for (let i = 0; i < 256; i += 1) {\n const v = min + ((max - min) * i) / 255;\n let k = 0;\n while (k + 1 < stops.length && (stops[k + 1]?.[0] ?? 0) < v) k += 1;\n const [v0, c0] = stops[k] ?? [min, [0, 0, 0, 1]];\n const [v1, c1] = stops[k + 1] ?? [v0, c0];\n const t = v1 > v0 ? Math.max(0, Math.min(1, (v - v0) / (v1 - v0))) : 0;\n for (let j = 0; j < 4; j += 1)\n rgba[i * 4 + j] = Math.round(((c0[j] ?? 0) + ((c1[j] ?? 0) - (c0[j] ?? 0)) * t) * 255);\n }\n return { rgba, min, max };\n}\n\n/** Up to four stops as zooms then values, constant if a number */\nexport function stops(size: Size): [number, number, number, number, number, number, number, number] {\n if (!Array.isArray(size)) {\n // A style function may return nothing for a feature without the property: 0\n const v = Number.isFinite(size) ? size : 0;\n return [0, 0, 0, 0, v, v, v, v];\n }\n // More than four: resampled at four zooms over their range\n let s = size;\n if (s.length > 4) {\n const z0 = s[0]?.[0] ?? 0;\n const z1 = s.at(-1)?.[0] ?? 0;\n s = [0, 1, 2, 3].map((k): [number, number] => {\n const z = z0 + ((z1 - z0) * k) / 3;\n return [z, interpolate(size, z)];\n });\n }\n const at = (k: number) => s[Math.min(k, s.length - 1)] ?? [0, 0];\n return [at(0)[0], at(1)[0], at(2)[0], at(3)[0], at(0)[1], at(1)[1], at(2)[1], at(3)[1]];\n}\n\n/** Value of zoom stops at a zoom */\nexport function interpolate(size: Size, zoom: number): number {\n if (typeof size === 'number') return size;\n const first = size[0];\n if (!first) return 0;\n if (zoom <= first[0]) return first[1];\n for (let k = 1; k < size.length; k += 1) {\n const [z0, v0] = size[k - 1] ?? first;\n const [z1, v1] = size[k] ?? first;\n if (zoom <= z1) return v0 + ((v1 - v0) * (zoom - z0)) / Math.max(z1 - z0, 1e-9);\n }\n return size.at(-1)?.[1] ?? 0;\n}\n\nexport function evaluate<T, P>(value: Styled<T, P>, properties: P, index: number): T {\n return typeof value === 'function' ? (value as (p: P, i: number) => T)(properties, index) : value;\n}\n\n// ── Geometry ──\n\n/** Collections in another CRS, reprojected once (the layers read their data again) */\nconst reprojected = new WeakMap<object, Feature<unknown>[]>();\n\nexport function featuresOf<P>(data: FeatureData<P>): Feature<P>[] {\n if (Array.isArray(data)) return data;\n if (data.type !== 'FeatureCollection') return [data];\n if (crsOf(data) === undefined) return data.features;\n let features = reprojected.get(data) as Feature<P>[] | undefined;\n if (!features) {\n features = reproject(data).features;\n reprojected.set(data, features);\n }\n return features;\n}\n\n/** Every geometry of a feature, collections flattened */\nfunction* geometries(geometry: Geometry | null): Generator<Geometry> {\n if (!geometry) return;\n if (geometry.type === 'GeometryCollection') for (const g of geometry.geometries) yield* geometries(g);\n else yield geometry;\n}\n\n/** A growable typed array */\nclass Grow<T extends Float64Array | Uint32Array> {\n length = 0;\n constructor(public data: T) {}\n push(...values: number[]): void {\n if (this.length + values.length > this.data.length) {\n const next = new (this.data.constructor as new (n: number) => T)(\n Math.max(16, this.data.length * 2, this.length + values.length),\n );\n next.set(this.data);\n this.data = next;\n }\n for (const v of values) this.data[this.length++] = v;\n }\n done(): T {\n return this.data.subarray(0, this.length) as T;\n }\n}\n\n/** Lines of the features: points (Mercator), first point of each line, feature of each line */\nfunction lineGeometry(features: Feature<unknown>[]) {\n const points = new Grow(new Float64Array(1024));\n const start = new Grow(new Uint32Array(64));\n const feature = new Grow(new Uint32Array(64));\n const line = (coords: Position[], f: number) => {\n start.push(points.length / 2);\n feature.push(f);\n for (const [lon, lat] of coords) points.push(mercatorX(lon), mercatorY(lat));\n };\n features.forEach((f, i) => {\n for (const g of geometries(f.geometry)) {\n if (g.type === 'LineString') line(g.coordinates, i);\n else if (g.type === 'MultiLineString') for (const l of g.coordinates) line(l, i);\n else if (g.type === 'Polygon') for (const r of g.coordinates) line(r, i);\n else if (g.type === 'MultiPolygon') for (const p of g.coordinates) for (const r of p) line(r, i);\n }\n });\n start.push(points.length / 2);\n return { points: points.done(), start: start.done(), feature: feature.done() };\n}\n\nfunction pointGeometry(features: Feature<unknown>[]) {\n const points = new Grow(new Float64Array(1024));\n const feature = new Grow(new Uint32Array(64));\n const point = ([lon, lat]: Position, f: number) => {\n points.push(mercatorX(lon), mercatorY(lat));\n feature.push(f);\n };\n features.forEach((f, i) => {\n for (const g of geometries(f.geometry)) {\n if (g.type === 'Point') point(g.coordinates, i);\n else if (g.type === 'MultiPoint') for (const p of g.coordinates) point(p, i);\n }\n });\n return { points: points.done(), feature: feature.done() };\n}\n\nexport function polygonGeometry(features: Feature<unknown>[]) {\n const points = new Grow(new Float64Array(1024));\n const ringStart = new Grow(new Uint32Array(64));\n const polygonStart = new Grow(new Uint32Array(64));\n const feature = new Grow(new Uint32Array(64));\n const polygon = (rings: Position[][], f: number) => {\n polygonStart.push(ringStart.length);\n feature.push(f);\n for (const ring of rings) {\n ringStart.push(points.length / 2);\n for (const [lon, lat] of ring) points.push(mercatorX(lon), mercatorY(lat));\n }\n };\n features.forEach((f, i) => {\n for (const g of geometries(f.geometry)) {\n if (g.type === 'Polygon') polygon(g.coordinates, i);\n else if (g.type === 'MultiPolygon') for (const p of g.coordinates) polygon(p, i);\n }\n });\n ringStart.push(points.length / 2);\n polygonStart.push(ringStart.length - 1);\n return {\n points: points.done(),\n ringStart: ringStart.done(),\n polygonStart: polygonStart.done(),\n feature: feature.done(),\n };\n}\n\n// ── Layers ──\n\n/** Floats per feature in the engine's style (see `setFeatureStyle`) */\nexport const FLOATS = 32;\n\n/** What every feature layer shares: its data, its style in the engine, values, filter */\nexport abstract class FeatureLayer<P, S extends FeatureLayerStyle<P>> extends Layer {\n protected list: Feature<P>[];\n protected values: Float32Array | undefined;\n\n /** @internal */\n constructor(\n map: LayerHost,\n data: FeatureData<P>,\n protected style: S,\n ) {\n super(map);\n this.list = featuresOf(data);\n }\n\n /** The features, in the order of the data (their index is what `pick` returns) */\n get features(): readonly Feature<P>[] {\n return this.list;\n }\n\n /** The feature of a picked index */\n featureAt(index: number): Feature<P> | undefined {\n return this.list[index];\n }\n\n /** Replaces the features; the style is evaluated again for them */\n setData(data: FeatureData<P>): void {\n const before = this.list.length;\n this.list = featuresOf(data);\n if (this.list.length !== before) this.values = undefined;\n // A new feature count needs new textures: the layer is created again at its place\n if (this.list.length !== before) this.recreate();\n else {\n this.upload(this.map.engine, this.id);\n this.applyStyle(this.map.engine, this.id);\n }\n this.map.requestRender();\n }\n\n setStyle(style: Partial<S>): void {\n this.style = { ...this.style, ...style };\n this.applyStyle(this.map.engine, this.id);\n this.map.requestRender();\n }\n\n /** One value per feature (in data order), colored through the style's `ramp`; NaN keeps a feature's color */\n setValues(values: Float32Array | undefined): void {\n this.values = values;\n this.map.engine.setFeatureValues(this.id, values ?? new Float32Array(this.list.length).fill(Number.NaN));\n this.map.requestRender();\n }\n\n /** Shows only the features the predicate keeps; undefined shows them all */\n setFilter(filter: ((properties: P, index: number) => boolean) | undefined): void {\n this.style = { ...this.style, filter };\n this.map.engine.setFeatureMask(this.id, this.mask());\n this.map.requestRender();\n }\n\n setVisible(visible: boolean): void {\n this.setStyle({ visible } as Partial<S>);\n }\n\n private mask(): Uint8Array {\n const { filter } = this.style;\n const mask = new Uint8Array(this.list.length).fill(255);\n if (filter)\n this.list.forEach((f, i) => {\n if (!filter(f.properties, i)) mask[i] = 0;\n });\n return mask;\n }\n\n /** Recreated in the engine at the same place (a new feature count) */\n private recreate(): void {\n const engine = this.map.engine;\n const old = this.id;\n this.attach(engine);\n this.map.replaceLayer(this, old);\n }\n\n /** @internal */\n protected create(engine: Engine): number {\n const id = this.add(engine);\n this.applyStyle(engine, id);\n if (this.values) engine.setFeatureValues(id, this.values);\n return id;\n }\n\n /** @internal Adds the geometry to the engine, returns the layer id */\n protected abstract add(engine: Engine): number;\n /** @internal Sends the geometry again (same feature count) */\n protected abstract upload(engine: Engine, id: number): void;\n /** Two colors and two sizes of a feature */\n protected abstract featureStyle(\n properties: P,\n index: number,\n ): [color: string, second: string, size: Size, second: Size];\n /** @internal Layer-specific settings (dashes, alignment) */\n protected abstract applyExtra(engine: Engine, id: number): void;\n\n /** @internal */\n protected applyStyle(engine: Engine, id: number): void {\n const out = new Float32Array(this.list.length * FLOATS);\n this.list.forEach((f, i) => {\n const [color, second, size, size2] = this.featureStyle(f.properties, i);\n const o = i * FLOATS;\n out.set(parseColor(color), o);\n out.set(parseColor(second), o + 4);\n out.set(stops(size), o + 8);\n out.set(stops(size2), o + 16);\n });\n engine.setFeatureStyle(id, out);\n engine.setFeatureMask(id, this.mask());\n const { ramp, opacity, minZoom, maxZoom, visible } = this.style;\n const r = ramp && rampTexels(ramp);\n engine.setFeatureRamp(id, r?.rgba, r?.min ?? 0, r?.max ?? 1);\n engine.setFeatureLayer(id, Float32Array.from(stops(opacity)), minZoom, maxZoom, visible);\n this.applyExtra(engine, id);\n }\n}\n\nexport class LineLayer<P = Properties> extends FeatureLayer<P, LineStyle<P>> {\n /** @internal */\n protected add(engine: Engine): number {\n const g = lineGeometry(this.list);\n return engine.addLines(g.points, g.start, g.feature, this.list.length);\n }\n\n /** @internal */\n protected upload(engine: Engine, id: number): void {\n const g = lineGeometry(this.list);\n engine.setLines(id, g.points, g.start, g.feature);\n }\n\n protected featureStyle(properties: P, index: number): [string, string, Size, Size] {\n const { color, width } = this.style;\n return [evaluate(color, properties, index), '#000', evaluate(width, properties, index), 0];\n }\n\n /** @internal */\n protected applyExtra(engine: Engine, id: number): void {\n const [dash, gap] = this.style.dash ?? [0, 0];\n engine.setLineDash(id, dash, gap);\n }\n}\n\nexport class CircleLayer<P = Properties> extends FeatureLayer<P, CircleStyle<P>> {\n /** @internal */\n protected add(engine: Engine): number {\n const g = pointGeometry(this.list);\n return engine.addCircles(g.points, g.feature, this.list.length);\n }\n\n /** @internal */\n protected upload(engine: Engine, id: number): void {\n const g = pointGeometry(this.list);\n engine.setCircles(id, g.points, g.feature);\n }\n\n protected featureStyle(properties: P, index: number): [string, string, Size, Size] {\n const { color, strokeColor, radius, strokeWidth } = this.style;\n return [\n evaluate(color, properties, index),\n evaluate(strokeColor, properties, index),\n evaluate(radius, properties, index),\n evaluate(strokeWidth, properties, index),\n ];\n }\n\n /** @internal */\n protected applyExtra(engine: Engine, id: number): void {\n engine.setCircleAlignment(id, this.style.alignment === 'map');\n }\n}\n\nexport class FillLayer<P = Properties> extends FeatureLayer<P, FillStyle<P>> {\n /** @internal */\n protected add(engine: Engine): number {\n const g = polygonGeometry(this.list);\n return engine.addFills(g.points, g.ringStart, g.polygonStart, g.feature, this.list.length);\n }\n\n /** @internal */\n protected upload(engine: Engine, id: number): void {\n const g = polygonGeometry(this.list);\n engine.setFills(id, g.points, g.ringStart, g.polygonStart, g.feature);\n }\n\n protected featureStyle(properties: P, index: number): [string, string, Size, Size] {\n return [evaluate(this.style.color, properties, index), '#000', 0, 0];\n }\n\n protected applyExtra(): void {}\n}\n\nexport function lineStyle<P>(options: LineOptions<P>): LineStyle<P> {\n const { data: _, before: __, ...rest } = options;\n return { ...(BASE as FeatureLayerStyle<P>), color: '#000', width: 1, dash: undefined, ...rest };\n}\n\nexport function circleStyle<P>(options: CircleOptions<P>): CircleStyle<P> {\n const { data: _, before: __, ...rest } = options;\n return {\n ...(BASE as FeatureLayerStyle<P>),\n color: '#000',\n radius: 5,\n strokeColor: '#fff',\n strokeWidth: 0,\n alignment: 'viewport',\n ...rest,\n };\n}\n\nexport function fillStyle<P>(options: FillOptions<P>): FillStyle<P> {\n const { data: _, before: __, ...rest } = options;\n return { ...(BASE as FeatureLayerStyle<P>), color: '#000', ...rest };\n}\n"]}
package/dist/geo.d.ts ADDED
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Web Mercator in [0, 1] across the world (y towards the south), for the page and the workers alike: the positions
3
+ * sent to the engine, the tiles of a view, the flights, the label candidates of the vector tiles.
4
+ */
5
+ /** Mercator x of a longitude (degrees) */
6
+ export declare function mercatorX(lon: number): number;
7
+ /** Mercator y of a latitude (degrees), clamped to the edges of the map */
8
+ export declare function mercatorY(lat: number): number;
9
+ /** Longitude (degrees) of a Mercator x */
10
+ export declare function longitude(x: number): number;
11
+ /** Latitude (degrees) of a Mercator y */
12
+ export declare function latitude(y: number): number;
13
+ /** Mercator x, y of a longitude and latitude */
14
+ export declare function toMercator([lon, lat]: readonly [number, number, ...unknown[]]): [x: number, y: number];
15
+ /** Longitude and latitude of a Mercator x, y */
16
+ export declare function fromMercator([x, y]: readonly [number, number]): [lon: number, lat: number];
package/dist/geo.js ADDED
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Web Mercator in [0, 1] across the world (y towards the south), for the page and the workers alike: the positions
3
+ * sent to the engine, the tiles of a view, the flights, the label candidates of the vector tiles.
4
+ */
5
+ /** The latitude where Web Mercator is square: the edges of the map */
6
+ const MAX_LAT = 85.051128779806589;
7
+ /** Mercator x of a longitude (degrees) */
8
+ export function mercatorX(lon) {
9
+ return (lon + 180) / 360;
10
+ }
11
+ /** Mercator y of a latitude (degrees), clamped to the edges of the map */
12
+ export function mercatorY(lat) {
13
+ const phi = (Math.max(-MAX_LAT, Math.min(MAX_LAT, lat)) * Math.PI) / 180;
14
+ return 0.5 - Math.log(Math.tan(Math.PI / 4 + phi / 2)) / (2 * Math.PI);
15
+ }
16
+ /** Longitude (degrees) of a Mercator x */
17
+ export function longitude(x) {
18
+ return x * 360 - 180;
19
+ }
20
+ /** Latitude (degrees) of a Mercator y */
21
+ export function latitude(y) {
22
+ return (Math.atan(Math.sinh(Math.PI * (1 - 2 * y))) * 180) / Math.PI;
23
+ }
24
+ /** Mercator x, y of a longitude and latitude */
25
+ export function toMercator([lon, lat]) {
26
+ return [mercatorX(lon), mercatorY(lat)];
27
+ }
28
+ /** Longitude and latitude of a Mercator x, y */
29
+ export function fromMercator([x, y]) {
30
+ return [longitude(x), latitude(y)];
31
+ }
32
+ //# sourceMappingURL=geo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geo.js","sourceRoot":"","sources":["../src/geo.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,sEAAsE;AACtE,MAAM,OAAO,GAAG,kBAAkB,CAAC;AAEnC,0CAA0C;AAC1C,MAAM,UAAU,SAAS,CAAC,GAAW;IACnC,OAAO,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;AAC3B,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,SAAS,CAAC,GAAW;IACnC,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC;IACzE,OAAO,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;AACzE,CAAC;AAED,0CAA0C;AAC1C,MAAM,UAAU,SAAS,CAAC,CAAS;IACjC,OAAO,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC;AACvB,CAAC;AAED,yCAAyC;AACzC,MAAM,UAAU,QAAQ,CAAC,CAAS;IAChC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC;AACvE,CAAC;AAED,gDAAgD;AAChD,MAAM,UAAU,UAAU,CAAC,CAAC,GAAG,EAAE,GAAG,CAA0C;IAC5E,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;AAC1C,CAAC;AAED,gDAAgD;AAChD,MAAM,UAAU,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,CAA4B;IAC5D,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;AACrC,CAAC","sourcesContent":["/**\n * Web Mercator in [0, 1] across the world (y towards the south), for the page and the workers alike: the positions\n * sent to the engine, the tiles of a view, the flights, the label candidates of the vector tiles.\n */\n\n/** The latitude where Web Mercator is square: the edges of the map */\nconst MAX_LAT = 85.051128779806589;\n\n/** Mercator x of a longitude (degrees) */\nexport function mercatorX(lon: number): number {\n return (lon + 180) / 360;\n}\n\n/** Mercator y of a latitude (degrees), clamped to the edges of the map */\nexport function mercatorY(lat: number): number {\n const phi = (Math.max(-MAX_LAT, Math.min(MAX_LAT, lat)) * Math.PI) / 180;\n return 0.5 - Math.log(Math.tan(Math.PI / 4 + phi / 2)) / (2 * Math.PI);\n}\n\n/** Longitude (degrees) of a Mercator x */\nexport function longitude(x: number): number {\n return x * 360 - 180;\n}\n\n/** Latitude (degrees) of a Mercator y */\nexport function latitude(y: number): number {\n return (Math.atan(Math.sinh(Math.PI * (1 - 2 * y))) * 180) / Math.PI;\n}\n\n/** Mercator x, y of a longitude and latitude */\nexport function toMercator([lon, lat]: readonly [number, number, ...unknown[]]): [x: number, y: number] {\n return [mercatorX(lon), mercatorY(lat)];\n}\n\n/** Longitude and latitude of a Mercator x, y */\nexport function fromMercator([x, y]: readonly [number, number]): [lon: number, lat: number] {\n return [longitude(x), latitude(y)];\n}\n"]}
@@ -4,32 +4,48 @@
4
4
  * `hillshade`, `terrain: 'ign'`, `PLAN_STYLES`); the rasters credit the IGN by themselves.
5
5
  */
6
6
  import type { FeatureCollection, Properties } from './features.ts';
7
+ import type { TileGrid } from './grid.ts';
7
8
  import type { RasterOptions } from './types.ts';
8
9
  /** Credits of the Géoplateforme's data: its basemaps, hillshade, terrain model, rasters and features */
9
10
  export declare const IGN_ATTRIBUTION = "<a href=\"https://www.ign.fr/\">\u00A9 IGN</a> \u2013 <a href=\"https://geoservices.ign.fr/\">G\u00E9oplateforme</a>";
10
11
  /**
11
- * A layer of the Géoplateforme's WMTS (its Web Mercator grid, PM) as raster options for `addRaster`, crediting the
12
- * IGN: `geoplateformeWmts('ORTHOIMAGERY.ORTHOPHOTOS', { format: 'image/jpeg' })`. The layer names are those of its
13
- * capabilities (https://data.geopf.fr/wmts?SERVICE=WMTS&REQUEST=GetCapabilities)
12
+ * The Géoplateforme's Lambert-93 tile matrix sets of 5 and 10 cm (`2154_10cm_6_20`, `2154_5cm_6_22`…: one pyramid,
13
+ * 209 715.2 m per pixel at level 0, halved at each level, from the corner (0, 12 000 000)), levels `min` to `max`, over
14
+ * France
15
+ */
16
+ export declare function lambert93Grid(name: string, min: number, max: number): TileGrid;
17
+ /**
18
+ * A layer of the Géoplateforme's WMTS as raster options for `addRaster`, crediting the IGN:
19
+ * `geoplateformeWmts('ORTHOIMAGERY.ORTHOPHOTOS', { format: 'image/jpeg' })`. The layer names are those of its
20
+ * capabilities (https://data.geopf.fr/wmts?SERVICE=WMTS&REQUEST=GetCapabilities). In its Web Mercator grid (`PM`) by
21
+ * default; a Lambert-93 layer in its matrix set (`matrixSet: '2154_10cm_6_20'`, a set of 5 or 10 cm, read from the
22
+ * capabilities) or another `grid` (from `wmtsGrid`, its set named) is reprojected by the map
14
23
  */
15
24
  export declare function geoplateformeWmts(layer: string, options?: {
16
25
  format?: string;
17
26
  style?: string;
27
+ matrixSet?: string;
18
28
  } & Omit<RasterOptions, 'url'>): RasterOptions;
19
29
  /**
20
30
  * Layers of the Géoplateforme's WMS (raster, `wms-r`) as raster options for `addRaster`, crediting the IGN: 256 px
21
- * images of each tile asked for in EPSG:3857, transparent where empty. `geoplateformeWms('CADASTRALPARCELS.PARCELLAIRE_EXPRESS')`
31
+ * images of each tile, transparent where empty. `geoplateformeWms('CADASTRALPARCELS.PARCELLAIRE_EXPRESS')`. Asked for
32
+ * in EPSG:3857, or in `crs` (`'EPSG:2154'`: the box of each tile in Lambert-93, at the tile's `size`, reprojected by
33
+ * the map; `'EPSG:4326'` is asked for as CRS:84, longitude first)
22
34
  */
23
35
  export declare function geoplateformeWms(layers: string, options?: {
24
36
  format?: string;
25
37
  styles?: string;
38
+ crs?: string;
26
39
  } & Omit<RasterOptions, 'url'>): RasterOptions;
27
40
  /**
28
41
  * Features of the Géoplateforme's WFS in a box (west, south, east, north, degrees), as GeoJSON in longitudes and
29
42
  * latitudes: `await geoplateformeWfs('BDTOPO_V3:batiment', [2.41, 48.84, 2.43, 48.85])`. At most `count` features
30
- * (default 5000). The type names are those of its capabilities (BD TOPO, ADMIN EXPRESS…)
43
+ * (default 5000). The type names are those of its capabilities (BD TOPO, ADMIN EXPRESS…). With `srsName`
44
+ * (`'EPSG:2154'`), the features come in that CRS (the box stays in degrees), the collection naming it in its `crs`
45
+ * member: the feature layers reproject it by themselves
31
46
  */
32
47
  export declare function geoplateformeWfs<P = Properties>(typeName: string, [west, south, east, north]: [number, number, number, number], options?: {
33
48
  count?: number;
34
49
  signal?: AbortSignal;
50
+ srsName?: string;
35
51
  }): Promise<FeatureCollection<P>>;