isard 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/CHANGELOG.md +134 -14
  2. package/README.md +2 -2
  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 -1
  7. package/dist/basemap.worker.js +2 -2
  8. package/dist/basemap.worker.js.map +8 -4
  9. package/dist/basemaps.d.ts +5 -3
  10. package/dist/basemaps.js +5 -3
  11. package/dist/basemaps.js.map +1 -1
  12. package/dist/crs.d.ts +72 -0
  13. package/dist/crs.js +243 -0
  14. package/dist/crs.js.map +1 -0
  15. package/dist/decoder.worker.js +4 -4
  16. package/dist/decoder.worker.js.map +4 -4
  17. package/dist/engine-loader.d.ts +27 -0
  18. package/dist/engine-loader.js +112 -0
  19. package/dist/engine-loader.js.map +1 -0
  20. package/dist/extrusions.js +11 -2
  21. package/dist/extrusions.js.map +1 -1
  22. package/dist/features.d.ts +8 -0
  23. package/dist/features.js +17 -10
  24. package/dist/features.js.map +1 -1
  25. package/dist/geo.d.ts +16 -0
  26. package/dist/geo.js +32 -0
  27. package/dist/geo.js.map +1 -0
  28. package/dist/geoplateforme.d.ts +21 -5
  29. package/dist/geoplateforme.js +47 -12
  30. package/dist/geoplateforme.js.map +1 -1
  31. package/dist/glyphs.d.ts +10 -3
  32. package/dist/glyphs.js +14 -2
  33. package/dist/glyphs.js.map +1 -1
  34. package/dist/gpx.d.ts +11 -0
  35. package/dist/gpx.js +74 -0
  36. package/dist/gpx.js.map +1 -0
  37. package/dist/grid.d.ts +81 -0
  38. package/dist/grid.js +270 -0
  39. package/dist/grid.js.map +1 -0
  40. package/dist/index.d.ts +7 -1
  41. package/dist/index.js +5 -0
  42. package/dist/index.js.map +1 -1
  43. package/dist/interaction.d.ts +3 -4
  44. package/dist/interaction.js +27 -7
  45. package/dist/interaction.js.map +1 -1
  46. package/dist/isard_bg.wasm +0 -0
  47. package/dist/isard_core_bg.wasm +0 -0
  48. package/dist/kml.d.ts +12 -0
  49. package/dist/kml.js +159 -0
  50. package/dist/kml.js.map +1 -0
  51. package/dist/layers.d.ts +5 -2
  52. package/dist/layers.js +22 -18
  53. package/dist/layers.js.map +1 -1
  54. package/dist/lru.d.ts +22 -0
  55. package/dist/lru.js +52 -0
  56. package/dist/lru.js.map +1 -0
  57. package/dist/map.d.ts +26 -6
  58. package/dist/map.js +196 -287
  59. package/dist/map.js.map +1 -1
  60. package/dist/resample.d.ts +41 -0
  61. package/dist/resample.js +164 -0
  62. package/dist/resample.js.map +1 -0
  63. package/dist/settings.d.ts +39 -0
  64. package/dist/settings.js +104 -0
  65. package/dist/settings.js.map +1 -0
  66. package/dist/symbols.d.ts +12 -1
  67. package/dist/symbols.js +124 -26
  68. package/dist/symbols.js.map +1 -1
  69. package/dist/terrain.d.ts +19 -7
  70. package/dist/terrain.js +50 -26
  71. package/dist/terrain.js.map +1 -1
  72. package/dist/topojson.d.ts +29 -0
  73. package/dist/topojson.js +66 -0
  74. package/dist/topojson.js.map +1 -0
  75. package/dist/types.d.ts +23 -7
  76. package/dist/types.js.map +1 -1
  77. package/dist/vectortiles.d.ts +13 -3
  78. package/dist/vectortiles.js +85 -46
  79. package/dist/vectortiles.js.map +1 -1
  80. package/dist/wasm/isard.d.ts +14 -7
  81. package/dist/wasm/isard.js +33 -10
  82. package/dist/wasm/isard_core.d.ts +6 -5
  83. package/dist/wasm/isard_core.js +41 -10
  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 -113
  93. package/dist/equirectangular.js.map +0 -1
