isard 1.2.0 → 1.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 (94) hide show
  1. package/CHANGELOG.md +88 -0
  2. package/README.md +44 -39
  3. package/dist/basemap/pmtileslayer.d.ts +33 -0
  4. package/dist/basemap/pmtileslayer.js +97 -0
  5. package/dist/basemap/pmtileslayer.js.map +1 -0
  6. package/dist/basemap/trees.d.ts +26 -0
  7. package/dist/basemap/trees.js +141 -0
  8. package/dist/basemap/trees.js.map +1 -0
  9. package/dist/basemap/vectorstyle.d.ts +10 -0
  10. package/dist/basemap/vectorstyle.js +35 -0
  11. package/dist/basemap/vectorstyle.js.map +1 -1
  12. package/dist/basemap/vectortiles.d.ts +67 -44
  13. package/dist/basemap/vectortiles.js +386 -302
  14. package/dist/basemap/vectortiles.js.map +1 -1
  15. package/dist/basemap/workerpool.d.ts +17 -0
  16. package/dist/basemap/workerpool.js +194 -0
  17. package/dist/basemap/workerpool.js.map +1 -0
  18. package/dist/basemap.worker.js +2 -2
  19. package/dist/basemap.worker.js.map +15 -8
  20. package/dist/decoder.worker.js +4 -4
  21. package/dist/decoder.worker.js.map +3 -3
  22. package/dist/engine-loader.d.ts +5 -1
  23. package/dist/engine-loader.js +11 -1
  24. package/dist/engine-loader.js.map +1 -1
  25. package/dist/geoplateforme.d.ts +16 -0
  26. package/dist/geoplateforme.js +23 -0
  27. package/dist/geoplateforme.js.map +1 -1
  28. package/dist/index.d.ts +11 -4
  29. package/dist/index.js +9 -2
  30. package/dist/index.js.map +1 -1
  31. package/dist/isard_bg.wasm +0 -0
  32. package/dist/isard_core_bg.wasm +0 -0
  33. package/dist/isard_tess_bg.wasm +0 -0
  34. package/dist/layers/layers.js +9 -0
  35. package/dist/layers/layers.js.map +1 -1
  36. package/dist/layers/vectors.d.ts +60 -0
  37. package/dist/layers/vectors.js +130 -0
  38. package/dist/layers/vectors.js.map +1 -0
  39. package/dist/map/frame-loop.d.ts +3 -0
  40. package/dist/map/frame-loop.js +6 -0
  41. package/dist/map/frame-loop.js.map +1 -1
  42. package/dist/map/raster-source.js +1 -1
  43. package/dist/map/raster-source.js.map +1 -1
  44. package/dist/map/workers.d.ts +1 -1
  45. package/dist/map/workers.js +1 -1
  46. package/dist/map/workers.js.map +1 -1
  47. package/dist/map.d.ts +21 -6
  48. package/dist/map.js +65 -11
  49. package/dist/map.js.map +1 -1
  50. package/dist/react/IsardMap.js +1 -0
  51. package/dist/react/IsardMap.js.map +1 -1
  52. package/dist/react/Swipe.d.ts +11 -4
  53. package/dist/react/Swipe.js +26 -15
  54. package/dist/react/Swipe.js.map +1 -1
  55. package/dist/react/VectorGeometry.d.ts +35 -0
  56. package/dist/react/VectorGeometry.js +82 -0
  57. package/dist/react/VectorGeometry.js.map +1 -0
  58. package/dist/react/context.d.ts +2 -1
  59. package/dist/react/context.js.map +1 -1
  60. package/dist/react/index.d.ts +2 -1
  61. package/dist/react/index.js +2 -1
  62. package/dist/react/index.js.map +1 -1
  63. package/dist/types.d.ts +24 -1
  64. package/dist/types.js.map +1 -1
  65. package/dist/ui/minimap.d.ts +25 -0
  66. package/dist/ui/minimap.js +90 -0
  67. package/dist/ui/minimap.js.map +1 -0
  68. package/dist/ui/scale.d.ts +19 -0
  69. package/dist/ui/scale.js +44 -0
  70. package/dist/ui/scale.js.map +1 -0
  71. package/dist/ui/search.d.ts +25 -0
  72. package/dist/ui/search.js +119 -0
  73. package/dist/ui/search.js.map +1 -0
  74. package/dist/ui/style.js +17 -0
  75. package/dist/ui/style.js.map +1 -1
  76. package/dist/util/sun.d.ts +11 -0
  77. package/dist/util/sun.js +26 -0
  78. package/dist/util/sun.js.map +1 -0
  79. package/dist/wasm/isard.d.ts +82 -7
  80. package/dist/wasm/isard.js +229 -8
  81. package/dist/wasm/isard_core.d.ts +82 -7
  82. package/dist/wasm/isard_core.js +229 -8
  83. package/dist/wasm/isard_tess.d.ts +109 -0
  84. package/dist/wasm/isard_tess.js +398 -0
  85. package/dist/workers/basemap/geometry.d.ts +72 -0
  86. package/dist/workers/basemap/labels.d.ts +8 -0
  87. package/dist/workers/basemap/raster.d.ts +10 -0
  88. package/dist/workers/basemap/tiles.d.ts +65 -0
  89. package/dist/workers/basemap/trees.d.ts +19 -0
  90. package/dist/workers/basemap.worker.d.ts +126 -22
  91. package/dist/workers/basemap.worker.js +72 -551
  92. package/dist/workers/basemap.worker.js.map +1 -1
  93. package/package.json +5 -4
  94. package/vite.js +10 -2
@@ -0,0 +1,35 @@
1
+ /** `<VectorGeometry>`: the fills and lines of a MapLibre style drawn as geometry (`vectorTiles().vectors()`), among the
2
+ * layers of the components */
3
+ import { type ReactNode, type Ref } from 'react';
4
+ import type { Style, StyleLayer } from '../basemap/vectorstyle.ts';
5
+ import type { VectorLayer, VectorSublayer } from '../layers/vectors.ts';
6
+ export interface VectorGeometryProps {
7
+ /** A style URL or object (default OpenFreeMap's Positron); another one makes the layer anew */
8
+ style?: string | Style;
9
+ /** The style layers drawn (default all its fills and lines); another function makes the layer anew, so keep it in a
10
+ * memo or at the module's level */
11
+ layers?: (layer: StyleLayer) => boolean;
12
+ /** The line layers that glow at night (default those whose id names a road); another function makes the layer anew,
13
+ * as `layers` */
14
+ streets?: (layer: StyleLayer) => boolean;
15
+ /** Paint properties over the style's (`setPaintProperty`), by style layer id, or by style layer drawn once the style
16
+ * is loaded (a function of its id, kind, source layer): compared by value, only those changed sent; one taken out
17
+ * keeps its last value */
18
+ paint?: Paint | ((layer: VectorSublayer) => Record<string, unknown> | undefined);
19
+ /** Shown (default true) */
20
+ visible?: boolean;
21
+ /** Its place among the layers of the components (as `<Layer order>`) */
22
+ order?: number;
23
+ /** The layer, once created and each time it is made anew */
24
+ onLayer?: (layer: VectorLayer) => void;
25
+ ref?: Ref<VectorLayer | undefined>;
26
+ }
27
+ /** Paint properties by style layer id */
28
+ type Paint = Record<string, Record<string, unknown>>;
29
+ /**
30
+ * The fills and lines of a MapLibre style drawn as geometry on the globe and the relief (`vectorTiles().vectors()`):
31
+ * sharp at any zoom and pitch, restyled by `paint` without cutting the tiles again, picked by feature
32
+ * (`map.pickFeature`). The ref and `onLayer` give its handle (`VectorLayer`: `layers`, `featureAt`, `ready`)
33
+ */
34
+ export declare const VectorGeometry: (props: VectorGeometryProps) => ReactNode;
35
+ export {};
@@ -0,0 +1,82 @@
1
+ /** `<VectorGeometry>`: the fills and lines of a MapLibre style drawn as geometry (`vectorTiles().vectors()`), among the
2
+ * layers of the components */
3
+ import { forwardRef, useContext, useEffect, useImperativeHandle, useRef, useState, } from 'react';
4
+ import { MapContext, SwipeContext } from "./context.js";
5
+ /** The paint properties of `next` that differ from those of `sent`, as `[layer, name, value]` */
6
+ const changed = (sent, next) => Object.entries(next ?? {}).flatMap(([layer, properties]) => Object.entries(properties)
7
+ .filter(([name, value]) => JSON.stringify(sent?.[layer]?.[name]) !== JSON.stringify(value))
8
+ .map(([name, value]) => [layer, name, value]));
9
+ const VectorGeometryComponent = forwardRef(function VectorGeometry({ style, layers, streets, paint, visible = true, order = 0, onLayer }, ref) {
10
+ const binding = useContext(MapContext);
11
+ const swipe = useContext(SwipeContext);
12
+ const latest = useRef({ order, onLayer });
13
+ /** The paint properties sent to the current layer */
14
+ const sent = useRef(undefined);
15
+ const [layer, setLayer] = useState();
16
+ latest.current = { order, onLayer };
17
+ useImperativeHandle(ref, () => layer, [layer]);
18
+ // The tiles and their geometry layer created once the map is there, in the declared order; made anew when the
19
+ // style, the layers kept or the streets change; the tiles (and their layer) destroyed when unmounted
20
+ useEffect(() => {
21
+ if (!binding)
22
+ return;
23
+ const tiles = binding.map.vectorTiles(style === undefined ? {} : { style });
24
+ const created = tiles.vectors({ ...(layers && { layers }), ...(streets && { streets }) });
25
+ binding.order.place(created, latest.current.order);
26
+ swipe?.set(created);
27
+ sent.current = undefined;
28
+ setLayer(created);
29
+ latest.current.onLayer?.(created);
30
+ return () => {
31
+ binding.order.remove(created);
32
+ swipe?.unset(created);
33
+ tiles.destroy();
34
+ setLayer(undefined);
35
+ };
36
+ }, [binding, swipe, style, layers, streets]);
37
+ // The paint properties changed since the last ones sent (all of them to a layer made anew), those of a function
38
+ // once the style is loaded; a later render or layer drops the wait
39
+ useEffect(() => {
40
+ if (!layer)
41
+ return;
42
+ const apply = (next) => {
43
+ changed(sent.current, next).forEach(([id, name, value]) => {
44
+ layer.setPaintProperty(id, name, value);
45
+ });
46
+ sent.current = next;
47
+ };
48
+ if (typeof paint !== 'function') {
49
+ apply(paint);
50
+ return;
51
+ }
52
+ const wait = { live: true };
53
+ layer.ready.then(() => {
54
+ if (!wait.live)
55
+ return;
56
+ apply(Object.fromEntries(layer.layers.flatMap((l) => {
57
+ const properties = paint(l);
58
+ return properties ? [[l.id, properties]] : [];
59
+ })));
60
+ }, () => undefined);
61
+ return () => {
62
+ wait.live = false;
63
+ };
64
+ }, [layer, paint]);
65
+ // Shown or hidden
66
+ useEffect(() => {
67
+ layer?.setVisible(visible);
68
+ }, [layer, visible]);
69
+ // A new `order`: moved to its new place among the layers of the components
70
+ useEffect(() => {
71
+ if (binding && layer)
72
+ binding.order.place(layer, order, layer);
73
+ }, [binding, layer, order]);
74
+ return null;
75
+ });
76
+ /**
77
+ * The fills and lines of a MapLibre style drawn as geometry on the globe and the relief (`vectorTiles().vectors()`):
78
+ * sharp at any zoom and pitch, restyled by `paint` without cutting the tiles again, picked by feature
79
+ * (`map.pickFeature`). The ref and `onLayer` give its handle (`VectorLayer`: `layers`, `featureAt`, `ready`)
80
+ */
81
+ export const VectorGeometry = VectorGeometryComponent;
82
+ //# sourceMappingURL=VectorGeometry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VectorGeometry.js","sourceRoot":"","sources":["../../src/react/VectorGeometry.tsx"],"names":[],"mappings":"AAAA;8BAC8B;AAE9B,OAAO,EACL,UAAU,EAGV,UAAU,EACV,SAAS,EACT,mBAAmB,EACnB,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AAGf,OAAO,EAAE,UAAU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B,2EAA2E;IAC3E,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,OAAO,IAAI,KAAK;YAAE,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IACjE,CAAC,EAAE,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;IAE5B,OAAO,IAAI,CAAC;AACd,CAAC,CACF,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,uBAAoE,CAAC","sourcesContent":["/** `<VectorGeometry>`: the fills and lines of a MapLibre style drawn as geometry (`vectorTiles().vectors()`), among the\n * layers of the components */\n\nimport {\n forwardRef,\n type ReactNode,\n type Ref,\n useContext,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n} from 'react';\nimport type { Style, StyleLayer } from '../basemap/vectorstyle.ts';\nimport type { VectorLayer, VectorSublayer } from '../layers/vectors.ts';\nimport { MapContext, SwipeContext } from './context.ts';\n\nexport interface VectorGeometryProps {\n /** A style URL or object (default OpenFreeMap's Positron); another one makes the layer anew */\n style?: string | Style;\n /** The style layers drawn (default all its fills and lines); another function makes the layer anew, so keep it in a\n * memo or at the module's level */\n layers?: (layer: StyleLayer) => boolean;\n /** The line layers that glow at night (default those whose id names a road); another function makes the layer anew,\n * as `layers` */\n streets?: (layer: StyleLayer) => boolean;\n /** Paint properties over the style's (`setPaintProperty`), by style layer id, or by style layer drawn once the style\n * is loaded (a function of its id, kind, source layer): compared by value, only those changed sent; one taken out\n * keeps its last value */\n paint?: Paint | ((layer: VectorSublayer) => Record<string, unknown> | undefined);\n /** Shown (default true) */\n visible?: boolean;\n /** Its place among the layers of the components (as `<Layer order>`) */\n order?: number;\n /** The layer, once created and each time it is made anew */\n onLayer?: (layer: VectorLayer) => void;\n ref?: Ref<VectorLayer | undefined>;\n}\n\n/** Paint properties by style layer id */\ntype Paint = Record<string, Record<string, unknown>>;\n\n/** The paint properties of `next` that differ from those of `sent`, as `[layer, name, value]` */\nconst changed = (sent: Paint | undefined, next: Paint | undefined): [layer: string, name: string, value: unknown][] =>\n Object.entries(next ?? {}).flatMap(([layer, properties]) =>\n Object.entries(properties)\n .filter(([name, value]) => JSON.stringify(sent?.[layer]?.[name]) !== JSON.stringify(value))\n .map(([name, value]): [string, string, unknown] => [layer, name, value]),\n );\n\nconst VectorGeometryComponent = forwardRef<VectorLayer | undefined, Omit<VectorGeometryProps, 'ref'>>(\n function VectorGeometry({ style, layers, streets, paint, visible = true, order = 0, onLayer }, ref) {\n const binding = useContext(MapContext);\n const swipe = useContext(SwipeContext);\n const latest = useRef({ order, onLayer });\n /** The paint properties sent to the current layer */\n const sent = useRef<Paint>(undefined);\n const [layer, setLayer] = useState<VectorLayer>();\n\n latest.current = { order, onLayer };\n useImperativeHandle(ref, () => layer, [layer]);\n\n // The tiles and their geometry layer created once the map is there, in the declared order; made anew when the\n // style, the layers kept or the streets change; the tiles (and their layer) destroyed when unmounted\n useEffect(() => {\n if (!binding) return;\n\n const tiles = binding.map.vectorTiles(style === undefined ? {} : { style });\n const created = tiles.vectors({ ...(layers && { layers }), ...(streets && { streets }) });\n\n binding.order.place(created, latest.current.order);\n swipe?.set(created);\n sent.current = undefined;\n setLayer(created);\n latest.current.onLayer?.(created);\n\n return () => {\n binding.order.remove(created);\n swipe?.unset(created);\n tiles.destroy();\n setLayer(undefined);\n };\n }, [binding, swipe, style, layers, streets]);\n\n // The paint properties changed since the last ones sent (all of them to a layer made anew), those of a function\n // once the style is loaded; a later render or layer drops the wait\n useEffect(() => {\n if (!layer) return;\n\n const apply = (next: Paint | undefined) => {\n changed(sent.current, next).forEach(([id, name, value]) => {\n layer.setPaintProperty(id, name, value);\n });\n sent.current = next;\n };\n\n if (typeof paint !== 'function') {\n apply(paint);\n\n return;\n }\n\n const wait = { live: true };\n\n layer.ready.then(\n () => {\n if (!wait.live) return;\n apply(\n Object.fromEntries(\n layer.layers.flatMap((l) => {\n const properties = paint(l);\n\n return properties ? [[l.id, properties]] : [];\n }),\n ),\n );\n },\n () => undefined,\n );\n\n return () => {\n wait.live = false;\n };\n }, [layer, paint]);\n\n // Shown or hidden\n useEffect(() => {\n layer?.setVisible(visible);\n }, [layer, visible]);\n\n // A new `order`: moved to its new place among the layers of the components\n useEffect(() => {\n if (binding && layer) binding.order.place(layer, order, layer);\n }, [binding, layer, order]);\n\n return null;\n },\n);\n\n/**\n * The fills and lines of a MapLibre style drawn as geometry on the globe and the relief (`vectorTiles().vectors()`):\n * sharp at any zoom and pitch, restyled by `paint` without cutting the tiles again, picked by feature\n * (`map.pickFeature`). The ref and `onLayer` give its handle (`VectorLayer`: `layers`, `featureAt`, `ready`)\n */\nexport const VectorGeometry = VectorGeometryComponent as (props: VectorGeometryProps) => ReactNode;\n"]}
@@ -13,10 +13,11 @@ export interface Binding {
13
13
  applyViewsheds(): void;
14
14
  }