@@ -0,0 +1,27 @@
1
+ import { TileLoader } from './loader.ts';
2
+ import type { GeoMapOptions } from './types.ts';
3
+ import type { Camera, Engine } from './wasm/isard.js';
4
+ export type EngineClass = new (canvas: HTMLCanvasElement, redraw: () => void) => Engine;
5
+ /** An engine loaded: its compiled module and its class */
6
+ export interface Bindings {
7
+ module: WebAssembly.Module;
8
+ Engine: EngineClass;
9
+ }
10
+ /** `core`: the engine without 3D Tiles; `full`: with them */
11
+ export type EngineKind = 'core' | 'full';
12
+ /** Where a build of the engine is loaded from: the option, or next to the module */
13
+ export declare function engineUrl(kind: EngineKind, options: Pick<GeoMapOptions, 'wasmUrl' | 'coreWasmUrl'>): string | URL;
14
+ /** A build compiled and instantiated with its bindings (once per page, unless it failed) */
15
+ export declare function loadEngine(kind: EngineKind, url: string | URL): Promise<Bindings>;
16
+ /** The full engine for a map on the core one, resolved in a task of its own, not in the one that instantiated it:
17
+ * the map rebuilt on it there, two shorter tasks */
18
+ export declare function loadFullEngineLater(url: string | URL): Promise<Bindings>;
19
+ /** Downloads and compiles the full engine when the page is idle, without running it; a failure is left to the first
20
+ * 3D Tiles layer, which tries again */
21
+ export declare function preloadFullEngine(url: string | URL, wanted: () => boolean): void;
22
+ /** The decoding workers of 3D Tiles, running the full engine's module, unless turned off (`workers: false` or 0, or
23
+ * no workers in this environment) */
24
+ export declare function startTileLoader(module: WebAssembly.Module, options: Pick<GeoMapOptions, 'workers' | 'workerUrl' | 'decoders'>, engine: Engine): TileLoader | undefined;
25
+ /** The engine of a destroyed map: every method a no-op returning undefined, but the camera (the last one) and the
26
+ * bounds, which late callers read */
27
+ 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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AM,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\nexport type EngineClass = new (canvas: HTMLCanvasElement, redraw: () => void) => Engine;\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"]}
@@ -185,7 +185,9 @@ export class ExtrusionLayer extends Layer {
185
185
  }
186
186
  sendLink(engine, id) {
187
187
  const n = this.network;
188
- engine.linkExtrusionNetwork(id, n?.layer.id, n ? Math.min(n.max, 1e29) : 0);
188
+ // A network removed (or not created) links to nothing
189
+ const network = n && n.layer.id >= 0 ? n.layer.id : undefined;
190
+ engine.linkExtrusionNetwork(id, network, n ? Math.min(n.max, 1e29) : 0);
189
191
  }
190
192
  /** @internal */
191
193
  create(engine) {
@@ -193,9 +195,16 @@ export class ExtrusionLayer extends Layer {
193
195
  this.sendLayer(engine, id);
194
196
  for (const tile of this.tiles.values())
195
197
  this.sendTile(engine, id, tile);
196
- this.sendLink(engine, id);
198
+ // A network created before (on a new engine, the map relinks once every layer is there)
199
+ if (!this.network || this.network.layer.id >= 0)
200
+ this.sendLink(engine, id);
197
201
  return id;
198
202
  }
203
+ /** @internal On a new engine, the network may come after the buildings: linked once both are there */
204
+ relink(engine) {
205
+ if (this.network)
206
+ this.sendLink(engine, this.id);
207
+ }
199
208
  }
200
209
  export function extrusionStyle(options) {
201
210
  const { data: _, before: __, ...rest } = options;
@@ -1 +1 @@
1
- {"version":3,"file":"extrusions.js","sourceRoot":"","sources":["../src/extrusions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,QAAQ,EAIR,MAAM,EACN,UAAU,EAGV,UAAU,EACV,eAAe,EACf,UAAU,EAEV,KAAK,GACN,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,KAAK,EAAqB,MAAM,aAAa,CAAC;AA4CvD,yCAAyC;AACzC,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;AAE5B,MAAM,OAAO,cAA+B,SAAQ,KAAK;IAS7C;IARO,KAAK,GAAG,IAAI,GAAG,EAAkC,CAAC;IAC3D,SAAS,GAAG,CAAC,CAAC;IACd,OAAO,CAAmD;IAElE,gBAAgB;IAChB,YACE,GAAc,EACd,IAAgC,EACxB,KAAwB;QAEhC,KAAK,CAAC,GAAG,CAAC,CAAC;QAFH,UAAK,GAAL,KAAK,CAAmB;QAGh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AAC;AACJ,CAAC","sourcesContent":["/**\n * Extruded polygons (buildings), styled per feature like the other feature layers, coming in tiles (or one set): an\n * application loading a tiled source (BD TOPO vector tiles…) hands each tile's buildings to `setTile` and drops them\n * with `removeTile`. Colored by their color, by a value per building through the ramp (water at a building), or by\n * the node values of a network layer (`linkNetwork`: the travel time to each building, recolored with the network).\n */\nimport {\n evaluate,\n type Feature,\n type FeatureData,\n type FeatureLayerStyle,\n FLOATS,\n featuresOf,\n type Placement,\n type Properties,\n parseColor,\n polygonGeometry,\n rampTexels,\n type Styled,\n stops,\n} from './features.ts';\nimport { Layer, type NetworkLayer } from './layers.ts';\nimport type { LayerHost } from './types.ts';\nimport type { Engine } from './wasm/isard.js';\n\nexport interface ExtrusionStyle<P = Properties> extends FeatureLayerStyle<P> {\n /** CSS color (default `#e4e1dc`) */\n color: Styled<string, P>;\n /** Height of the roof over the ground, metres (default 6) */\n height: Styled<number, P>;\n /** Height of the foot of the walls, metres (default 0) */\n base: Styled<number, P>;\n}\n\nexport interface ExtrusionOptions<P = Properties> extends Partial<ExtrusionStyle<P>>, Placement {\n /** Polygon and MultiPolygon features, as one set (tiles come with `setTile`) */\n data?: FeatureData<P>;\n}\n\n/** Key of a tile of extrusions (see `ExtrusionLayer.setTile`) */\nexport type TileKey = string | number;\n\n/**\n * Polygons as typed arrays, for tiles decoded in a worker (no GeoJSON in between): points in Mercator [0, 1] (x, y\n * interleaved, y towards the south), the first point of each ring and the first ring of each polygon (one more entry\n * than rings and polygons; the first ring of a polygon is its outline), the feature of each polygon\n */\nexport interface PolygonArrays {\n points: Float64Array;\n ringStart: Uint32Array;\n polygonStart: Uint32Array;\n feature: Uint32Array;\n}\n\ninterface Tile<P> {\n /** Batch number in the engine: tiles are drawn, and their features numbered for picking, in this order */\n batch: number;\n /** The properties of the features, which the style reads */\n properties: P[];\n features: Feature<P>[] | undefined;\n arrays: PolygonArrays | undefined;\n values: Float32Array | undefined;\n anchors: Float32Array | undefined;\n}\n\n/** TileKey of the set given as `data` */\nconst DATA = Symbol('data');\n\nexport class ExtrusionLayer<P = Properties> extends Layer {\n private readonly tiles = new Map<TileKey | typeof DATA, Tile<P>>();\n private nextBatch = 1;\n private network: { layer: NetworkLayer; max: number } | undefined;\n\n /** @internal */\n constructor(\n map: LayerHost,\n data: FeatureData<P> | undefined,\n private style: ExtrusionStyle<P>,\n ) {\n super(map);\n if (data) {\n const features = featuresOf(data);\n const properties = features.map((f) => f.properties);\n this.tiles.set(DATA, {\n batch: 0,\n properties,\n features,\n arrays: undefined,\n values: undefined,\n anchors: undefined,\n });\n }\n }\n\n /** Replaces the set given as `data` */\n setData(data: FeatureData<P>): void {\n const features = featuresOf(data);\n this.put(\n DATA,\n features.map((f) => f.properties),\n features,\n undefined,\n );\n }\n\n /** Adds or replaces the buildings of a tile: GeoJSON, or typed arrays with the properties of each feature */\n setTile(key: TileKey, data: FeatureData<P> | { arrays: PolygonArrays; properties: P[] }): void {\n if ('arrays' in data) this.put(key, data.properties, undefined, data.arrays);\n else {\n const features = featuresOf(data);\n this.put(\n key,\n features.map((f) => f.properties),\n features,\n undefined,\n );\n }\n }\n\n removeTile(key: TileKey): void {\n const tile = this.tiles.get(key);\n if (!tile) return;\n this.tiles.delete(key);\n this.map.engine.removeExtrusionBatch(this.id, tile.batch);\n this.map.requestRender();\n }\n\n /** Keys of the tiles held */\n get tileKeys(): TileKey[] {\n return [...this.tiles.keys()].filter((k): k is TileKey => k !== DATA);\n }\n\n /** The properties of the features of a tile (or of the data) */\n properties(key?: TileKey): readonly P[] {\n return this.tiles.get(key ?? DATA)?.properties ?? [];\n }\n\n /** The feature of a picked index (its geometry if given as GeoJSON): tiles are numbered one after the other, in the\n * order they were added */\n featureAt(index: number): Feature<P> | undefined {\n let rest = index;\n for (const tile of [...this.tiles.values()].sort((a, b) => a.batch - b.batch)) {\n const n = tile.properties.length;\n if (rest < n) {\n const properties = tile.properties[rest] as P;\n return tile.features?.[rest] ?? { type: 'Feature', properties, geometry: null };\n }\n rest -= n;\n }\n return undefined;\n }\n\n /** The tile and the index in it of a picked index */\n tileAt(index: number): { key: TileKey | undefined; index: number } | undefined {\n let rest = index;\n for (const [key, tile] of [...this.tiles].sort((a, b) => a[1].batch - b[1].batch)) {\n if (rest < tile.properties.length) return { key: key === DATA ? undefined : key, index: rest };\n rest -= tile.properties.length;\n }\n return undefined;\n }\n\n setStyle(style: Partial<ExtrusionStyle<P>>): void {\n this.style = { ...this.style, ...style };\n const engine = this.map.engine;\n for (const tile of this.tiles.values()) this.sendStyle(engine, this.id, tile);\n this.sendLayer(engine, this.id);\n this.map.requestRender();\n }\n\n setVisible(visible: boolean): void {\n this.setStyle({ visible } as Partial<ExtrusionStyle<P>>);\n }\n\n setFilter(filter: ((properties: P, index: number) => boolean) | undefined): void {\n this.style = { ...this.style, filter };\n for (const tile of this.tiles.values()) this.map.engine.setFeatureMask(this.id, this.mask(tile), tile.batch);\n this.map.requestRender();\n }\n\n /** One value per building of a tile (or of the data), colored through the ramp; NaN keeps a building's color */\n setValues(values: Float32Array | undefined, key?: TileKey): void {\n const tile = this.tiles.get(key ?? DATA);\n if (!tile) return;\n tile.values = values;\n this.map.engine.setFeatureValues(\n this.id,\n values ?? new Float32Array(tile.properties.length).fill(Number.NaN),\n tile.batch,\n );\n this.map.requestRender();\n }\n\n /**\n * Colors the buildings by the node values of a network layer, recolored with it: each building takes min(value(A)\n * + cost from A, value(B) + cost from B) from its anchors (`setAnchors`), through the ramp, up to `max` (above, or\n * unreached: its own color). Undefined: back to the buildings' own values.\n */\n linkNetwork(network: NetworkLayer | undefined, max = Number.POSITIVE_INFINITY): void {\n this.network = network && { layer: network, max };\n this.sendLink(this.map.engine, this.id);\n this.map.requestRender();\n }\n\n /** Per building of a tile (or of the data): node A, node B, cost from A, cost from B (4 floats each) */\n setAnchors(anchors: Float32Array, key?: TileKey): void {\n const tile = this.tiles.get(key ?? DATA);\n if (!tile) return;\n tile.anchors = anchors;\n this.map.engine.setExtrusionAnchors(this.id, tile.batch, anchors);\n this.map.requestRender();\n }\n\n private put(\n key: TileKey | typeof DATA,\n properties: P[],\n features: Feature<P>[] | undefined,\n arrays: PolygonArrays | undefined,\n ): void {\n const old = this.tiles.get(key);\n const tile: Tile<P> = {\n batch: old?.batch ?? (key === DATA ? 0 : this.nextBatch++),\n properties,\n features,\n arrays,\n values: undefined,\n anchors: undefined,\n };\n this.tiles.set(key, tile);\n this.sendTile(this.map.engine, this.id, tile);\n this.map.requestRender();\n }\n\n private mask(tile: Tile<P>): Uint8Array {\n const { filter } = this.style;\n const mask = new Uint8Array(tile.properties.length).fill(255);\n if (filter)\n tile.properties.forEach((p, i) => {\n if (!filter(p, i)) mask[i] = 0;\n });\n return mask;\n }\n\n private sendTile(engine: Engine, id: number, tile: Tile<P>): void {\n const g = tile.arrays ?? polygonGeometry(tile.features ?? []);\n const n = tile.properties.length;\n engine.setExtrusionBatch(id, tile.batch, g.points, g.ringStart, g.polygonStart, g.feature, n);\n this.sendStyle(engine, id, tile);\n if (tile.values) engine.setFeatureValues(id, tile.values, tile.batch);\n if (tile.anchors) engine.setExtrusionAnchors(id, tile.batch, tile.anchors);\n }\n\n private sendStyle(engine: Engine, id: number, tile: Tile<P>): void {\n const { color, height, base } = this.style;\n const out = new Float32Array(tile.properties.length * FLOATS);\n // Constant colors parsed once: a tile has thousands of buildings\n const fixed = typeof color === 'string' ? parseColor(color) : undefined;\n tile.properties.forEach((p, i) => {\n const o = i * FLOATS;\n out.set(fixed ?? parseColor(evaluate(color, p, i)), o);\n out.set(stops(evaluate(height, p, i)), o + 8);\n out.set(stops(evaluate(base, p, i)), o + 16);\n });\n engine.setFeatureStyle(id, out, tile.batch);\n engine.setFeatureMask(id, this.mask(tile), tile.batch);\n }\n\n private sendLayer(engine: Engine, id: number): void {\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 }\n\n private sendLink(engine: Engine, id: number): void {\n const n = this.network;\n engine.linkExtrusionNetwork(id, n?.layer.id, n ? Math.min(n.max, 1e29) : 0);\n }\n\n /** @internal */\n protected create(engine: Engine): number {\n const id = engine.addExtrusions();\n this.sendLayer(engine, id);\n for (const tile of this.tiles.values()) this.sendTile(engine, id, tile);\n this.sendLink(engine, id);\n return id;\n }\n}\n\nexport function extrusionStyle<P>(options: ExtrusionOptions<P>): ExtrusionStyle<P> {\n const { data: _, before: __, ...rest } = options;\n return {\n opacity: 1,\n minZoom: 0,\n maxZoom: 24,\n visible: true,\n filter: undefined,\n ramp: undefined,\n color: '#e4e1dc',\n height: 6,\n base: 0,\n ...rest,\n };\n}\n"]}
1
+ {"version":3,"file":"extrusions.js","sourceRoot":"","sources":["../src/extrusions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,QAAQ,EAIR,MAAM,EACN,UAAU,EAGV,UAAU,EACV,eAAe,EACf,UAAU,EAEV,KAAK,GACN,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,KAAK,EAAqB,MAAM,aAAa,CAAC;AA4CvD,yCAAyC;AACzC,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;AAE5B,MAAM,OAAO,cAA+B,SAAQ,KAAK;IAS7C;IARO,KAAK,GAAG,IAAI,GAAG,EAAkC,CAAC;IAC3D,SAAS,GAAG,CAAC,CAAC;IACd,OAAO,CAAmD;IAElE,gBAAgB;IAChB,YACE,GAAc,EACd,IAAgC,EACxB,KAAwB;QAEhC,KAAK,CAAC,GAAG,CAAC,CAAC;QAFH,UAAK,GAAL,KAAK,CAAmB;QAGhC,IAAI,IAAI,EAAE,CAAC;YACT,MAAM,QAAQ,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;YAClC,MAAM,UAAU,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,C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AC;IACjD,OAAO;QACL,OAAO,EAAE,CAAC;QACV,OAAO,EAAE,CAAC;QACV,OAAO,EAAE,EAAE;QACX,OAAO,EAAE,IAAI;QACb,MAAM,EAAE,SAAS;QACjB,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,SAAS;QAChB,MAAM,EAAE,CAAC;QACT,IAAI,EAAE,CAAC;QACP,GAAG,IAAI;KACR,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Extruded polygons (buildings), styled per feature like the other feature layers, coming in tiles (or one set): an\n * application loading a tiled source (BD TOPO vector tiles…) hands each tile's buildings to `setTile` and drops them\n * with `removeTile`. Colored by their color, by a value per building through the ramp (water at a building), or by\n * the node values of a network layer (`linkNetwork`: the travel time to each building, recolored with the network).\n */\nimport {\n evaluate,\n type Feature,\n type FeatureData,\n type FeatureLayerStyle,\n FLOATS,\n featuresOf,\n type Placement,\n type Properties,\n parseColor,\n polygonGeometry,\n rampTexels,\n type Styled,\n stops,\n} from './features.ts';\nimport { Layer, type NetworkLayer } from './layers.ts';\nimport type { LayerHost } from './types.ts';\nimport type { Engine } from './wasm/isard.js';\n\nexport interface ExtrusionStyle<P = Properties> extends FeatureLayerStyle<P> {\n /** CSS color (default `#e4e1dc`) */\n color: Styled<string, P>;\n /** Height of the roof over the ground, metres (default 6) */\n height: Styled<number, P>;\n /** Height of the foot of the walls, metres (default 0) */\n base: Styled<number, P>;\n}\n\nexport interface ExtrusionOptions<P = Properties> extends Partial<ExtrusionStyle<P>>, Placement {\n /** Polygon and MultiPolygon features, as one set (tiles come with `setTile`) */\n data?: FeatureData<P>;\n}\n\n/** Key of a tile of extrusions (see `ExtrusionLayer.setTile`) */\nexport type TileKey = string | number;\n\n/**\n * Polygons as typed arrays, for tiles decoded in a worker (no GeoJSON in between): points in Mercator [0, 1] (x, y\n * interleaved, y towards the south), the first point of each ring and the first ring of each polygon (one more entry\n * than rings and polygons; the first ring of a polygon is its outline), the feature of each polygon\n */\nexport interface PolygonArrays {\n points: Float64Array;\n ringStart: Uint32Array;\n polygonStart: Uint32Array;\n feature: Uint32Array;\n}\n\ninterface Tile<P> {\n /** Batch number in the engine: tiles are drawn, and their features numbered for picking, in this order */\n batch: number;\n /** The properties of the features, which the style reads */\n properties: P[];\n features: Feature<P>[] | undefined;\n arrays: PolygonArrays | undefined;\n values: Float32Array | undefined;\n anchors: Float32Array | undefined;\n}\n\n/** TileKey of the set given as `data` */\nconst DATA = Symbol('data');\n\nexport class ExtrusionLayer<P = Properties> extends Layer {\n private readonly tiles = new Map<TileKey | typeof DATA, Tile<P>>();\n private nextBatch = 1;\n private network: { layer: NetworkLayer; max: number } | undefined;\n\n /** @internal */\n constructor(\n map: LayerHost,\n data: FeatureData<P> | undefined,\n private style: ExtrusionStyle<P>,\n ) {\n super(map);\n if (data) {\n const features = featuresOf(data);\n const properties = features.map((f) => f.properties);\n this.tiles.set(DATA, {\n batch: 0,\n properties,\n features,\n arrays: undefined,\n values: undefined,\n anchors: undefined,\n });\n }\n }\n\n /** Replaces the set given as `data` */\n setData(data: FeatureData<P>): void {\n const features = featuresOf(data);\n this.put(\n DATA,\n features.map((f) => f.properties),\n features,\n undefined,\n );\n }\n\n /** Adds or replaces the buildings of a tile: GeoJSON, or typed arrays with the properties of each feature */\n setTile(key: TileKey, data: FeatureData<P> | { arrays: PolygonArrays; properties: P[] }): void {\n if ('arrays' in data) this.put(key, data.properties, undefined, data.arrays);\n else {\n const features = featuresOf(data);\n this.put(\n key,\n features.map((f) => f.properties),\n features,\n undefined,\n );\n }\n }\n\n removeTile(key: TileKey): void {\n const tile = this.tiles.get(key);\n if (!tile) return;\n this.tiles.delete(key);\n this.map.engine.removeExtrusionBatch(this.id, tile.batch);\n this.map.requestRender();\n }\n\n /** Keys of the tiles held */\n get tileKeys(): TileKey[] {\n return [...this.tiles.keys()].filter((k): k is TileKey => k !== DATA);\n }\n\n /** The properties of the features of a tile (or of the data) */\n properties(key?: TileKey): readonly P[] {\n return this.tiles.get(key ?? DATA)?.properties ?? [];\n }\n\n /** The feature of a picked index (its geometry if given as GeoJSON): tiles are numbered one after the other, in the\n * order they were added */\n featureAt(index: number): Feature<P> | undefined {\n let rest = index;\n for (const tile of [...this.tiles.values()].sort((a, b) => a.batch - b.batch)) {\n const n = tile.properties.length;\n if (rest < n) {\n const properties = tile.properties[rest] as P;\n return tile.features?.[rest] ?? { type: 'Feature', properties, geometry: null };\n }\n rest -= n;\n }\n return undefined;\n }\n\n /** The tile and the index in it of a picked index */\n tileAt(index: number): { key: TileKey | undefined; index: number } | undefined {\n let rest = index;\n for (const [key, tile] of [...this.tiles].sort((a, b) => a[1].batch - b[1].batch)) {\n if (rest < tile.properties.length) return { key: key === DATA ? undefined : key, index: rest };\n rest -= tile.properties.length;\n }\n return undefined;\n }\n\n setStyle(style: Partial<ExtrusionStyle<P>>): void {\n this.style = { ...this.style, ...style };\n const engine = this.map.engine;\n for (const tile of this.tiles.values()) this.sendStyle(engine, this.id, tile);\n this.sendLayer(engine, this.id);\n this.map.requestRender();\n }\n\n setVisible(visible: boolean): void {\n this.setStyle({ visible } as Partial<ExtrusionStyle<P>>);\n }\n\n setFilter(filter: ((properties: P, index: number) => boolean) | undefined): void {\n this.style = { ...this.style, filter };\n for (const tile of this.tiles.values()) this.map.engine.setFeatureMask(this.id, this.mask(tile), tile.batch);\n this.map.requestRender();\n }\n\n /** One value per building of a tile (or of the data), colored through the ramp; NaN keeps a building's color */\n setValues(values: Float32Array | undefined, key?: TileKey): void {\n const tile = this.tiles.get(key ?? DATA);\n if (!tile) return;\n tile.values = values;\n this.map.engine.setFeatureValues(\n this.id,\n values ?? new Float32Array(tile.properties.length).fill(Number.NaN),\n tile.batch,\n );\n this.map.requestRender();\n }\n\n /**\n * Colors the buildings by the node values of a network layer, recolored with it: each building takes min(value(A)\n * + cost from A, value(B) + cost from B) from its anchors (`setAnchors`), through the ramp, up to `max` (above, or\n * unreached: its own color). Undefined: back to the buildings' own values.\n */\n linkNetwork(network: NetworkLayer | undefined, max = Number.POSITIVE_INFINITY): void {\n this.network = network && { layer: network, max };\n this.sendLink(this.map.engine, this.id);\n this.map.requestRender();\n }\n\n /** Per building of a tile (or of the data): node A, node B, cost from A, cost from B (4 floats each) */\n setAnchors(anchors: Float32Array, key?: TileKey): void {\n const tile = this.tiles.get(key ?? DATA);\n if (!tile) return;\n tile.anchors = anchors;\n this.map.engine.setExtrusionAnchors(this.id, tile.batch, anchors);\n this.map.requestRender();\n }\n\n private put(\n key: TileKey | typeof DATA,\n properties: P[],\n features: Feature<P>[] | undefined,\n arrays: PolygonArrays | undefined,\n ): void {\n const old = this.tiles.get(key);\n const tile: Tile<P> = {\n batch: old?.batch ?? (key === DATA ? 0 : this.nextBatch++),\n properties,\n features,\n arrays,\n values: undefined,\n anchors: undefined,\n };\n this.tiles.set(key, tile);\n this.sendTile(this.map.engine, this.id, tile);\n this.map.requestRender();\n }\n\n private mask(tile: Tile<P>): Uint8Array {\n const { filter } = this.style;\n const mask = new Uint8Array(tile.properties.length).fill(255);\n if (filter)\n tile.properties.forEach((p, i) => {\n if (!filter(p, i)) mask[i] = 0;\n });\n return mask;\n }\n\n private sendTile(engine: Engine, id: number, tile: Tile<P>): void {\n const g = tile.arrays ?? polygonGeometry(tile.features ?? []);\n const n = tile.properties.length;\n engine.setExtrusionBatch(id, tile.batch, g.points, g.ringStart, g.polygonStart, g.feature, n);\n this.sendStyle(engine, id, tile);\n if (tile.values) engine.setFeatureValues(id, tile.values, tile.batch);\n if (tile.anchors) engine.setExtrusionAnchors(id, tile.batch, tile.anchors);\n }\n\n private sendStyle(engine: Engine, id: number, tile: Tile<P>): void {\n const { color, height, base } = this.style;\n const out = new Float32Array(tile.properties.length * FLOATS);\n // Constant colors parsed once: a tile has thousands of buildings\n const fixed = typeof color === 'string' ? parseColor(color) : undefined;\n tile.properties.forEach((p, i) => {\n const o = i * FLOATS;\n out.set(fixed ?? parseColor(evaluate(color, p, i)), o);\n out.set(stops(evaluate(height, p, i)), o + 8);\n out.set(stops(evaluate(base, p, i)), o + 16);\n });\n engine.setFeatureStyle(id, out, tile.batch);\n engine.setFeatureMask(id, this.mask(tile), tile.batch);\n }\n\n private sendLayer(engine: Engine, id: number): void {\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 }\n\n private sendLink(engine: Engine, id: number): void {\n const n = this.network;\n // A network removed (or not created) links to nothing\n const network = n && n.layer.id >= 0 ? n.layer.id : undefined;\n engine.linkExtrusionNetwork(id, network, n ? Math.min(n.max, 1e29) : 0);\n }\n\n /** @internal */\n protected create(engine: Engine): number {\n const id = engine.addExtrusions();\n this.sendLayer(engine, id);\n for (const tile of this.tiles.values()) this.sendTile(engine, id, tile);\n // A network created before (on a new engine, the map relinks once every layer is there)\n if (!this.network || this.network.layer.id >= 0) this.sendLink(engine, id);\n return id;\n }\n\n /** @internal On a new engine, the network may come after the buildings: linked once both are there */\n override relink(engine: Engine): void {\n if (this.network) this.sendLink(engine, this.id);\n }\n}\n\nexport function extrusionStyle<P>(options: ExtrusionOptions<P>): ExtrusionStyle<P> {\n const { data: _, before: __, ...rest } = options;\n return {\n opacity: 1,\n minZoom: 0,\n maxZoom: 24,\n visible: true,\n filter: undefined,\n ramp: undefined,\n color: '#e4e1dc',\n height: 6,\n base: 0,\n ...rest,\n };\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,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAC9C,CAAC;AAED,qEAAqE;AACrE,MAAM,UAAU,UAAU,CAAC,IAAU;IACnC,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAU,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5F,MAAM,GA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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,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAmGpC,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,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ACjD,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 { 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"]}