15
15
  export declare const MapContext: import("react").Context<Binding | undefined>;
16
- /** The layers of a `<Swipe>` around, its `<Layer>` children joining it */
16
+ /** The layers of a `<Swipe>` around, its `<Layer>` children joining it; `other`: the group of its `<SwipeOther>` */
17
17
  export interface SwipeGroup {
18
18
  set(layer: LayerHandle): void;
19
19
  unset(layer: LayerHandle): void;
20
+ other?: SwipeGroup;
20
21
  }
21
22
  export declare const SwipeContext: import("react").Context<SwipeGroup | undefined>;
22
23
  /** The marker of a `<Marker>` around and its position (a `<Popup>` in it opens on its click, at that position) */
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/react/context.ts"],"names":[],"mappings":"AAAA;uBACuB;AAEvB,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAerE,MAAM,CAAC,MAAM,UAAU,GAAG,aAAa,CAAsB,SAAS,CAAC,CAAC;AAQxE,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAAyB,SAAS,CAAC,CAAC;AAE7E,kHAAkH;AAClH,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,CAAuD,SAAS,CAAC,CAAC;AAE5G,0EAA0E;AAC1E,MAAM,CAAC,MAAM,MAAM,GAAG,GAAuB,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,GAAG,CAAC;AAE5E,mHAAmH;AACnH,MAAM,CAAC,MAAM,WAAW,GAAG,CAA4B,IAAO,EAAE,QAAuC,EAAQ,EAAE;IAC/G,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC;IACrB,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IAEhC,MAAM,CAAC,OAAO,GAAG,QAAQ,CAAC;IAC1B,uGAAuG;IACvG,SAAS,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;AAChF,CAAC,CAAC;AAEF,qFAAqF;AACrF,MAAM,CAAC,MAAM,OAAO,GAAG,CAAmB,MAAS,EAAiD,EAAE,CACpG,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CAEnF,CAAC","sourcesContent":["/** What the components of a map share: the map, the order of their layers, the viewsheds, the swipe and the marker\n * around; the hooks */\n\nimport { createContext, useContext, useEffect, useRef } from 'react';\nimport type { LayerOrder } from '../bind/layers.ts';\nimport type { Layer as LayerHandle } from '../layers/layers.ts';\nimport type { GeoMap } from '../map.ts';\nimport type { LonLat, MapEvents, ViewshedOptions } from '../types.ts';\nimport type { Marker as MarkerHandle } from '../ui/overlay.ts';\n\nexport interface Binding {\n map: GeoMap;\n order: LayerOrder;\n /** The observers of the `<Viewshed>` components, set on the map together */\n viewsheds: Map<object, ViewshedOptions>;\n applyViewsheds(): void;\n}\n\nexport const MapContext = createContext<Binding | undefined>(undefined);\n\n/** The layers of a `<Swipe>` around, its `<Layer>` children joining it */\nexport interface SwipeGroup {\n set(layer: LayerHandle): void;\n unset(layer: LayerHandle): void;\n}\n\nexport const SwipeContext = createContext<SwipeGroup | undefined>(undefined);\n\n/** The marker of a `<Marker>` around and its position (a `<Popup>` in it opens on its click, at that position) */\nexport const MarkerContext = createContext<{ marker: MarkerHandle; lonLat: LonLat } | undefined>(undefined);\n\n/** The map of the `<IsardMap>` around, once created (undefined before) */\nexport const useMap = (): GeoMap | undefined => useContext(MapContext)?.map;\n\n/** Listens to an event of the map around while the component is mounted; the listener may change at each render */\nexport const useMapEvent = <K extends keyof MapEvents>(type: K, listener: (event: MapEvents[K]) => void): void => {\n const map = useMap();\n const latest = useRef(listener);\n\n latest.current = listener;\n // Listening while mounted, to the listener of the last render; stops when unmounted or the map changes\n useEffect(() => map?.on(type, (event) => latest.current(event)), [map, type]);\n};\n\n/** The entries of an object whose value is defined (`exactOptionalPropertyTypes`) */\nexport const defined = <T extends object>(object: T): { [K in keyof T]?: Exclude<T[K], undefined> } =>\n Object.fromEntries(Object.entries(object).filter(([, value]) => value !== undefined)) as {\n [K in keyof T]?: Exclude<T[K], undefined>;\n };\n"]}
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/react/context.ts"],"names":[],"mappings":"AAAA;uBACuB;AAEvB,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAerE,MAAM,CAAC,MAAM,UAAU,GAAG,aAAa,CAAsB,SAAS,CAAC,CAAC;AASxE,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAAyB,SAAS,CAAC,CAAC;AAE7E,kHAAkH;AAClH,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,CAAuD,SAAS,CAAC,CAAC;AAE5G,0EAA0E;AAC1E,MAAM,CAAC,MAAM,MAAM,GAAG,GAAuB,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,GAAG,CAAC;AAE5E,mHAAmH;AACnH,MAAM,CAAC,MAAM,WAAW,GAAG,CAA4B,IAAO,EAAE,QAAuC,EAAQ,EAAE;IAC/G,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC;IACrB,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IAEhC,MAAM,CAAC,OAAO,GAAG,QAAQ,CAAC;IAC1B,uGAAuG;IACvG,SAAS,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;AAChF,CAAC,CAAC;AAEF,qFAAqF;AACrF,MAAM,CAAC,MAAM,OAAO,GAAG,CAAmB,MAAS,EAAiD,EAAE,CACpG,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CAEnF,CAAC","sourcesContent":["/** What the components of a map share: the map, the order of their layers, the viewsheds, the swipe and the marker\n * around; the hooks */\n\nimport { createContext, useContext, useEffect, useRef } from 'react';\nimport type { LayerOrder } from '../bind/layers.ts';\nimport type { Layer as LayerHandle } from '../layers/layers.ts';\nimport type { GeoMap } from '../map.ts';\nimport type { LonLat, MapEvents, ViewshedOptions } from '../types.ts';\nimport type { Marker as MarkerHandle } from '../ui/overlay.ts';\n\nexport interface Binding {\n map: GeoMap;\n order: LayerOrder;\n /** The observers of the `<Viewshed>` components, set on the map together */\n viewsheds: Map<object, ViewshedOptions>;\n applyViewsheds(): void;\n}\n\nexport const MapContext = createContext<Binding | undefined>(undefined);\n\n/** The layers of a `<Swipe>` around, its `<Layer>` children joining it; `other`: the group of its `<SwipeOther>` */\nexport interface SwipeGroup {\n set(layer: LayerHandle): void;\n unset(layer: LayerHandle): void;\n other?: SwipeGroup;\n}\n\nexport const SwipeContext = createContext<SwipeGroup | undefined>(undefined);\n\n/** The marker of a `<Marker>` around and its position (a `<Popup>` in it opens on its click, at that position) */\nexport const MarkerContext = createContext<{ marker: MarkerHandle; lonLat: LonLat } | undefined>(undefined);\n\n/** The map of the `<IsardMap>` around, once created (undefined before) */\nexport const useMap = (): GeoMap | undefined => useContext(MapContext)?.map;\n\n/** Listens to an event of the map around while the component is mounted; the listener may change at each render */\nexport const useMapEvent = <K extends keyof MapEvents>(type: K, listener: (event: MapEvents[K]) => void): void => {\n const map = useMap();\n const latest = useRef(listener);\n\n latest.current = listener;\n // Listening while mounted, to the listener of the last render; stops when unmounted or the map changes\n useEffect(() => map?.on(type, (event) => latest.current(event)), [map, type]);\n};\n\n/** The entries of an object whose value is defined (`exactOptionalPropertyTypes`) */\nexport const defined = <T extends object>(object: T): { [K in keyof T]?: Exclude<T[K], undefined> } =>\n Object.fromEntries(Object.entries(object).filter(([, value]) => value !== undefined)) as {\n [K in keyof T]?: Exclude<T[K], undefined>;\n };\n"]}
@@ -22,5 +22,6 @@ export { Layer, type LayerHandles, type LayerProps, type LayerType } from './Lay
22
22
  export { Marker, type MarkerProps } from './Marker.tsx';
23
23
  export { Panel, type PanelProps } from './Panel.tsx';
24
24
  export { Popup, type PopupProps } from './Popup.tsx';
25
- export { Swipe, type SwipeProps } from './Swipe.tsx';
25
+ export { Swipe, SwipeOther, type SwipeProps } from './Swipe.tsx';
26
+ export { VectorGeometry, type VectorGeometryProps } from './VectorGeometry.tsx';
26
27
  export { Viewshed } from './Viewshed.tsx';
@@ -17,6 +17,7 @@ export { Layer } from "./Layer.js";
17
17
  export { Marker } from "./Marker.js";
18
18
  export { Panel } from "./Panel.js";
19
19
  export { Popup } from "./Popup.js";
20
- export { Swipe } from "./Swipe.js";
20
+ export { Swipe, SwipeOther } from "./Swipe.js";
21
+ export { VectorGeometry } from "./VectorGeometry.js";
21
22
  export { Viewshed } from "./Viewshed.js";
22
23
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAOH,OAAO,EAAE,OAAO,EAAqB,MAAM,cAAe,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAyB,MAAM,kBAAmB,CAAC;AACvE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,QAAQ,EAA0C,MAAM,eAAgB,CAAC;AAClF,OAAO,EAAE,KAAK,EAAsD,MAAM,YAAa,CAAC;AACxF,OAAO,EAAE,MAAM,EAAoB,MAAM,aAAc,CAAC;AACxD,OAAO,EAAE,KAAK,EAAmB,MAAM,YAAa,CAAC;AACrD,OAAO,EAAE,KAAK,EAAmB,MAAM,YAAa,CAAC;AACrD,OAAO,EAAE,KAAK,EAAmB,MAAM,YAAa,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAgB,CAAC","sourcesContent":["/**\n * Isard in React: the map, its layers, markers, popups, panels and effects as components, created when they mount,\n * updated by the least their props need and removed when they unmount.\n *\n * ```tsx\n * <IsardMap preset=\"ign-3d\" center={[2.35, 48.85]} zoom={15} style={{ height: 400 }}>\n * <Layer type=\"lines\" data={routes} color=\"#0057b8\" width={3} />\n * <Marker lonLat={[2.35, 48.85]}><Popup>Here</Popup></Marker>\n * </IsardMap>\n * ```\n */\n\nexport type { Layer as LayerHandle } from '../layers/layers.ts';\nexport type { GeoMap, LayerSpec } from '../map.ts';\nexport type { LonLat } from '../types.ts';\nexport type { Marker as MarkerHandle, Panel as PanelHandle, Popup as PopupHandle } from '../ui/overlay.ts';\nexport type { Camera } from '../wasm/isard.js';\nexport { Control, type ControlProps } from './Control.tsx';\nexport { CustomLayer, type CustomLayerProps } from './CustomLayer.tsx';\nexport { useMap, useMapEvent } from './context.ts';\nexport { IsardMap, type IsardMapProps, type MapEventProps } from './IsardMap.tsx';\nexport { Layer, type LayerHandles, type LayerProps, type LayerType } from './Layer.tsx';\nexport { Marker, type MarkerProps } from './Marker.tsx';\nexport { Panel, type PanelProps } from './Panel.tsx';\nexport { Popup, type PopupProps } from './Popup.tsx';\nexport { Swipe, type SwipeProps } from './Swipe.tsx';\nexport { Viewshed } from './Viewshed.tsx';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAOH,OAAO,EAAE,OAAO,EAAqB,MAAM,cAAe,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAyB,MAAM,kBAAmB,CAAC;AACvE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,QAAQ,EAA0C,MAAM,eAAgB,CAAC;AAClF,OAAO,EAAE,KAAK,EAAsD,MAAM,YAAa,CAAC;AACxF,OAAO,EAAE,MAAM,EAAoB,MAAM,aAAc,CAAC;AACxD,OAAO,EAAE,KAAK,EAAmB,MAAM,YAAa,CAAC;AACrD,OAAO,EAAE,KAAK,EAAmB,MAAM,YAAa,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,UAAU,EAAmB,MAAM,YAAa,CAAC;AACjE,OAAO,EAAE,cAAc,EAA4B,MAAM,qBAAsB,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAgB,CAAC","sourcesContent":["/**\n * Isard in React: the map, its layers, markers, popups, panels and effects as components, created when they mount,\n * updated by the least their props need and removed when they unmount.\n *\n * ```tsx\n * <IsardMap preset=\"ign-3d\" center={[2.35, 48.85]} zoom={15} style={{ height: 400 }}>\n * <Layer type=\"lines\" data={routes} color=\"#0057b8\" width={3} />\n * <Marker lonLat={[2.35, 48.85]}><Popup>Here</Popup></Marker>\n * </IsardMap>\n * ```\n */\n\nexport type { Layer as LayerHandle } from '../layers/layers.ts';\nexport type { GeoMap, LayerSpec } from '../map.ts';\nexport type { LonLat } from '../types.ts';\nexport type { Marker as MarkerHandle, Panel as PanelHandle, Popup as PopupHandle } from '../ui/overlay.ts';\nexport type { Camera } from '../wasm/isard.js';\nexport { Control, type ControlProps } from './Control.tsx';\nexport { CustomLayer, type CustomLayerProps } from './CustomLayer.tsx';\nexport { useMap, useMapEvent } from './context.ts';\nexport { IsardMap, type IsardMapProps, type MapEventProps } from './IsardMap.tsx';\nexport { Layer, type LayerHandles, type LayerProps, type LayerType } from './Layer.tsx';\nexport { Marker, type MarkerProps } from './Marker.tsx';\nexport { Panel, type PanelProps } from './Panel.tsx';\nexport { Popup, type PopupProps } from './Popup.tsx';\nexport { Swipe, SwipeOther, type SwipeProps } from './Swipe.tsx';\nexport { VectorGeometry, type VectorGeometryProps } from './VectorGeometry.tsx';\nexport { Viewshed } from './Viewshed.tsx';\n"]}
package/dist/types.d.ts CHANGED
@@ -74,6 +74,8 @@ export interface GeoMapOptions extends Partial<Camera> {
74
74
  background?: string;
75
75
  /** Space behind the globe: stars and atmosphere halo, fading out as the globe turns flat (default true) */
76
76
  sky?: boolean;
77
+ /** The sun casting the shadows of buildings, trees, models and the relief (`setSun`); none by default */
78
+ sun?: SunOptions;
77
79
  /** Relief under the basemap: true for the body's terrain model (on the Earth the worldwide Terrain Tiles; NASA's on
78
80
  * the Moon and Mars: LOLA, MOLA), one of the Earth's models by name (`'ign'`: France, RGE ALTI), or its options
79
81
  * (default false; on another body, its `url` is required). Network layers are draped on it */
@@ -96,7 +98,7 @@ export interface GeoMapOptions extends Partial<Camera> {
96
98
  /** A preset of map options (`IGN_PRESETS`: `'ign'`, `'ign-3d'`, `'ign-ortho-3d'`), the other options over it */
97
99
  preset?: 'ign' | 'ign-3d' | 'ign-ortho-3d';
98
100
  /** The folder isard's files are served from (its engines, `isard_bg.wasm`, `isard_core_bg.wasm`,
99
- * `isard_points_bg.wasm`, and its workers, `decoder.worker.js`, `basemap.worker.js`): one option for a bundler that
101
+ * `isard_points_bg.wasm`, `isard_tess_bg.wasm`, and its workers, `decoder.worker.js`, `basemap.worker.js`): one option for a bundler that
100
102
  * moves them, the `…Url` options below for each one. `isard/vite` sets it for the whole page; default next to the
101
103
  * module */
102
104
  assetsUrl?: string | URL;
@@ -110,6 +112,10 @@ export interface GeoMapOptions extends Partial<Camera> {
110
112
  /** Where the decoding workers load the point cloud module from (`isard_points_bg.wasm`, the LAZ decoder of COPC),
111
113
  * when a bundler does not resolve the default URL. Loaded with the first point cloud only */
112
114
  pointsWasmUrl?: string | URL;
115
+ /** Where the basemap workers load the tessellation module from (`isard_tess_bg.wasm`: the vector tiles drawn as
116
+ * geometry, `vectorTiles().vectors()`, made ready for the GPU off the main thread), when a bundler does not resolve
117
+ * the default URL. Loaded with the first tile of geometry; without it, the main thread does that work */
118
+ tessWasmUrl?: string | URL;
113
119
  /** Load the engine with 3D Tiles from the start (default false: it is loaded when the first 3D Tiles layer or glTF
114
120
  * model is added, the map then moving its camera and layers onto it, a stall of about a frame or two). For a map that shows 3D Tiles
115
121
  * at once: one engine downloaded instead of two. `'preload'`: the map starts on the engine without 3D Tiles and
@@ -175,6 +181,21 @@ export interface AtmosphereOptions {
175
181
  /** Share of the distance to the far plane over which the ground fades into the fog, 0-1 (default 0.4) */
176
182
  fogGroundBlend?: number;
177
183
  }
184
+ /** The sun casting shadows (`GeoMap.setSun`): where it stands, by date or by hand, and how dark its shadows are */
185
+ export interface SunOptions {
186
+ /** The time: the sun where it stands then over the map's center (default now, unless `azimuth` and `altitude`) */
187
+ date?: Date;
188
+ /** Degrees clockwise from north, with `altitude`: the sun placed by hand */
189
+ azimuth?: number;
190
+ /** Degrees above the horizon; at or under it, no shadows */
191
+ altitude?: number;
192
+ /** How dark the shadows are, 0 to 1 (default 0.35) */
193
+ opacity?: number;
194
+ /** How dark the night is, 0 to 1: the scene tinted in its blue, the windows of the buildings and the streets of
195
+ * `vectors()` lit, the labels light on dark. By default from the sun's altitude: falling from 6° above the horizon
196
+ * to 6° under it */
197
+ night?: number;
198
+ }
178
199
  /** What can be seen from a point (`GeoMap.setViewshed`); with several observers, the colors, the opacity and the
179
200
  * cone's color are the first one's */
180
201
  export interface ViewshedOptions {
@@ -223,6 +244,8 @@ export interface SwipeOptions {
223
244
  layers: readonly Layer[];
224
245
  /** The side they show on (default 'left') */
225
246
  side?: 'left' | 'right';
247
+ /** Layers shown on the other side only: two meshes of the same place, each on its side, never drawn over each other */
248
+ other?: readonly Layer[];
226
249
  }
227
250
  /** Animation of a camera move */
228
251
  export interface AnimationOptions {
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,0CAA0C","sourcesContent":["/** Public types of the `isard` package */\n\nimport type { TileGrid } from './basemap/grid.ts';\nimport type { DecoderUrls } from './engine/decoders.ts';\nimport type { Feature, Ramp, Size } from './layers/features.ts';\nimport type { Layer } from './layers/layers.ts';\nimport type { AttributionOptions } from './ui/controls.ts';\nimport type { Camera, Engine } from './wasm/isard.js';\n\nexport type LonLat = [lon: number, lat: number];\nexport type Point = [x: number, y: number];\n\n/**\n * The named basemaps. OpenFreeMap's vector styles, OpenStreetMap data worldwide, their labels above the other layers:\n * `osm-positron` (light grey, quiet: data over it reads first), `osm-liberty` and `osm-bright` (in colour). The\n * Géoplateforme's (IGN, France): rasters (`ign-plan`, `ign-plan-grey`, `ign-ortho`, the aerial photographs) or vector\n * tiles with their labels (`ign-plan-vector`, `ign-plan-grey-vector`, the PLAN.IGN styles).\n */\nexport type BasemapName =\n | 'osm-positron'\n | 'osm-liberty'\n | 'osm-bright'\n | 'ign-plan'\n | 'ign-plan-grey'\n | 'ign-ortho'\n | 'ign-plan-vector'\n | 'ign-plan-grey-vector'\n | 'none';\n\n/** A basemap by name (see `BasemapName`) */\nexport type Basemap = BasemapName;\n\n/**\n * The Earth's named terrain models. `'terrain-tiles'`: worldwide, the Terrain Tiles of AWS's open data registry\n * (SRTM, EU-DEM, GMTED… merged by Mapzen, 30 m in most places), the sea floor flattened at sea level. `'ign'`: France,\n * the IGN's RGE ALTI from the Géoplateforme (1 to 5 m), raised by the RAF20 geoid to heights above the ellipsoid.\n */\nexport type TerrainModel = 'terrain-tiles' | 'ign';\n\n/** How tiles encode their altitudes: `'float32'`, raw little-endian floats (`image/x-bil;bits=32`, an ArcGIS raw\n * grid); `'terrarium'`, the colors of a PNG, `R × 256 + G + B / 256 - 32768`; `'mapbox'`, those of Terrain-RGB,\n * `(R × 65536 + G × 256 + B) / 10 - 10000` */\nexport type TerrainEncoding = 'float32' | 'terrarium' | 'mapbox';\n\n/**\n * How tiles load and show. 'immediate' (default): everything visible loads, tiles show as soon as they arrive.\n * 'smooth': during flights the levels flown through are skipped, off-center tiles wait while the camera moves, tiles\n * fade in; fewer downloads, for slow networks or GPUs.\n */\nexport type LoadingMode = 'immediate' | 'smooth';\n\n/** 'globe': a sphere at low zoom, blending into Web Mercator between zooms 5 and 7, up to three levels later under a\n * tilted camera (it sees much farther than its center: the horizon stays curved) */\nexport type Projection = 'globe' | 'mercator';\n\n/** A body to draw the map on, other than the named ones (`CelestialBody`) */\nexport interface BodyOptions {\n /** Equatorial radius, metres */\n radius: number;\n /** Flattening of its ellipsoid, 0 for a sphere (default 0) */\n flattening?: number;\n /** An atmosphere: its halo around the globe, true for the Earth's light blue, or a CSS color (its alpha the\n * halo's strength) (default false) */\n atmosphere?: boolean | string;\n /** Color of the globe where no tile covers it (past the Web Mercator latitudes, 85°), a CSS color (default\n * `#808080`) */\n color?: string;\n /** Lowest and highest altitudes of its ground, metres around the ellipsoid: what its relief may raise into view\n * (default ±1 % of the radius) */\n relief?: [lowest: number, highest: number];\n}\n\n/**\n * The body the map is drawn on: 'earth' (WGS 84, the default), 'moon' (a sphere of 1 737 400 m, no atmosphere),\n * 'mars' (a sphere of 3 396 190 m, its equatorial radius, a thin dusty halo; planetocentric latitudes) or another\n * one. Zoom levels keep their meaning on screen (the Web Mercator tile pyramid), their metres follow the body:\n * altitudes, relief, buildings, 3D Tiles. Off the Earth, the map has none of the Earth's defaults: no basemap, no\n * credits, and space for its background; the Moon and Mars have NASA's relief for `terrain: true`.\n */\nexport type CelestialBody = 'earth' | 'moon' | 'mars' | BodyOptions;\n\nexport interface GeoMapOptions extends Partial<Camera> {\n /** The body the map is drawn on (default 'earth'); set at creation */\n body?: CelestialBody;\n /** Default 'globe' */\n projection?: Projection;\n /** Default 'immediate' */\n loading?: LoadingMode;\n /** The basemap (default 'osm-positron'; 'none' off the Earth) */\n basemap?: Basemap;\n /** Opacity of the IGN hillshade over the basemap (France, Géoplateforme), 0 for none (default 0) */\n hillshade?: number;\n /** Color behind the map (sky of tilted flat views), a CSS color (default `#f2f2f0`; black off the Earth) */\n background?: string;\n /** Space behind the globe: stars and atmosphere halo, fading out as the globe turns flat (default true) */\n sky?: boolean;\n /** Relief under the basemap: true for the body's terrain model (on the Earth the worldwide Terrain Tiles; NASA's on\n * the Moon and Mars: LOLA, MOLA), one of the Earth's models by name (`'ign'`: France, RGE ALTI), or its options\n * (default false; on another body, its `url` is required). Network layers are draped on it */\n terrain?: boolean | TerrainModel | TerrainOptions;\n minZoom?: number;\n maxZoom?: number;\n /** Highest pitch, degrees, up to 85 (default 70) */\n maxPitch?: number;\n /** Sky over the plane, seen when the camera is tilted towards the horizon, and the fog the ground fades into\n * (MapLibre's `setSky`); default none: the background color */\n atmosphere?: AtmosphereOptions;\n /** Mouse, touch and keyboard controls (default true) */\n interactive?: boolean;\n /** Keyboard controls once the map has the focus (it is reached with Tab): arrows pan, Shift + arrows rotate and\n * tilt, + and - zoom (Shift: two levels), 0 faces north and levels the view (default true; none when not\n * `interactive`) */\n keyboard?: boolean;\n /** Accessible name of the map, read by screen readers (default 'Map') */\n ariaLabel?: string;\n /** A preset of map options (`IGN_PRESETS`: `'ign'`, `'ign-3d'`, `'ign-ortho-3d'`), the other options over it */\n preset?: 'ign' | 'ign-3d' | 'ign-ortho-3d';\n /** The folder isard's files are served from (its engines, `isard_bg.wasm`, `isard_core_bg.wasm`,\n * `isard_points_bg.wasm`, and its workers, `decoder.worker.js`, `basemap.worker.js`): one option for a bundler that\n * moves them, the `…Url` options below for each one. `isard/vite` sets it for the whole page; default next to the\n * module */\n assetsUrl?: string | URL;\n /** Where to load the engine with 3D Tiles from (`isard_bg.wasm`), when a bundler does not resolve the default URL.\n * Given without `coreWasmUrl`, maps load this engine from the start */\n wasmUrl?: string | URL;\n /** Where to load the engine without 3D Tiles from (`isard_core_bg.wasm`, a third smaller), when a bundler does not\n * resolve the default URL. Maps load it first, and the engine with 3D Tiles (`wasmUrl`) for their first 3D Tiles\n * layer only */\n coreWasmUrl?: string | URL;\n /** Where the decoding workers load the point cloud module from (`isard_points_bg.wasm`, the LAZ decoder of COPC),\n * when a bundler does not resolve the default URL. Loaded with the first point cloud only */\n pointsWasmUrl?: string | URL;\n /** Load the engine with 3D Tiles from the start (default false: it is loaded when the first 3D Tiles layer or glTF\n * model is added, the map then moving its camera and layers onto it, a stall of about a frame or two). For a map that shows 3D Tiles\n * at once: one engine downloaded instead of two. `'preload'`: the map starts on the engine without 3D Tiles and\n * downloads and compiles the other once idle, without running it: its first 3D Tiles layer does not wait for the\n * download (for a map that will show 3D Tiles later, on demand) */\n tiles3d?: boolean | 'preload';\n /** Where to load the vector basemap worker from, when a bundler does not resolve the default URL */\n basemapWorkerUrl?: string | URL;\n /** Texture size of the vector basemap's tiles, pixels (default 512: lines and edges sharp at every zoom on a screen\n * of pixel ratio 1). 256: a quarter of the drawing in the workers, of the uploads and of the GPU memory, for lines\n * and edges a little softer between two zoom levels (the tiles are shown 181 to 362 CSS pixels wide) */\n basemapTileSize?: number;\n /** Glyphs of the symbol layers: a URL with `{fontstack}` and `{range}` (MapLibre's glyph format; default\n * OpenFreeMap's fonts, Noto Sans). A vector basemap's labels take the glyphs of its style */\n glyphs?: string;\n /** Workers decoding 3D Tiles off the main thread: a count, or false to decode on the main thread (default: cores - 1,\n * 1 to 4). False (or 0) also decodes the PNG relief and reprojects the equirectangular rasters on the main thread,\n * else done by the vector basemap's workers */\n workers?: number | false;\n /** Where to load the decoding worker from, when a bundler does not resolve the default URL */\n workerUrl?: string | URL;\n /** Folders of the Draco and Basis Universal decoders, loaded by the workers on first use (default: the official\n * builds on gstatic.com and jsDelivr; self-host them for offline or locked-down networks). They run through\n * `new Function`: a Content Security Policy needs `'unsafe-eval'` (see `DecoderUrls`) */\n decoders?: Partial<DecoderUrls>;\n /** Credits at the bottom right: false for none, or its options (default true: the credits of the basemap,\n * hillshade and relief in use, compact on maps narrower than 640 px) */\n attributionControl?: boolean | AttributionOptions;\n}\n\nexport interface TerrainOptions {\n /** One of the Earth's named models (default `'terrain-tiles'` on the Earth); unused with a `url` */\n model?: TerrainModel;\n /** Altitudes of 256 × 256 tiles in `encoding`: a WMS GetMap URL with {bbox} (EPSG:3857 on the Earth, the body's\n * Mercator metres elsewhere: the sphere of its radius), a tile URL with {z}, {x} and {y}, or an ArcGIS image service\n * (a URL ending in `/ImageServer`), asked for raw altitudes in the body's Mercator (default: the `model`'s; on the\n * Moon and Mars, NASA's Trek LOLA and MOLA models) */\n url?: string;\n /** How the tiles of `url` encode their altitudes (default `'float32'`); `'terrarium'` and `'mapbox'` take a URL with\n * {z}, {x} and {y} */\n encoding?: TerrainEncoding;\n /** Vertical exaggeration, 1 for the true relief (default 1) */\n exaggeration?: number;\n /** Finest level of the relief, up to 15 (default 15; 14 for the Terrain Tiles, 8 for the Moon's and Mars's models). It\n * starts at level 6 on the Earth, coarser on bodies of a larger relief for their size (3 on the Moon and Mars) */\n maxZoom?: number;\n /** Altitudes over mainland France raised by the height of the RAF20 geoid (the French one, 0 away from France), to\n * heights above the ellipsoid (those of 3D Tiles); false keeps the altitudes as served (NGF-IGN69 for the IGN's)\n * (default true for the `'ign'` model, false otherwise) */\n geoid?: boolean;\n}\n\n/** Sky, horizon and fog over the plane, with the names and meanings of MapLibre's `setSky` */\nexport interface AtmosphereOptions {\n /** A CSS color (default `#9cc7ec`) */\n skyColor?: string;\n /** (default `#e8f1f8`) */\n horizonColor?: string;\n /** (default `#f2f5f8`) */\n fogColor?: string;\n /** Blend from the horizon to the sky color, share of the field of view above the horizon, 0-1 (default 0.6) */\n skyHorizonBlend?: number;\n /** Blend from the horizon to the fog color below the horizon, 0-1 (default 0.7) */\n horizonFogBlend?: number;\n /** Share of the distance to the far plane over which the ground fades into the fog, 0-1 (default 0.4) */\n fogGroundBlend?: number;\n}\n\n/** What can be seen from a point (`GeoMap.setViewshed`); with several observers, the colors, the opacity and the\n * cone's color are the first one's */\nexport interface ViewshedOptions {\n /** The observer */\n position: LonLat;\n /** Metres above the ground (default 1.7, eye level) */\n height?: number;\n /** Metres around the observer that are tinted (default 1000) */\n range?: number;\n /** A CSS color for what is seen (default `#2f9e44`) */\n visibleColor?: string;\n /** A CSS color for what is hidden (default `#e03131`) */\n hiddenColor?: string;\n /** How strongly the colors tint the scene, multiplied into it so that its textures and shading stay, 0-1 (default\n * 0.7) */\n opacity?: number;\n /** A CSS color for the cone drawn in 3D (one way only): its fan through the axis, at the eye's height and tilted\n * with it, from the eye to the range; solid where nothing hides it, faint behind the scene; none by default */\n coneColor?: string;\n /** To look one way only (a camera, a lookout), degrees clockwise from north; all around without it */\n direction?: number;\n /** Degrees above the horizon the cone looks, negative below (default 0) */\n tilt?: number;\n /** Angle of view across, degrees (default 60) */\n fov?: number;\n /** Angle of view up and down, degrees (default 40) */\n verticalFov?: number;\n}\n\n/** An eye at street level (`GeoMap.setFirstPerson`) */\nexport interface FirstPersonView {\n /** Where it stands */\n lonLat: LonLat;\n /** Metres above the ground (default 1.7) */\n height?: number;\n /** Degrees clockwise from north it looks to */\n bearing: number;\n /** Degrees from straight down: 90 level (the default), 180 straight up */\n pitch?: number;\n /** Vertical field of view, degrees (default 75) */\n fov?: number;\n}\n\n/** Layers shown on one side of a vertical line only (`GeoMap.setSwipe`) */\nexport interface SwipeOptions {\n /** CSS pixels from the left of the map */\n position: number;\n layers: readonly Layer[];\n /** The side they show on (default 'left') */\n side?: 'left' | 'right';\n}\n\n/** Animation of a camera move */\nexport interface AnimationOptions {\n /** Milliseconds */\n duration?: number;\n /** Progress over time, both 0 to 1 */\n easing?: (t: number) => number;\n}\n\nexport interface FlyToOptions extends AnimationOptions {\n /** How far the flight zooms out on its way, as MapLibre's `curve` (default 1.42) */\n curve?: number;\n /** Average speed in screens per second when `duration` is not given (default 1.2) */\n speed?: number;\n}\n\n/**\n * Tile grid of a raster's URL. 'mercator': Web Mercator (XYZ, WMTS PM), the engine's own. 'equirectangular':\n * longitudes and latitudes (Plate Carrée, EPSG:4326-like), two 256 px tiles side by side at level 0, rows from the\n * north (NASA's Trek WMTS, WorldCRS84Quad). A `TileGrid`: the tile matrices of a WMTS in any CRS (Lambert-93…), or a\n * WMS asked for each tile's box in its CRS. The last two are reprojected into Web Mercator tiles by the map's workers\n * (in the page with `workers: false`).\n */\nexport type RasterGrid = 'mercator' | 'equirectangular' | TileGrid;\n\n/** What `RasterLayer.setStyle` changes */\nexport interface RasterStyle {\n opacity: number;\n /** 0 = greyscale, 1 = original colors */\n saturation: number;\n}\n\nexport interface RasterOptions {\n /** Tile URL with {z}, {x} and {y} (256 px tiles); unused with a `loader` */\n url: string;\n /** Tile grid of `url` (default 'mercator'); with 'equirectangular', `minZoom` and `maxZoom` are levels of that\n * grid; with a `TileGrid`, they are map zooms, by default those its matrices span */\n grid?: RasterGrid;\n minZoom?: number;\n maxZoom?: number;\n opacity?: number;\n /** 0 = greyscale, 1 = original colors */\n saturation?: number;\n /** Side of the tiles' textures, pixels (default 256): more for sharper tiles drawn by a `loader` */\n size?: number;\n /** Draws each tile instead of fetching `url`: an image of `size` × `size`, null for nothing there; a rejection is\n * retried like a network error */\n loader?: (z: number, x: number, y: number, signal: AbortSignal) => Promise<ImageBitmap | null>;\n /** Credits of the tiles, HTML: shown by the attribution control while the layer is on the map */\n attribution?: string;\n}\n\nexport interface NetworkStyle {\n /** Line width, CSS pixels, or zoom stops `[[zoom, width], …]` (default 2) */\n width: Size;\n /** Values above are drawn as unreached (default 1800) */\n max: number;\n /** Darker line every `contour` value units, 0 for none (default 0) */\n contour: number;\n opacity: number;\n /** Width of the halo drawn under the lines, CSS pixels or zoom stops, 0 for none (default 0): wide and faint, the\n * reached streets add up into a heat map that fills the blocks */\n halo: Size;\n /** Opacity of the halo at the middle of a line, fading quadratically to its sides (default 0.11) */\n haloOpacity: number;\n /** Colors from 0 to `max`: `[[fraction of max, color], …]` (default green to red) */\n ramp: Ramp | undefined;\n /** Color of the parts beyond `max` or unreached (default `rgba(140, 140, 140, 0.25)`) */\n unreachedColor: string;\n /** Share of `max` over which the colors fade out before it, 0 to 1 (default 0) */\n fade: number;\n}\n\nexport interface NetworkOptions extends Partial<NetworkStyle> {\n /** Node coordinates in degrees: lon0, lat0, lon1, lat1… */\n nodes: Float64Array;\n /** Edges as node index pairs: a0, b0, a1, b1… */\n edges: Uint32Array;\n /** Line of each edge, from A to B: the points of edge e are `points[start[e] .. start[e + 1]]` (lon, lat pairs,\n * counted in points); with fewer than two points an edge is straight. Default: all straight. */\n lines?: { start: Uint32Array; points: Float64Array };\n /** Per edge, the cost of travelling it from A to B then from B to A, in value units (Infinity: closed that way;\n * closed both ways: not drawn). A point along an edge then takes the quickest way there, min(value(A) + cost from\n * A, value(B) + cost from B), as a travel time does. Without costs, values are interpolated along the edges. */\n costs?: Float32Array;\n /** Width factor of each edge (default 1): rail lines wider than streets */\n edgeWidths?: Float32Array;\n}\n\nexport interface Tiles3dStyle {\n /** Screen-space error (CSS pixels) above which a tile is refined: 16 by default, lower is finer and heavier */\n maxScreenSpaceError: number;\n opacity: number;\n /** Size of the points of point cloud tiles (`.pnts`, glTF points), CSS pixels: 2 by default */\n pointSize?: number;\n /** A CSS color multiplying the textures of the meshes, the color of the untextured ones (buildings without\n * textures are light grey without it); none by default */\n color?: string;\n}\n\nexport interface Tiles3dOptions extends Partial<Tiles3dStyle> {\n /** URL of a `tileset.json` (3D Tiles 1.0 b3dm and pnts, 1.1 glb meshes and points, external tilesets) */\n url: string;\n /** Its heights are altitudes above the geoid (NGF-IGN69), as the IGN's Bâtiments 3D, rather than above the\n * ellipsoid (3D Tiles as specified): each tile raised by the RAF20 geoid, onto the IGN relief (default false) */\n geoid?: boolean;\n}\n\nexport interface MapPointerEvent {\n point: Point;\n /** Undefined above the horizon */\n lonLat: LonLat | undefined;\n}\n\n/** What 'hoverfeature' found under the pointer */\nexport interface MapHoverFeatureEvent extends MapPointerEvent {\n /** The feature under the pointer (see `GeoMap.pickFeature`), undefined if none */\n hit: FeatureHit | undefined;\n}\n\n/** A picked feature: its layer handle, its index there and, for line, circle, fill, extrusion, point cloud and 3D\n * Tiles layers, the feature itself (a building of 3D Tiles with its properties) */\nexport interface FeatureHit {\n layer: Layer;\n index: number;\n feature: Feature | undefined;\n}\n\nexport interface MapEvents {\n /** The camera started moving (a gesture, an animation or `setCamera`) */\n movestart: Camera;\n /** The camera moved */\n move: Camera;\n /** The camera stopped: no gesture held, no animation running */\n moveend: Camera;\n /** The map changed size (CSS pixels) */\n resize: { width: number; height: number };\n /** The pointer moved over the map (at most once per frame, not while dragging) */\n hover: MapPointerEvent;\n /** What is under the pointer, picked without stalling the GPU: a frame or two after 'hover', only while listened to\n * (radius and layers in `GeoMap.hoverPicking`) */\n hoverfeature: MapHoverFeatureEvent;\n /** Click without drag */\n click: MapPointerEvent;\n /** A frame was drawn; duration of the engine call in milliseconds */\n render: { ms: number };\n /** Everything in view is loaded and drawn, nothing moves: the end of a load, once after each change (as MapLibre's\n * `idle`). Tiles requested by the first frame count, so it never fires before they arrive. */\n idle: Record<string, never>;\n /** The pointer left the canvas (a mouse going out of the map, or onto a control or marker) */\n leave: Record<string, never>;\n}\n\n/** What a layer handle needs from its map */\nexport interface LayerHost {\n readonly engine: Engine;\n requestRender(): void;\n /** Forgets a removed layer */\n detach(layer: Layer): void;\n /** Moves a layer under `before`, or on top */\n moveLayer(layer: Layer, before: Layer | undefined): void;\n /** A layer created again in the engine (new id): put at the place of its old id, which is removed */\n replaceLayer(layer: Layer, old: number): void;\n /** Resolves once the map is idle (everything in view loaded and drawn) */\n whenIdle(): Promise<void>;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,0CAA0C","sourcesContent":["/** Public types of the `isard` package */\n\nimport type { TileGrid } from './basemap/grid.ts';\nimport type { DecoderUrls } from './engine/decoders.ts';\nimport type { Feature, Ramp, Size } from './layers/features.ts';\nimport type { Layer } from './layers/layers.ts';\nimport type { AttributionOptions } from './ui/controls.ts';\nimport type { Camera, Engine } from './wasm/isard.js';\n\nexport type LonLat = [lon: number, lat: number];\nexport type Point = [x: number, y: number];\n\n/**\n * The named basemaps. OpenFreeMap's vector styles, OpenStreetMap data worldwide, their labels above the other layers:\n * `osm-positron` (light grey, quiet: data over it reads first), `osm-liberty` and `osm-bright` (in colour). The\n * Géoplateforme's (IGN, France): rasters (`ign-plan`, `ign-plan-grey`, `ign-ortho`, the aerial photographs) or vector\n * tiles with their labels (`ign-plan-vector`, `ign-plan-grey-vector`, the PLAN.IGN styles).\n */\nexport type BasemapName =\n | 'osm-positron'\n | 'osm-liberty'\n | 'osm-bright'\n | 'ign-plan'\n | 'ign-plan-grey'\n | 'ign-ortho'\n | 'ign-plan-vector'\n | 'ign-plan-grey-vector'\n | 'none';\n\n/** A basemap by name (see `BasemapName`) */\nexport type Basemap = BasemapName;\n\n/**\n * The Earth's named terrain models. `'terrain-tiles'`: worldwide, the Terrain Tiles of AWS's open data registry\n * (SRTM, EU-DEM, GMTED… merged by Mapzen, 30 m in most places), the sea floor flattened at sea level. `'ign'`: France,\n * the IGN's RGE ALTI from the Géoplateforme (1 to 5 m), raised by the RAF20 geoid to heights above the ellipsoid.\n */\nexport type TerrainModel = 'terrain-tiles' | 'ign';\n\n/** How tiles encode their altitudes: `'float32'`, raw little-endian floats (`image/x-bil;bits=32`, an ArcGIS raw\n * grid); `'terrarium'`, the colors of a PNG, `R × 256 + G + B / 256 - 32768`; `'mapbox'`, those of Terrain-RGB,\n * `(R × 65536 + G × 256 + B) / 10 - 10000` */\nexport type TerrainEncoding = 'float32' | 'terrarium' | 'mapbox';\n\n/**\n * How tiles load and show. 'immediate' (default): everything visible loads, tiles show as soon as they arrive.\n * 'smooth': during flights the levels flown through are skipped, off-center tiles wait while the camera moves, tiles\n * fade in; fewer downloads, for slow networks or GPUs.\n */\nexport type LoadingMode = 'immediate' | 'smooth';\n\n/** 'globe': a sphere at low zoom, blending into Web Mercator between zooms 5 and 7, up to three levels later under a\n * tilted camera (it sees much farther than its center: the horizon stays curved) */\nexport type Projection = 'globe' | 'mercator';\n\n/** A body to draw the map on, other than the named ones (`CelestialBody`) */\nexport interface BodyOptions {\n /** Equatorial radius, metres */\n radius: number;\n /** Flattening of its ellipsoid, 0 for a sphere (default 0) */\n flattening?: number;\n /** An atmosphere: its halo around the globe, true for the Earth's light blue, or a CSS color (its alpha the\n * halo's strength) (default false) */\n atmosphere?: boolean | string;\n /** Color of the globe where no tile covers it (past the Web Mercator latitudes, 85°), a CSS color (default\n * `#808080`) */\n color?: string;\n /** Lowest and highest altitudes of its ground, metres around the ellipsoid: what its relief may raise into view\n * (default ±1 % of the radius) */\n relief?: [lowest: number, highest: number];\n}\n\n/**\n * The body the map is drawn on: 'earth' (WGS 84, the default), 'moon' (a sphere of 1 737 400 m, no atmosphere),\n * 'mars' (a sphere of 3 396 190 m, its equatorial radius, a thin dusty halo; planetocentric latitudes) or another\n * one. Zoom levels keep their meaning on screen (the Web Mercator tile pyramid), their metres follow the body:\n * altitudes, relief, buildings, 3D Tiles. Off the Earth, the map has none of the Earth's defaults: no basemap, no\n * credits, and space for its background; the Moon and Mars have NASA's relief for `terrain: true`.\n */\nexport type CelestialBody = 'earth' | 'moon' | 'mars' | BodyOptions;\n\nexport interface GeoMapOptions extends Partial<Camera> {\n /** The body the map is drawn on (default 'earth'); set at creation */\n body?: CelestialBody;\n /** Default 'globe' */\n projection?: Projection;\n /** Default 'immediate' */\n loading?: LoadingMode;\n /** The basemap (default 'osm-positron'; 'none' off the Earth) */\n basemap?: Basemap;\n /** Opacity of the IGN hillshade over the basemap (France, Géoplateforme), 0 for none (default 0) */\n hillshade?: number;\n /** Color behind the map (sky of tilted flat views), a CSS color (default `#f2f2f0`; black off the Earth) */\n background?: string;\n /** Space behind the globe: stars and atmosphere halo, fading out as the globe turns flat (default true) */\n sky?: boolean;\n /** The sun casting the shadows of buildings, trees, models and the relief (`setSun`); none by default */\n sun?: SunOptions;\n /** Relief under the basemap: true for the body's terrain model (on the Earth the worldwide Terrain Tiles; NASA's on\n * the Moon and Mars: LOLA, MOLA), one of the Earth's models by name (`'ign'`: France, RGE ALTI), or its options\n * (default false; on another body, its `url` is required). Network layers are draped on it */\n terrain?: boolean | TerrainModel | TerrainOptions;\n minZoom?: number;\n maxZoom?: number;\n /** Highest pitch, degrees, up to 85 (default 70) */\n maxPitch?: number;\n /** Sky over the plane, seen when the camera is tilted towards the horizon, and the fog the ground fades into\n * (MapLibre's `setSky`); default none: the background color */\n atmosphere?: AtmosphereOptions;\n /** Mouse, touch and keyboard controls (default true) */\n interactive?: boolean;\n /** Keyboard controls once the map has the focus (it is reached with Tab): arrows pan, Shift + arrows rotate and\n * tilt, + and - zoom (Shift: two levels), 0 faces north and levels the view (default true; none when not\n * `interactive`) */\n keyboard?: boolean;\n /** Accessible name of the map, read by screen readers (default 'Map') */\n ariaLabel?: string;\n /** A preset of map options (`IGN_PRESETS`: `'ign'`, `'ign-3d'`, `'ign-ortho-3d'`), the other options over it */\n preset?: 'ign' | 'ign-3d' | 'ign-ortho-3d';\n /** The folder isard's files are served from (its engines, `isard_bg.wasm`, `isard_core_bg.wasm`,\n * `isard_points_bg.wasm`, `isard_tess_bg.wasm`, and its workers, `decoder.worker.js`, `basemap.worker.js`): one option for a bundler that\n * moves them, the `…Url` options below for each one. `isard/vite` sets it for the whole page; default next to the\n * module */\n assetsUrl?: string | URL;\n /** Where to load the engine with 3D Tiles from (`isard_bg.wasm`), when a bundler does not resolve the default URL.\n * Given without `coreWasmUrl`, maps load this engine from the start */\n wasmUrl?: string | URL;\n /** Where to load the engine without 3D Tiles from (`isard_core_bg.wasm`, a third smaller), when a bundler does not\n * resolve the default URL. Maps load it first, and the engine with 3D Tiles (`wasmUrl`) for their first 3D Tiles\n * layer only */\n coreWasmUrl?: string | URL;\n /** Where the decoding workers load the point cloud module from (`isard_points_bg.wasm`, the LAZ decoder of COPC),\n * when a bundler does not resolve the default URL. Loaded with the first point cloud only */\n pointsWasmUrl?: string | URL;\n /** Where the basemap workers load the tessellation module from (`isard_tess_bg.wasm`: the vector tiles drawn as\n * geometry, `vectorTiles().vectors()`, made ready for the GPU off the main thread), when a bundler does not resolve\n * the default URL. Loaded with the first tile of geometry; without it, the main thread does that work */\n tessWasmUrl?: string | URL;\n /** Load the engine with 3D Tiles from the start (default false: it is loaded when the first 3D Tiles layer or glTF\n * model is added, the map then moving its camera and layers onto it, a stall of about a frame or two). For a map that shows 3D Tiles\n * at once: one engine downloaded instead of two. `'preload'`: the map starts on the engine without 3D Tiles and\n * downloads and compiles the other once idle, without running it: its first 3D Tiles layer does not wait for the\n * download (for a map that will show 3D Tiles later, on demand) */\n tiles3d?: boolean | 'preload';\n /** Where to load the vector basemap worker from, when a bundler does not resolve the default URL */\n basemapWorkerUrl?: string | URL;\n /** Texture size of the vector basemap's tiles, pixels (default 512: lines and edges sharp at every zoom on a screen\n * of pixel ratio 1). 256: a quarter of the drawing in the workers, of the uploads and of the GPU memory, for lines\n * and edges a little softer between two zoom levels (the tiles are shown 181 to 362 CSS pixels wide) */\n basemapTileSize?: number;\n /** Glyphs of the symbol layers: a URL with `{fontstack}` and `{range}` (MapLibre's glyph format; default\n * OpenFreeMap's fonts, Noto Sans). A vector basemap's labels take the glyphs of its style */\n glyphs?: string;\n /** Workers decoding 3D Tiles off the main thread: a count, or false to decode on the main thread (default: cores - 1,\n * 1 to 4). False (or 0) also decodes the PNG relief and reprojects the equirectangular rasters on the main thread,\n * else done by the vector basemap's workers */\n workers?: number | false;\n /** Where to load the decoding worker from, when a bundler does not resolve the default URL */\n workerUrl?: string | URL;\n /** Folders of the Draco and Basis Universal decoders, loaded by the workers on first use (default: the official\n * builds on gstatic.com and jsDelivr; self-host them for offline or locked-down networks). They run through\n * `new Function`: a Content Security Policy needs `'unsafe-eval'` (see `DecoderUrls`) */\n decoders?: Partial<DecoderUrls>;\n /** Credits at the bottom right: false for none, or its options (default true: the credits of the basemap,\n * hillshade and relief in use, compact on maps narrower than 640 px) */\n attributionControl?: boolean | AttributionOptions;\n}\n\nexport interface TerrainOptions {\n /** One of the Earth's named models (default `'terrain-tiles'` on the Earth); unused with a `url` */\n model?: TerrainModel;\n /** Altitudes of 256 × 256 tiles in `encoding`: a WMS GetMap URL with {bbox} (EPSG:3857 on the Earth, the body's\n * Mercator metres elsewhere: the sphere of its radius), a tile URL with {z}, {x} and {y}, or an ArcGIS image service\n * (a URL ending in `/ImageServer`), asked for raw altitudes in the body's Mercator (default: the `model`'s; on the\n * Moon and Mars, NASA's Trek LOLA and MOLA models) */\n url?: string;\n /** How the tiles of `url` encode their altitudes (default `'float32'`); `'terrarium'` and `'mapbox'` take a URL with\n * {z}, {x} and {y} */\n encoding?: TerrainEncoding;\n /** Vertical exaggeration, 1 for the true relief (default 1) */\n exaggeration?: number;\n /** Finest level of the relief, up to 15 (default 15; 14 for the Terrain Tiles, 8 for the Moon's and Mars's models). It\n * starts at level 6 on the Earth, coarser on bodies of a larger relief for their size (3 on the Moon and Mars) */\n maxZoom?: number;\n /** Altitudes over mainland France raised by the height of the RAF20 geoid (the French one, 0 away from France), to\n * heights above the ellipsoid (those of 3D Tiles); false keeps the altitudes as served (NGF-IGN69 for the IGN's)\n * (default true for the `'ign'` model, false otherwise) */\n geoid?: boolean;\n}\n\n/** Sky, horizon and fog over the plane, with the names and meanings of MapLibre's `setSky` */\nexport interface AtmosphereOptions {\n /** A CSS color (default `#9cc7ec`) */\n skyColor?: string;\n /** (default `#e8f1f8`) */\n horizonColor?: string;\n /** (default `#f2f5f8`) */\n fogColor?: string;\n /** Blend from the horizon to the sky color, share of the field of view above the horizon, 0-1 (default 0.6) */\n skyHorizonBlend?: number;\n /** Blend from the horizon to the fog color below the horizon, 0-1 (default 0.7) */\n horizonFogBlend?: number;\n /** Share of the distance to the far plane over which the ground fades into the fog, 0-1 (default 0.4) */\n fogGroundBlend?: number;\n}\n\n/** The sun casting shadows (`GeoMap.setSun`): where it stands, by date or by hand, and how dark its shadows are */\nexport interface SunOptions {\n /** The time: the sun where it stands then over the map's center (default now, unless `azimuth` and `altitude`) */\n date?: Date;\n /** Degrees clockwise from north, with `altitude`: the sun placed by hand */\n azimuth?: number;\n /** Degrees above the horizon; at or under it, no shadows */\n altitude?: number;\n /** How dark the shadows are, 0 to 1 (default 0.35) */\n opacity?: number;\n /** How dark the night is, 0 to 1: the scene tinted in its blue, the windows of the buildings and the streets of\n * `vectors()` lit, the labels light on dark. By default from the sun's altitude: falling from 6° above the horizon\n * to 6° under it */\n night?: number;\n}\n\n/** What can be seen from a point (`GeoMap.setViewshed`); with several observers, the colors, the opacity and the\n * cone's color are the first one's */\nexport interface ViewshedOptions {\n /** The observer */\n position: LonLat;\n /** Metres above the ground (default 1.7, eye level) */\n height?: number;\n /** Metres around the observer that are tinted (default 1000) */\n range?: number;\n /** A CSS color for what is seen (default `#2f9e44`) */\n visibleColor?: string;\n /** A CSS color for what is hidden (default `#e03131`) */\n hiddenColor?: string;\n /** How strongly the colors tint the scene, multiplied into it so that its textures and shading stay, 0-1 (default\n * 0.7) */\n opacity?: number;\n /** A CSS color for the cone drawn in 3D (one way only): its fan through the axis, at the eye's height and tilted\n * with it, from the eye to the range; solid where nothing hides it, faint behind the scene; none by default */\n coneColor?: string;\n /** To look one way only (a camera, a lookout), degrees clockwise from north; all around without it */\n direction?: number;\n /** Degrees above the horizon the cone looks, negative below (default 0) */\n tilt?: number;\n /** Angle of view across, degrees (default 60) */\n fov?: number;\n /** Angle of view up and down, degrees (default 40) */\n verticalFov?: number;\n}\n\n/** An eye at street level (`GeoMap.setFirstPerson`) */\nexport interface FirstPersonView {\n /** Where it stands */\n lonLat: LonLat;\n /** Metres above the ground (default 1.7) */\n height?: number;\n /** Degrees clockwise from north it looks to */\n bearing: number;\n /** Degrees from straight down: 90 level (the default), 180 straight up */\n pitch?: number;\n /** Vertical field of view, degrees (default 75) */\n fov?: number;\n}\n\n/** Layers shown on one side of a vertical line only (`GeoMap.setSwipe`) */\nexport interface SwipeOptions {\n /** CSS pixels from the left of the map */\n position: number;\n layers: readonly Layer[];\n /** The side they show on (default 'left') */\n side?: 'left' | 'right';\n /** Layers shown on the other side only: two meshes of the same place, each on its side, never drawn over each other */\n other?: readonly Layer[];\n}\n\n/** Animation of a camera move */\nexport interface AnimationOptions {\n /** Milliseconds */\n duration?: number;\n /** Progress over time, both 0 to 1 */\n easing?: (t: number) => number;\n}\n\nexport interface FlyToOptions extends AnimationOptions {\n /** How far the flight zooms out on its way, as MapLibre's `curve` (default 1.42) */\n curve?: number;\n /** Average speed in screens per second when `duration` is not given (default 1.2) */\n speed?: number;\n}\n\n/**\n * Tile grid of a raster's URL. 'mercator': Web Mercator (XYZ, WMTS PM), the engine's own. 'equirectangular':\n * longitudes and latitudes (Plate Carrée, EPSG:4326-like), two 256 px tiles side by side at level 0, rows from the\n * north (NASA's Trek WMTS, WorldCRS84Quad). A `TileGrid`: the tile matrices of a WMTS in any CRS (Lambert-93…), or a\n * WMS asked for each tile's box in its CRS. The last two are reprojected into Web Mercator tiles by the map's workers\n * (in the page with `workers: false`).\n */\nexport type RasterGrid = 'mercator' | 'equirectangular' | TileGrid;\n\n/** What `RasterLayer.setStyle` changes */\nexport interface RasterStyle {\n opacity: number;\n /** 0 = greyscale, 1 = original colors */\n saturation: number;\n}\n\nexport interface RasterOptions {\n /** Tile URL with {z}, {x} and {y} (256 px tiles); unused with a `loader` */\n url: string;\n /** Tile grid of `url` (default 'mercator'); with 'equirectangular', `minZoom` and `maxZoom` are levels of that\n * grid; with a `TileGrid`, they are map zooms, by default those its matrices span */\n grid?: RasterGrid;\n minZoom?: number;\n maxZoom?: number;\n opacity?: number;\n /** 0 = greyscale, 1 = original colors */\n saturation?: number;\n /** Side of the tiles' textures, pixels (default 256): more for sharper tiles drawn by a `loader` */\n size?: number;\n /** Draws each tile instead of fetching `url`: an image of `size` × `size`, null for nothing there; a rejection is\n * retried like a network error */\n loader?: (z: number, x: number, y: number, signal: AbortSignal) => Promise<ImageBitmap | null>;\n /** Credits of the tiles, HTML: shown by the attribution control while the layer is on the map */\n attribution?: string;\n}\n\nexport interface NetworkStyle {\n /** Line width, CSS pixels, or zoom stops `[[zoom, width], …]` (default 2) */\n width: Size;\n /** Values above are drawn as unreached (default 1800) */\n max: number;\n /** Darker line every `contour` value units, 0 for none (default 0) */\n contour: number;\n opacity: number;\n /** Width of the halo drawn under the lines, CSS pixels or zoom stops, 0 for none (default 0): wide and faint, the\n * reached streets add up into a heat map that fills the blocks */\n halo: Size;\n /** Opacity of the halo at the middle of a line, fading quadratically to its sides (default 0.11) */\n haloOpacity: number;\n /** Colors from 0 to `max`: `[[fraction of max, color], …]` (default green to red) */\n ramp: Ramp | undefined;\n /** Color of the parts beyond `max` or unreached (default `rgba(140, 140, 140, 0.25)`) */\n unreachedColor: string;\n /** Share of `max` over which the colors fade out before it, 0 to 1 (default 0) */\n fade: number;\n}\n\nexport interface NetworkOptions extends Partial<NetworkStyle> {\n /** Node coordinates in degrees: lon0, lat0, lon1, lat1… */\n nodes: Float64Array;\n /** Edges as node index pairs: a0, b0, a1, b1… */\n edges: Uint32Array;\n /** Line of each edge, from A to B: the points of edge e are `points[start[e] .. start[e + 1]]` (lon, lat pairs,\n * counted in points); with fewer than two points an edge is straight. Default: all straight. */\n lines?: { start: Uint32Array; points: Float64Array };\n /** Per edge, the cost of travelling it from A to B then from B to A, in value units (Infinity: closed that way;\n * closed both ways: not drawn). A point along an edge then takes the quickest way there, min(value(A) + cost from\n * A, value(B) + cost from B), as a travel time does. Without costs, values are interpolated along the edges. */\n costs?: Float32Array;\n /** Width factor of each edge (default 1): rail lines wider than streets */\n edgeWidths?: Float32Array;\n}\n\nexport interface Tiles3dStyle {\n /** Screen-space error (CSS pixels) above which a tile is refined: 16 by default, lower is finer and heavier */\n maxScreenSpaceError: number;\n opacity: number;\n /** Size of the points of point cloud tiles (`.pnts`, glTF points), CSS pixels: 2 by default */\n pointSize?: number;\n /** A CSS color multiplying the textures of the meshes, the color of the untextured ones (buildings without\n * textures are light grey without it); none by default */\n color?: string;\n}\n\nexport interface Tiles3dOptions extends Partial<Tiles3dStyle> {\n /** URL of a `tileset.json` (3D Tiles 1.0 b3dm and pnts, 1.1 glb meshes and points, external tilesets) */\n url: string;\n /** Its heights are altitudes above the geoid (NGF-IGN69), as the IGN's Bâtiments 3D, rather than above the\n * ellipsoid (3D Tiles as specified): each tile raised by the RAF20 geoid, onto the IGN relief (default false) */\n geoid?: boolean;\n}\n\nexport interface MapPointerEvent {\n point: Point;\n /** Undefined above the horizon */\n lonLat: LonLat | undefined;\n}\n\n/** What 'hoverfeature' found under the pointer */\nexport interface MapHoverFeatureEvent extends MapPointerEvent {\n /** The feature under the pointer (see `GeoMap.pickFeature`), undefined if none */\n hit: FeatureHit | undefined;\n}\n\n/** A picked feature: its layer handle, its index there and, for line, circle, fill, extrusion, point cloud and 3D\n * Tiles layers, the feature itself (a building of 3D Tiles with its properties) */\nexport interface FeatureHit {\n layer: Layer;\n index: number;\n feature: Feature | undefined;\n}\n\nexport interface MapEvents {\n /** The camera started moving (a gesture, an animation or `setCamera`) */\n movestart: Camera;\n /** The camera moved */\n move: Camera;\n /** The camera stopped: no gesture held, no animation running */\n moveend: Camera;\n /** The map changed size (CSS pixels) */\n resize: { width: number; height: number };\n /** The pointer moved over the map (at most once per frame, not while dragging) */\n hover: MapPointerEvent;\n /** What is under the pointer, picked without stalling the GPU: a frame or two after 'hover', only while listened to\n * (radius and layers in `GeoMap.hoverPicking`) */\n hoverfeature: MapHoverFeatureEvent;\n /** Click without drag */\n click: MapPointerEvent;\n /** A frame was drawn; duration of the engine call in milliseconds */\n render: { ms: number };\n /** Everything in view is loaded and drawn, nothing moves: the end of a load, once after each change (as MapLibre's\n * `idle`). Tiles requested by the first frame count, so it never fires before they arrive. */\n idle: Record<string, never>;\n /** The pointer left the canvas (a mouse going out of the map, or onto a control or marker) */\n leave: Record<string, never>;\n}\n\n/** What a layer handle needs from its map */\nexport interface LayerHost {\n readonly engine: Engine;\n requestRender(): void;\n /** Forgets a removed layer */\n detach(layer: Layer): void;\n /** Moves a layer under `before`, or on top */\n moveLayer(layer: Layer, before: Layer | undefined): void;\n /** A layer created again in the engine (new id): put at the place of its old id, which is removed */\n replaceLayer(layer: Layer, old: number): void;\n /** Resolves once the map is idle (everything in view loaded and drawn) */\n whenIdle(): Promise<void>;\n}\n"]}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * The minimap: a second map in a corner, flat and a few levels out, following the map and outlining what it shows;
3
+ * a click on it takes the map there.
4
+ */
5
+ import { GeoMap } from '../map.ts';
6
+ import type { Basemap } from '../types.ts';
7
+ import type { Control } from './controls.ts';
8
+ export interface MinimapOptions {
9
+ /** Its basemap (default 'ign-plan-grey', light under the outline) */
10
+ basemap?: Basemap;
11
+ /** Levels out from the map (default 4) */
12
+ zoomOffset?: number;
13
+ /** Side, CSS pixels (default 160) */
14
+ size?: number;
15
+ /** The outline of the view (default '#e3342f') */
16
+ color?: string;
17
+ }
18
+ /** A flat map a few levels out, following the map, the view outlined on it */
19
+ export declare class MinimapControl implements Control {
20
+ private readonly options;
21
+ private stop;
22
+ constructor(options?: MinimapOptions);
23
+ onAdd(map: GeoMap): HTMLElement;
24
+ onRemove(): void;
25
+ }
@@ -0,0 +1,90 @@
1
+ /**
2
+ * The minimap: a second map in a corner, flat and a few levels out, following the map and outlining what it shows;
3
+ * a click on it takes the map there.
4
+ */
5
+ import { GeoMap } from "../map.js";
6
+ /** The outline of `[west, south, east, north]` */
7
+ const outline = ([west, south, east, north]) => ({
8
+ type: 'FeatureCollection',
9
+ features: [
10
+ {
11
+ type: 'Feature',
12
+ properties: {},
13
+ geometry: {
14
+ type: 'Polygon',
15
+ coordinates: [
16
+ [
17
+ [west, south],
18
+ [east, south],
19
+ [east, north],
20
+ [west, north],
21
+ [west, south],
22
+ ],
23
+ ],
24
+ },
25
+ },
26
+ ],
27
+ });
28
+ /** A flat map a few levels out, following the map, the view outlined on it */
29
+ export class MinimapControl {
30
+ options;
31
+ stop;
32
+ constructor(options = {}) {
33
+ this.options = { basemap: 'ign-plan-grey', zoomOffset: 4, size: 160, color: '#e3342f', ...options };
34
+ }
35
+ onAdd(map) {
36
+ const { basemap, zoomOffset, size, color } = this.options;
37
+ const element = document.createElement('div');
38
+ const state = { removed: false, offs: [] };
39
+ element.className = 'isard-ctrl-minimap';
40
+ element.style.width = `${size}px`;
41
+ element.style.height = `${size}px`;
42
+ element.setAttribute('aria-hidden', 'true');
43
+ const cameraOf = () => {
44
+ const { center, zoom } = map.getCamera();
45
+ return { center, zoom: Math.max(0, zoom - zoomOffset), pitch: 0, bearing: 0 };
46
+ };
47
+ GeoMap.create(element, {
48
+ ...cameraOf(),
49
+ basemap,
50
+ projection: 'mercator',
51
+ interactive: false,
52
+ attributionControl: false,
53
+ }).then((mini) => {
54
+ if (state.removed) {
55
+ mini.destroy();
56
+ return;
57
+ }
58
+ state.mini = mini;
59
+ const view = mini.addLines({ data: outline(map.getBounds()), color, width: 2 });
60
+ const follow = () => {
61
+ mini.setCamera(cameraOf());
62
+ view.setData(outline(map.getBounds()));
63
+ };
64
+ state.offs.push(map.on('move', follow), map.on('resize', follow));
65
+ // Not interactive (no gestures, no events): its clicks read on its element
66
+ const click = (e) => {
67
+ const box = element.getBoundingClientRect();
68
+ const lonLat = mini.unproject([e.clientX - box.left, e.clientY - box.top]);
69
+ if (lonLat)
70
+ map.easeTo({ center: lonLat });
71
+ };
72
+ element.addEventListener('click', click);
73
+ state.offs.push(() => element.removeEventListener('click', click));
74
+ follow();
75
+ }, (error) => console.warn(error));
76
+ this.stop = () => {
77
+ state.removed = true;
78
+ state.offs.forEach((off) => {
79
+ off();
80
+ });
81
+ state.mini?.destroy();
82
+ };
83
+ return element;
84
+ }
85
+ onRemove() {
86
+ this.stop?.();
87
+ this.stop = undefined;
88
+ }
89
+ }
90
+ //# sourceMappingURL=minimap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"minimap.js","sourceRoot":"","sources":["../../src/ui/minimap.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAenC,kDAAkD;AAClD,MAAM,OAAO,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,CAAmC,EAAqB,EAAE,CAAC,CAAC;IACpG,IAAI,EAAE,mBAAmB;IACzB,QAAQ,EAAE;QACR;YACE,IAAI,EAAE,SAAS;YACf,UAAU,EAAE,EAAE;YACd,QAAQ,EAAE;gBACR,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE;oBACX;wBACE,CAAC,IAAI,EAAE,KAAK,CAAC;wBACb,CAAC,IAAI,EAAE,KAAK,CAAC;wBACb,CAAC,IAAI,EAAE,KAAK,CAAC;wBACb,CAAC,IAAI,EAAE,KAAK,CAAC;wBACb,CAAC,IAAI,EAAE,KAAK,CAAC;qBACd;iBACF;aACF;SACF;KACF;CACF,CAAC,CAAC;AAEH,8EAA8E;AAC9E,MAAM,OAAO,cAAc;IACR,OAAO,CAA2B;IAC3C,IAAI,CAA2B;IAEvC,YAAY,UAA0B,EAAE;QACtC,IAAI,CAAC,OAAO,GAAG,EAAE,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,OAAO,EAAE,CAAC;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IAAI,CAAC;YACrB,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;gBACzB,GAAG,EAAE,CAAC;YACR,CAAC,CAAC,CAAC;YACH,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC;QACxB,CAAC,CAAC;QAEF,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,QAAQ;QACN,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;QACd,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;IACxB,CAAC;CACF","sourcesContent":["/**\n * The minimap: a second map in a corner, flat and a few levels out, following the map and outlining what it shows;\n * a click on it takes the map there.\n */\n\nimport type { FeatureCollection } from '../layers/features.ts';\nimport { GeoMap } from '../map.ts';\nimport type { Basemap } from '../types.ts';\nimport type { Control } from './controls.ts';\n\nexport interface MinimapOptions {\n /** Its basemap (default 'ign-plan-grey', light under the outline) */\n basemap?: Basemap;\n /** Levels out from the map (default 4) */\n zoomOffset?: number;\n /** Side, CSS pixels (default 160) */\n size?: number;\n /** The outline of the view (default '#e3342f') */\n color?: string;\n}\n\n/** The outline of `[west, south, east, north]` */\nconst outline = ([west, south, east, north]: [number, number, number, number]): FeatureCollection => ({\n type: 'FeatureCollection',\n features: [\n {\n type: 'Feature',\n properties: {},\n geometry: {\n type: 'Polygon',\n coordinates: [\n [\n [west, south],\n [east, south],\n [east, north],\n [west, north],\n [west, south],\n ],\n ],\n },\n },\n ],\n});\n\n/** A flat map a few levels out, following the map, the view outlined on it */\nexport class MinimapControl implements Control {\n private readonly options: Required<MinimapOptions>;\n private stop: (() => void) | undefined;\n\n constructor(options: MinimapOptions = {}) {\n this.options = { basemap: 'ign-plan-grey', zoomOffset: 4, size: 160, color: '#e3342f', ...options };\n }\n\n onAdd(map: GeoMap): HTMLElement {\n const { basemap, zoomOffset, size, color } = this.options;\n const element = document.createElement('div');\n const state: { mini?: GeoMap; removed: boolean; offs: (() => void)[] } = { removed: false, offs: [] };\n\n element.className = 'isard-ctrl-minimap';\n element.style.width = `${size}px`;\n element.style.height = `${size}px`;\n element.setAttribute('aria-hidden', 'true');\n\n const cameraOf = () => {\n const { center, zoom } = map.getCamera();\n\n return { center, zoom: Math.max(0, zoom - zoomOffset), pitch: 0, bearing: 0 };\n };\n\n GeoMap.create(element, {\n ...cameraOf(),\n basemap,\n projection: 'mercator',\n interactive: false,\n attributionControl: false,\n }).then(\n (mini) => {\n if (state.removed) {\n mini.destroy();\n\n return;\n }\n\n state.mini = mini;\n\n const view = mini.addLines({ data: outline(map.getBounds()), color, width: 2 });\n const follow = () => {\n mini.setCamera(cameraOf());\n view.setData(outline(map.getBounds()));\n };\n\n state.offs.push(map.on('move', follow), map.on('resize', follow));\n // Not interactive (no gestures, no events): its clicks read on its element\n const click = (e: MouseEvent) => {\n const box = element.getBoundingClientRect();\n const lonLat = mini.unproject([e.clientX - box.left, e.clientY - box.top]);\n\n if (lonLat) map.easeTo({ center: lonLat });\n };\n\n element.addEventListener('click', click);\n state.offs.push(() => element.removeEventListener('click', click));\n follow();\n },\n (error: unknown) => console.warn(error),\n );\n\n this.stop = () => {\n state.removed = true;\n state.offs.forEach((off) => {\n off();\n });\n state.mini?.destroy();\n };\n\n return element;\n }\n\n onRemove(): void {\n this.stop?.();\n this.stop = undefined;\n }\n}\n"]}
@@ -0,0 +1,19 @@
1
+ /** The scale bar: a round length (1, 2 or 5 times a power of ten) and its width on the map, at its center */
2
+ import type { GeoMap } from '../map.ts';
3
+ import type { Control } from './controls.ts';
4
+ export interface ScaleOptions {
5
+ /** Longest bar, CSS pixels (default 100) */
6
+ maxWidth?: number;
7
+ }
8
+ /** The round length shown for at most `metres` (1, 2 or 5 times a power of ten) */
9
+ export declare const roundLength: (metres: number) => number;
10
+ /** A length for its label: metres under 1 km, kilometres from there */
11
+ export declare const lengthLabel: (metres: number) => string;
12
+ /** A bar of a round length at the center of the map, updated as it moves; hidden where the center sees no ground */
13
+ export declare class ScaleControl implements Control {
14
+ private readonly maxWidth;
15
+ private stopListening;
16
+ constructor(options?: ScaleOptions);
17
+ onAdd(map: GeoMap): HTMLElement;
18
+ onRemove(): void;
19
+ }
@@ -0,0 +1,44 @@
1
+ /** The scale bar: a round length (1, 2 or 5 times a power of ten) and its width on the map, at its center */
2
+ /** The round length shown for at most `metres` (1, 2 or 5 times a power of ten) */
3
+ export const roundLength = (metres) => {
4
+ const power = 10 ** Math.floor(Math.log10(metres));
5
+ const step = [5, 2, 1].find((s) => s * power <= metres) ?? 1;
6
+ return step * power;
7
+ };
8
+ /** A length for its label: metres under 1 km, kilometres from there */
9
+ export const lengthLabel = (metres) => (metres >= 1000 ? `${metres / 1000} km` : `${metres} m`);
10
+ /** A bar of a round length at the center of the map, updated as it moves; hidden where the center sees no ground */
11
+ export class ScaleControl {
12
+ maxWidth;
13
+ stopListening;
14
+ constructor(options = {}) {
15
+ this.maxWidth = options.maxWidth ?? 100;
16
+ }
17
+ onAdd(map) {
18
+ const element = document.createElement('div');
19
+ element.className = 'isard-ctrl-scale';
20
+ element.setAttribute('aria-hidden', 'true');
21
+ const update = () => {
22
+ const perPixel = map.metersPerPixel();
23
+ element.hidden = perPixel === undefined || !(perPixel > 0);
24
+ if (element.hidden || perPixel === undefined)
25
+ return;
26
+ const length = roundLength(perPixel * this.maxWidth);
27
+ element.style.width = `${Math.round(length / perPixel)}px`;
28
+ element.textContent = lengthLabel(length);
29
+ };
30
+ const offs = [map.on('move', update), map.on('resize', update), map.on('idle', update)];
31
+ this.stopListening = () => {
32
+ offs.forEach((off) => {
33
+ off();
34
+ });
35
+ };
36
+ update();
37
+ return element;
38
+ }
39
+ onRemove() {
40
+ this.stopListening?.();
41
+ this.stopListening = undefined;
42
+ }
43
+ }
44
+ //# sourceMappingURL=scale.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scale.js","sourceRoot":"","sources":["../../src/ui/scale.ts"],"names":[],"mappings":"AAAA,6GAA6G;AAU7G,mFAAmF;AACnF,MAAM,CAAC,MAAM,WAAW,GA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W,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC;YAErD,OAAO,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC;YAC3D,OAAO,CAAC,WAAW,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;QAC5C,CAAC,CAAC;QACF,MAAM,IAAI,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;QAExF,IAAI,CAAC,aAAa,GAAG,GAAG,EAAE;YACxB,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;gBACnB,GAAG,EAAE,CAAC;YACR,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QACF,MAAM,EAAE,CAAC;QAET,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,QAAQ;QACN,IAAI,CAAC,aAAa,EAAE,EAAE,CAAC;QACvB,IAAI,CAAC,aAAa,GAAG,SAAS,CAAC;IACjC,CAAC;CACF","sourcesContent":["/** The scale bar: a round length (1, 2 or 5 times a power of ten) and its width on the map, at its center */\n\nimport type { GeoMap } from '../map.ts';\nimport type { Control } from './controls.ts';\n\nexport interface ScaleOptions {\n /** Longest bar, CSS pixels (default 100) */\n maxWidth?: number;\n}\n\n/** The round length shown for at most `metres` (1, 2 or 5 times a power of ten) */\nexport const roundLength = (metres: number): number => {\n const power = 10 ** Math.floor(Math.log10(metres));\n const step = [5, 2, 1].find((s) => s * power <= metres) ?? 1;\n\n return step * power;\n};\n\n/** A length for its label: metres under 1 km, kilometres from there */\nexport const lengthLabel = (metres: number): string => (metres >= 1000 ? `${metres / 1000} km` : `${metres} m`);\n\n/** A bar of a round length at the center of the map, updated as it moves; hidden where the center sees no ground */\nexport class ScaleControl implements Control {\n private readonly maxWidth: number;\n private stopListening: (() => void) | undefined;\n\n constructor(options: ScaleOptions = {}) {\n this.maxWidth = options.maxWidth ?? 100;\n }\n\n onAdd(map: GeoMap): HTMLElement {\n const element = document.createElement('div');\n\n element.className = 'isard-ctrl-scale';\n element.setAttribute('aria-hidden', 'true');\n\n const update = () => {\n const perPixel = map.metersPerPixel();\n\n element.hidden = perPixel === undefined || !(perPixel > 0);\n if (element.hidden || perPixel === undefined) return;\n\n const length = roundLength(perPixel * this.maxWidth);\n\n element.style.width = `${Math.round(length / perPixel)}px`;\n element.textContent = lengthLabel(length);\n };\n const offs = [map.on('move', update), map.on('resize', update), map.on('idle', update)];\n\n this.stopListening = () => {\n offs.forEach((off) => {\n off();\n });\n };\n update();\n\n return element;\n }\n\n onRemove(): void {\n this.stopListening?.();\n this.stopListening = undefined;\n }\n}\n"]}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * The search bar: places suggested as the user types (the Géoplateforme's geocoding by default, or yours), the map
3
+ * flying to the one picked. A combobox for screen readers: arrows move in the list, Enter picks, Escape closes.
4
+ */
5
+ import { type GeocodedPlace } from '../geoplateforme.ts';
6
+ import type { GeoMap } from '../map.ts';
7
+ import type { Control } from './controls.ts';
8
+ export interface SearchOptions {
9
+ /** The places of a text (default: the Géoplateforme's geocoding, France) */
10
+ geocode?: (text: string, signal: AbortSignal) => Promise<GeocodedPlace[]>;
11
+ /** What a pick does (default: a flight there, closer for an address than for a place) */
12
+ onSelect?: (place: GeocodedPlace, map: GeoMap) => void;
13
+ /** Default 'Search a place' */
14
+ placeholder?: string;
15
+ /** Suggestions shown at most (default 8) */
16
+ maxResults?: number;
17
+ }
18
+ /** A text box and the places it suggests, in a corner of the map */
19
+ export declare class SearchControl implements Control {
20
+ private readonly options;
21
+ private stop;
22
+ constructor(options?: SearchOptions);
23
+ onAdd(map: GeoMap): HTMLElement;
24
+ onRemove(): void;
25
+ }