isard 0.8.0 → 1.1.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 (180) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/dist/{basemaps.d.ts → basemap/basemaps.d.ts} +4 -4
  3. package/dist/{basemaps.js → basemap/basemaps.js} +3 -15
  4. package/dist/basemap/basemaps.js.map +1 -0
  5. package/dist/{grid.d.ts → basemap/grid.d.ts} +1 -1
  6. package/dist/{grid.js → basemap/grid.js} +2 -2
  7. package/dist/basemap/grid.js.map +1 -0
  8. package/dist/basemap/mvt.js.map +1 -0
  9. package/dist/{pmtiles.d.ts → basemap/pmtiles.d.ts} +6 -0
  10. package/dist/{pmtiles.js → basemap/pmtiles.js} +2 -2
  11. package/dist/basemap/pmtiles.js.map +1 -0
  12. package/dist/{resample.d.ts → basemap/resample.d.ts} +9 -0
  13. package/dist/{resample.js → basemap/resample.js} +2 -2
  14. package/dist/basemap/resample.js.map +1 -0
  15. package/dist/{terrain.js → basemap/terrain.js} +1 -1
  16. package/dist/basemap/terrain.js.map +1 -0
  17. package/dist/{vectorstyle.js → basemap/vectorstyle.js} +1 -1
  18. package/dist/basemap/vectorstyle.js.map +1 -0
  19. package/dist/{vectortiles.d.ts → basemap/vectortiles.d.ts} +9 -9
  20. package/dist/{vectortiles.js → basemap/vectortiles.js} +19 -8
  21. package/dist/basemap/vectortiles.js.map +1 -0
  22. package/dist/{wmts.js → basemap/wmts.js} +3 -3
  23. package/dist/basemap/wmts.js.map +1 -0
  24. package/dist/basemap.worker.js +2 -2
  25. package/dist/basemap.worker.js.map +10 -10
  26. package/dist/bind/layers.d.ts +37 -0
  27. package/dist/bind/layers.js +130 -0
  28. package/dist/bind/layers.js.map +1 -0
  29. package/dist/{crs.d.ts → data/crs.d.ts} +1 -1
  30. package/dist/data/crs.js.map +1 -0
  31. package/dist/{gpx.d.ts → data/gpx.d.ts} +1 -1
  32. package/dist/data/gpx.js.map +1 -0
  33. package/dist/{kml.d.ts → data/kml.d.ts} +1 -1
  34. package/dist/data/kml.js.map +1 -0
  35. package/dist/{topojson.d.ts → data/topojson.d.ts} +1 -1
  36. package/dist/data/topojson.js.map +1 -0
  37. package/dist/data/xml.js.map +1 -0
  38. package/dist/decoder.worker.js +1 -1
  39. package/dist/decoder.worker.js.map +4 -4
  40. package/dist/{decoders.d.ts → engine/decoders.d.ts} +1 -1
  41. package/dist/engine/decoders.js.map +1 -0
  42. package/dist/{loader.d.ts → engine/loader.d.ts} +1 -1
  43. package/dist/{loader.js → engine/loader.js} +4 -0
  44. package/dist/engine/loader.js.map +1 -0
  45. package/dist/{protocol.d.ts → engine/protocol.d.ts} +1 -1
  46. package/dist/engine/protocol.js +3 -0
  47. package/dist/engine/protocol.js.map +1 -0
  48. package/dist/engine/requests.js.map +1 -0
  49. package/dist/engine-loader.d.ts +16 -5
  50. package/dist/engine-loader.js +39 -8
  51. package/dist/engine-loader.js.map +1 -1
  52. package/dist/formats.d.ts +3 -3
  53. package/dist/formats.js +3 -3
  54. package/dist/formats.js.map +1 -1
  55. package/dist/geoplateforme.d.ts +53 -3
  56. package/dist/geoplateforme.js +35 -1
  57. package/dist/geoplateforme.js.map +1 -1
  58. package/dist/index.d.ts +32 -32
  59. package/dist/index.js +19 -19
  60. package/dist/index.js.map +1 -1
  61. package/dist/isard_bg.wasm +0 -0
  62. package/dist/isard_core_bg.wasm +0 -0
  63. package/dist/layers/extrusions.js.map +1 -0
  64. package/dist/{features.js → layers/features.js} +3 -3
  65. package/dist/layers/features.js.map +1 -0
  66. package/dist/{glyphs.d.ts → layers/glyphs.d.ts} +3 -3
  67. package/dist/{glyphs.js → layers/glyphs.js} +11 -1
  68. package/dist/layers/glyphs.js.map +1 -0
  69. package/dist/{icons.d.ts → layers/icons.d.ts} +2 -2
  70. package/dist/{icons.js → layers/icons.js} +8 -1
  71. package/dist/layers/icons.js.map +1 -0
  72. package/dist/{layers.d.ts → layers/layers.d.ts} +11 -5
  73. package/dist/{layers.js → layers/layers.js} +17 -6
  74. package/dist/layers/layers.js.map +1 -0
  75. package/dist/{panoramas.d.ts → layers/panoramas.d.ts} +1 -1
  76. package/dist/{panoramas.js → layers/panoramas.js} +2 -2
  77. package/dist/layers/panoramas.js.map +1 -0
  78. package/dist/{pointclouds.d.ts → layers/pointclouds.d.ts} +2 -2
  79. package/dist/{pointclouds.js → layers/pointclouds.js} +1 -1
  80. package/dist/layers/pointclouds.js.map +1 -0
  81. package/dist/{symbols.d.ts → layers/symbols.d.ts} +2 -2
  82. package/dist/{symbols.js → layers/symbols.js} +1 -1
  83. package/dist/layers/symbols.js.map +1 -0
  84. package/dist/map.d.ts +93 -12
  85. package/dist/map.js +119 -28
  86. package/dist/map.js.map +1 -1
  87. package/dist/projections.d.ts +3 -3
  88. package/dist/projections.js +2 -2
  89. package/dist/projections.js.map +1 -1
  90. package/dist/react/index.d.ts +119 -0
  91. package/dist/react/index.js +409 -0
  92. package/dist/react/index.js.map +1 -0
  93. package/dist/settings.d.ts +1 -1
  94. package/dist/settings.js +2 -2
  95. package/dist/settings.js.map +1 -1
  96. package/dist/types.d.ts +16 -12
  97. package/dist/types.js +1 -0
  98. package/dist/types.js.map +1 -1
  99. package/dist/{controls.d.ts → ui/controls.d.ts} +5 -4
  100. package/dist/{controls.js → ui/controls.js} +0 -8
  101. package/dist/ui/controls.js.map +1 -0
  102. package/dist/{interaction.d.ts → ui/interaction.d.ts} +7 -3
  103. package/dist/{interaction.js → ui/interaction.js} +1 -1
  104. package/dist/ui/interaction.js.map +1 -0
  105. package/dist/{overlay.d.ts → ui/overlay.d.ts} +2 -2
  106. package/dist/ui/overlay.js.map +1 -0
  107. package/dist/ui/style.js.map +1 -0
  108. package/dist/{animation.d.ts → util/animation.d.ts} +6 -2
  109. package/dist/util/animation.js.map +1 -0
  110. package/dist/util/color.js.map +1 -0
  111. package/dist/util/geo.js.map +1 -0
  112. package/dist/util/lru.js.map +1 -0
  113. package/dist/{basemap.worker.d.ts → workers/basemap.worker.d.ts} +14 -4
  114. package/dist/workers/basemap.worker.js +647 -0
  115. package/dist/workers/basemap.worker.js.map +1 -0
  116. package/package.json +31 -2
  117. package/vite.d.ts +17 -0
  118. package/vite.js +64 -0
  119. package/dist/animation.js.map +0 -1
  120. package/dist/basemaps.js.map +0 -1
  121. package/dist/color.js.map +0 -1
  122. package/dist/controls.js.map +0 -1
  123. package/dist/crs.js.map +0 -1
  124. package/dist/decoders.js.map +0 -1
  125. package/dist/extrusions.js.map +0 -1
  126. package/dist/features.js.map +0 -1
  127. package/dist/geo.js.map +0 -1
  128. package/dist/glyphs.js.map +0 -1
  129. package/dist/gpx.js.map +0 -1
  130. package/dist/grid.js.map +0 -1
  131. package/dist/icons.js.map +0 -1
  132. package/dist/interaction.js.map +0 -1
  133. package/dist/kml.js.map +0 -1
  134. package/dist/layers.js.map +0 -1
  135. package/dist/loader.js.map +0 -1
  136. package/dist/lru.js.map +0 -1
  137. package/dist/mvt.js.map +0 -1
  138. package/dist/overlay.js.map +0 -1
  139. package/dist/panoramas.js.map +0 -1
  140. package/dist/pmtiles.js.map +0 -1
  141. package/dist/pointclouds.js.map +0 -1
  142. package/dist/protocol.js +0 -2
  143. package/dist/protocol.js.map +0 -1
  144. package/dist/requests.js.map +0 -1
  145. package/dist/resample.js.map +0 -1
  146. package/dist/style.js.map +0 -1
  147. package/dist/symbols.js.map +0 -1
  148. package/dist/terrain.js.map +0 -1
  149. package/dist/topojson.js.map +0 -1
  150. package/dist/vectorstyle.js.map +0 -1
  151. package/dist/vectortiles.js.map +0 -1
  152. package/dist/wmts.js.map +0 -1
  153. package/dist/xml.js.map +0 -1
  154. /package/dist/{mvt.d.ts → basemap/mvt.d.ts} +0 -0
  155. /package/dist/{mvt.js → basemap/mvt.js} +0 -0
  156. /package/dist/{terrain.d.ts → basemap/terrain.d.ts} +0 -0
  157. /package/dist/{vectorstyle.d.ts → basemap/vectorstyle.d.ts} +0 -0
  158. /package/dist/{wmts.d.ts → basemap/wmts.d.ts} +0 -0
  159. /package/dist/{crs.js → data/crs.js} +0 -0
  160. /package/dist/{gpx.js → data/gpx.js} +0 -0
  161. /package/dist/{kml.js → data/kml.js} +0 -0
  162. /package/dist/{topojson.js → data/topojson.js} +0 -0
  163. /package/dist/{xml.d.ts → data/xml.d.ts} +0 -0
  164. /package/dist/{xml.js → data/xml.js} +0 -0
  165. /package/dist/{decoders.js → engine/decoders.js} +0 -0
  166. /package/dist/{requests.d.ts → engine/requests.d.ts} +0 -0
  167. /package/dist/{requests.js → engine/requests.js} +0 -0
  168. /package/dist/{extrusions.d.ts → layers/extrusions.d.ts} +0 -0
  169. /package/dist/{extrusions.js → layers/extrusions.js} +0 -0
  170. /package/dist/{features.d.ts → layers/features.d.ts} +0 -0
  171. /package/dist/{overlay.js → ui/overlay.js} +0 -0
  172. /package/dist/{style.d.ts → ui/style.d.ts} +0 -0
  173. /package/dist/{style.js → ui/style.js} +0 -0
  174. /package/dist/{animation.js → util/animation.js} +0 -0
  175. /package/dist/{color.d.ts → util/color.d.ts} +0 -0
  176. /package/dist/{color.js → util/color.js} +0 -0
  177. /package/dist/{geo.d.ts → util/geo.d.ts} +0 -0
  178. /package/dist/{geo.js → util/geo.js} +0 -0
  179. /package/dist/{lru.d.ts → util/lru.d.ts} +0 -0
  180. /package/dist/{lru.js → util/lru.js} +0 -0
package/dist/map.d.ts CHANGED
@@ -1,13 +1,19 @@
1
- import { type Control, type ControlPosition } from './controls.ts';
2
- import { ExtrusionLayer, type ExtrusionOptions } from './extrusions.ts';
3
- import { CircleLayer, type CircleOptions, FillLayer, type FillOptions, LineLayer, type LineOptions } from './features.ts';
4
- import { type ImageOptions, type Pixels } from './icons.ts';
5
- import { CustomLayer, type CustomLayerInterface, GroundLayer, type GroundOptions, type Layer, ModelLayer, type ModelOptions, NetworkLayer, RasterLayer, Tiles3dLayer } from './layers.ts';
6
- import { type PanoramaOptions, type Panoramas } from './panoramas.ts';
7
- import { PointCloudLayer, type PointCloudOptions } from './pointclouds.ts';
8
- import { SymbolLayer, type SymbolOptions } from './symbols.ts';
1
+ /**
2
+ * The map: canvas, camera, layers, events, overlays, credits and the frame loop. Frames are drawn on demand only: an
3
+ * idle map costs nothing. Hover events are coalesced to one per frame, so the values computed for a mouse position are
4
+ * drawn in the same frame. The engine's loading is in engine-loader.ts, its settings from the options in settings.ts,
5
+ * the camera animations in animation.ts.
6
+ */
7
+ import { type PmtilesOptions, VectorTiles, type VectorTilesOptions } from './basemap/vectortiles.ts';
8
+ import { ExtrusionLayer, type ExtrusionOptions } from './layers/extrusions.ts';
9
+ import { CircleLayer, type CircleOptions, FillLayer, type FillOptions, LineLayer, type LineOptions } from './layers/features.ts';
10
+ import { type ImageOptions, type Pixels } from './layers/icons.ts';
11
+ import { CustomLayer, type CustomLayerInterface, GroundLayer, type GroundOptions, type Layer, ModelLayer, type ModelOptions, NetworkLayer, RasterLayer, Tiles3dLayer } from './layers/layers.ts';
12
+ import { type PanoramaOptions, type Panoramas } from './layers/panoramas.ts';
13
+ import { PointCloudLayer, type PointCloudOptions } from './layers/pointclouds.ts';
14
+ import { SymbolLayer, type SymbolOptions } from './layers/symbols.ts';
9
15
  import type { AnimationOptions, AtmosphereOptions, Basemap, FeatureHit, FirstPersonView, FlyToOptions, GeoMapOptions, LoadingMode, LonLat, MapEvents, NetworkOptions, Point, Projection, RasterOptions, SwipeOptions, TerrainModel, TerrainOptions, Tiles3dOptions, ViewshedOptions } from './types.ts';
10
- import { type PmtilesOptions, VectorTiles, type VectorTilesOptions } from './vectortiles.ts';
16
+ import { type Control, type ControlPosition } from './ui/controls.ts';
11
17
  import type { Camera, PickHit, RasterLayerStats } from './wasm/isard.js';
12
18
  /** A map (see `GeoMap.create`); layers take it as their host */
13
19
  export declare class GeoMap {
@@ -91,7 +97,7 @@ export declare class GeoMap {
91
97
  * tiles when only the exaggeration changes) */
92
98
  private readonly terrainLoaders;
93
99
  /** Loads the engine (once per page) and creates a map filling `container` */
94
- static create(container: HTMLElement, options?: GeoMapOptions): Promise<GeoMap>;
100
+ static create(container: HTMLElement, given?: GeoMapOptions): Promise<GeoMap>;
95
101
  private constructor();
96
102
  /** The element the map was created in */
97
103
  getContainer(): HTMLElement;
@@ -126,13 +132,50 @@ export declare class GeoMap {
126
132
  private applySwipe;
127
133
  /** Takes a layer out of the drawing order (to put it back elsewhere, or for good) */
128
134
  private unlist;
129
- private add;
135
+ private addLayer;
130
136
  /** Index in the engine of the layer at `index`: the layers waiting for the engine with 3D Tiles are not in it yet */
131
137
  private engineIndex;
132
138
  /** Moves a layer under all the others */
133
139
  private toBottom;
134
140
  /** Listens to an event; returns the function that stops listening */
135
141
  on<K extends keyof MapEvents>(type: K, listener: (event: MapEvents[K]) => void): () => void;
142
+ /**
143
+ * The camera's methods together: `get`, `set`, `easeTo`, `flyTo`, `bounds`, `firstPerson` and `setFirstPerson`
144
+ * (street level), `project`, `unproject`; the same as the map's own (`getCamera`, `setCamera`…)
145
+ */
146
+ readonly camera: {
147
+ readonly get: () => Camera;
148
+ readonly set: (camera: Partial<Camera>) => void;
149
+ readonly easeTo: (camera: Partial<Camera>, options?: number | AnimationOptions) => void;
150
+ readonly flyTo: (camera: Partial<Camera>, options?: FlyToOptions) => void;
151
+ readonly bounds: () => [west: number, south: number, east: number, north: number];
152
+ readonly firstPerson: () => Readonly<Required<FirstPersonView>> | undefined;
153
+ readonly setFirstPerson: (view: FirstPersonView | undefined) => void;
154
+ readonly project: (lonLat: LonLat, height?: number) => Point | undefined;
155
+ readonly unproject: (point: Point) => LonLat | undefined;
156
+ };
157
+ /**
158
+ * What lies under a point or at a position, together: `feature` (`pickFeature`), `surface` (`pickSurface`),
159
+ * `surfaceAt`, `elevationAt`, `metersPerPixel`
160
+ */
161
+ readonly query: {
162
+ readonly feature: (point: Point, options?: {
163
+ radius?: number;
164
+ layers?: readonly Layer[];
165
+ }) => FeatureHit | undefined;
166
+ readonly surface: (point: Point) => {
167
+ lonLat: LonLat;
168
+ height: number;
169
+ } | undefined;
170
+ readonly surfaceAt: (lonLat: LonLat) => number | undefined;
171
+ readonly elevationAt: (lonLat: LonLat) => number | undefined;
172
+ readonly metersPerPixel: (point?: Point) => number | undefined;
173
+ };
174
+ /** What is drawn over the scene, together: `viewshed` (`setViewshed`), `swipe` (`setSwipe`) */
175
+ readonly effects: {
176
+ readonly viewshed: (options: ViewshedOptions | readonly ViewshedOptions[] | undefined) => void;
177
+ readonly swipe: (options: SwipeOptions | undefined) => void;
178
+ };
136
179
  getCamera(): Camera;
137
180
  setCamera(camera: Partial<Camera>): void;
138
181
  /** Animated move to a camera: over `duration` milliseconds (or the options), ease-out by default */
@@ -228,7 +271,7 @@ export declare class GeoMap {
228
271
  addControl(control: Control, position?: ControlPosition): this;
229
272
  removeControl(control: Control): this;
230
273
  /** Replaces the basemap and the IGN hillshade, under the other layers (hillshade by default: 0, none). The former
231
- * names of the Géoplateforme basemaps (`LegacyBasemap`) are taken under their new ones */
274
+ * names of the Géoplateforme basemaps throw, naming the new ones */
232
275
  setBasemap(basemap: Basemap, hillshade?: number): void;
233
276
  /** Raster tiles ({z}, {x}, {y} URL; Web Mercator, or reprojected from another `grid`: longitudes and latitudes,
234
277
  * Lambert-93, UTM…), over the layers already added */
@@ -244,6 +287,12 @@ export declare class GeoMap {
244
287
  addPmtiles(url: string, options?: PmtilesOptions): Promise<RasterLayer | VectorTiles>;
245
288
  /** Line network colored by a value per node; `layer.setValues` recolors it in one texture upload */
246
289
  addNetwork(options: NetworkOptions): NetworkLayer;
290
+ /**
291
+ * A layer from its description, as an application's configuration gives it: `{ type, ...options }`, the options of
292
+ * the `add…` method of that type (`'lines'` for `addLines`, `'tiles3d'` for `addTiles3d`…); `before` to go under
293
+ * another layer. The layer's `ready` resolves once the map has drawn it
294
+ */
295
+ add<P = Record<string, unknown>>(spec: LayerSpec<P>): Layer;
247
296
  /** Lines from GeoJSON (line strings, and polygon outlines), styled per feature */
248
297
  addLines<P = Record<string, unknown>>(options: LineOptions<P>): LineLayer<P>;
249
298
  /** Discs from GeoJSON points, styled per feature */
@@ -316,3 +365,35 @@ export declare class GeoMap {
316
365
  private resize;
317
366
  destroy(): void;
318
367
  }
368
+ /** A layer by its type and the options of its `add…` method (`GeoMap.add`) */
369
+ export type LayerSpec<P = Record<string, unknown>> = ({
370
+ type: 'lines';
371
+ } & LineOptions<P>) | ({
372
+ type: 'circles';
373
+ } & CircleOptions<P>) | ({
374
+ type: 'fills';
375
+ } & FillOptions<P>) | ({
376
+ type: 'symbols';
377
+ } & SymbolOptions<P>) | ({
378
+ type: 'extrusions';
379
+ } & ExtrusionOptions<P>) | ({
380
+ type: 'raster';
381
+ } & RasterOptions & {
382
+ before?: Layer;
383
+ }) | ({
384
+ type: 'ground';
385
+ } & GroundOptions & {
386
+ before?: Layer;
387
+ }) | ({
388
+ type: 'network';
389
+ } & NetworkOptions) | ({
390
+ type: 'tiles3d';
391
+ } & Tiles3dOptions) | ({
392
+ type: 'pointcloud';
393
+ } & PointCloudOptions & {
394
+ before?: Layer;
395
+ }) | ({
396
+ type: 'models';
397
+ } & ModelOptions & {
398
+ before?: Layer;
399
+ });
package/dist/map.js CHANGED
@@ -4,25 +4,26 @@
4
4
  * drawn in the same frame. The engine's loading is in engine-loader.ts, its settings from the options in settings.ts,
5
5
  * the camera animations in animation.ts.
6
6
  */
7
- import { easeTo, flyTo } from "./animation.js";
8
- import { BASEMAPS, basemapName, HILLSHADE, SEA } from "./basemaps.js";
9
- import { AttributionControl } from "./controls.js";
7
+ import { BASEMAPS, HILLSHADE, RENAMED_BASEMAPS, SEA } from "./basemap/basemaps.js";
8
+ import { equirectangularGrid, gridLoader, gridZooms, resolveGrid } from "./basemap/grid.js";
9
+ import { encodedTerrainLoader } from "./basemap/terrain.js";
10
+ import { BasemapWorkers, defaultWorkerCount, defaultWorkerUrl, pmtilesLayer, pmtilesRasterLoader, VECTOR_BASEMAPS, VectorTiles, } from "./basemap/vectortiles.js";
11
+ import { headerRules, onHeaderRules } from "./engine/requests.js";
10
12
  import { destroyedEngine, engineUrl, loadEngine, loadFullEngineLater, preloadFullEngine, startTileLoader, } from "./engine-loader.js";
11
- import { ExtrusionLayer, extrusionStyle } from "./extrusions.js";
12
- import { CircleLayer, circleStyle, FillLayer, fillStyle, LineLayer, lineStyle, } from "./features.js";
13
- import { Glyphs } from "./glyphs.js";
14
- import { equirectangularGrid, gridLoader, gridZooms, resolveGrid } from "./grid.js";
15
- import { Icons, readPixels } from "./icons.js";
16
- import { Interaction } from "./interaction.js";
17
- import { CustomLayer, GroundLayer, ModelLayer, NetworkLayer, RasterLayer, Tiles3dLayer, } from "./layers.js";
18
- import { loadPanoramas } from "./panoramas.js";
19
- import { PointCloudLayer } from "./pointclouds.js";
20
- import { headerRules, onHeaderRules } from "./requests.js";
13
+ import { IGN_PRESETS } from "./geoplateforme.js";
14
+ import { ExtrusionLayer, extrusionStyle } from "./layers/extrusions.js";
15
+ import { CircleLayer, circleStyle, FillLayer, fillStyle, LineLayer, lineStyle, } from "./layers/features.js";
16
+ import { Glyphs } from "./layers/glyphs.js";
17
+ import { Icons, readPixels } from "./layers/icons.js";
18
+ import { CustomLayer, GroundLayer, ModelLayer, NetworkLayer, RasterLayer, Tiles3dLayer, } from "./layers/layers.js";
19
+ import { loadPanoramas } from "./layers/panoramas.js";
20
+ import { PointCloudLayer } from "./layers/pointclouds.js";
21
+ import { SymbolLayer, symbolStyle } from "./layers/symbols.js";
21
22
  import { atmosphereSettings, bodySettings, haloSettings, rgb, terrainSettings, } from "./settings.js";
22
- import { injectStyle } from "./style.js";
23
- import { SymbolLayer, symbolStyle } from "./symbols.js";
24
- import { encodedTerrainLoader } from "./terrain.js";
25
- import { BasemapWorkers, defaultWorkerCount, defaultWorkerUrl, pmtilesLayer, pmtilesRasterLoader, VECTOR_BASEMAPS, VectorTiles, } from "./vectortiles.js";
23
+ import { AttributionControl } from "./ui/controls.js";
24
+ import { Interaction } from "./ui/interaction.js";
25
+ import { injectStyle } from "./ui/style.js";
26
+ import { easeTo, flyTo } from "./util/animation.js";
26
27
  /** Reports an error without throwing it here: the console shows it, as an uncaught one */
27
28
  function report(error) {
28
29
  if (typeof reportError === 'function')
@@ -50,11 +51,13 @@ const CORNERS = ['top-left', 'top-right', 'bottom-left', 'bottom-right'];
50
51
  const MAX_POLLS = 30;
51
52
  /** The name of a basemap, checked: an unknown one throws */
52
53
  function checkBasemap(basemap) {
53
- const name = basemapName(basemap);
54
- if (name !== 'none' && !(name in VECTOR_BASEMAPS) && !(name in BASEMAPS)) {
54
+ const renamed = RENAMED_BASEMAPS[basemap];
55
+ if (renamed)
56
+ throw new Error(`isard: the basemap '${basemap}' is now named '${renamed}'`);
57
+ if (basemap !== 'none' && !(basemap in VECTOR_BASEMAPS) && !(basemap in BASEMAPS)) {
55
58
  throw new Error(`isard: unknown basemap '${basemap}'`);
56
59
  }
57
- return name;
60
+ return basemap;
58
61
  }
59
62
  /** A map (see `GeoMap.create`); layers take it as their host */
60
63
  export class GeoMap {
@@ -148,7 +151,9 @@ export class GeoMap {
148
151
  * tiles when only the exaggeration changes) */
149
152
  terrainLoaders = new Map();
150
153
  /** Loads the engine (once per page) and creates a map filling `container` */
151
- static async create(container, options = {}) {
154
+ static async create(container, given = {}) {
155
+ // A preset under the options given
156
+ const options = given.preset ? { ...IGN_PRESETS[given.preset], ...given } : given;
152
157
  // With 3D Tiles from the start when asked, or when only that engine's URL is given (as before the core engine)
153
158
  const full = options.tiles3d === true || (options.wasmUrl !== undefined && options.coreWasmUrl === undefined);
154
159
  // Before anything is created
@@ -166,7 +171,7 @@ export class GeoMap {
166
171
  this.tiles3dModule = tiles3dModule;
167
172
  this.tiles3dOptions = { ...options };
168
173
  this.glyphsUrl = options.glyphs;
169
- this.basemapWorkerUrl = options.basemapWorkerUrl;
174
+ this.basemapWorkerUrl = options.basemapWorkerUrl ?? defaultWorkerUrl(options.assetsUrl);
170
175
  this.basemapTileSize = options.basemapTileSize;
171
176
  this.container = container;
172
177
  this.canvas = document.createElement('canvas');
@@ -435,7 +440,7 @@ export class GeoMap {
435
440
  if (index >= 0)
436
441
  this.layers.splice(index, 1);
437
442
  }
438
- add(layer) {
443
+ addLayer(layer) {
439
444
  // On the core engine, a 3D Tiles layer or a model waits for the engine with 3D Tiles: it is created with the
440
445
  // others on it
441
446
  if (layer.needsFullEngine && !this.tiles3dModule)
@@ -506,6 +511,37 @@ export class GeoMap {
506
511
  }
507
512
  }
508
513
  // ── Camera ──
514
+ /**
515
+ * The camera's methods together: `get`, `set`, `easeTo`, `flyTo`, `bounds`, `firstPerson` and `setFirstPerson`
516
+ * (street level), `project`, `unproject`; the same as the map's own (`getCamera`, `setCamera`…)
517
+ */
518
+ camera = {
519
+ get: () => this.getCamera(),
520
+ set: (camera) => this.setCamera(camera),
521
+ easeTo: (camera, options) => this.easeTo(camera, options),
522
+ flyTo: (camera, options) => this.flyTo(camera, options),
523
+ bounds: () => this.getBounds(),
524
+ firstPerson: () => this.firstPerson,
525
+ setFirstPerson: (view) => this.setFirstPerson(view),
526
+ project: (lonLat, height) => this.project(lonLat, height),
527
+ unproject: (point) => this.unproject(point),
528
+ };
529
+ /**
530
+ * What lies under a point or at a position, together: `feature` (`pickFeature`), `surface` (`pickSurface`),
531
+ * `surfaceAt`, `elevationAt`, `metersPerPixel`
532
+ */
533
+ query = {
534
+ feature: (point, options) => this.pickFeature(point, options),
535
+ surface: (point) => this.pickSurface(point),
536
+ surfaceAt: (lonLat) => this.surfaceAt(lonLat),
537
+ elevationAt: (lonLat) => this.elevationAt(lonLat),
538
+ metersPerPixel: (point) => this.metersPerPixel(point),
539
+ };
540
+ /** What is drawn over the scene, together: `viewshed` (`setViewshed`), `swipe` (`setSwipe`) */
541
+ effects = {
542
+ viewshed: (options) => this.setViewshed(options),
543
+ swipe: (options) => this.setSwipe(options),
544
+ };
509
545
  getCamera() {
510
546
  return this.frameCamera ?? this.engine.camera();
511
547
  }
@@ -839,7 +875,7 @@ export class GeoMap {
839
875
  }
840
876
  // ── Layers ──
841
877
  /** Replaces the basemap and the IGN hillshade, under the other layers (hillshade by default: 0, none). The former
842
- * names of the Géoplateforme basemaps (`LegacyBasemap`) are taken under their new ones */
878
+ * names of the Géoplateforme basemaps throw, naming the new ones */
843
879
  setBasemap(basemap, hillshade = 0) {
844
880
  const name = checkBasemap(basemap);
845
881
  if (this.basemap && this.hasLayer(this.basemap))
@@ -917,7 +953,62 @@ export class GeoMap {
917
953
  const { halo = 0, haloOpacity = 0.11, ramp, unreachedColor = 'rgba(140, 140, 140, 0.25)', fade = 0 } = options;
918
954
  const style = { width, max, contour, opacity, halo, haloOpacity, ramp, unreachedColor, fade };
919
955
  validateNetwork(nodes, edges);
920
- return this.add(new NetworkLayer(this, { nodes, edges, lines }, costs, style, edgeWidths));
956
+ return this.addLayer(new NetworkLayer(this, { nodes, edges, lines }, costs, style, edgeWidths));
957
+ }
958
+ /**
959
+ * A layer from its description, as an application's configuration gives it: `{ type, ...options }`, the options of
960
+ * the `add…` method of that type (`'lines'` for `addLines`, `'tiles3d'` for `addTiles3d`…); `before` to go under
961
+ * another layer. The layer's `ready` resolves once the map has drawn it
962
+ */
963
+ add(spec) {
964
+ switch (spec.type) {
965
+ case 'lines':
966
+ return this.addLines(spec);
967
+ case 'circles':
968
+ return this.addCircles(spec);
969
+ case 'fills':
970
+ return this.addFills(spec);
971
+ case 'symbols':
972
+ return this.addSymbols(spec);
973
+ case 'extrusions':
974
+ return this.addExtrusions(spec);
975
+ case 'raster':
976
+ return this.addRaster(spec);
977
+ case 'ground':
978
+ return this.addGround(spec);
979
+ case 'network':
980
+ return this.addNetwork(spec);
981
+ case 'tiles3d':
982
+ return this.addTiles3d(spec);
983
+ case 'pointcloud':
984
+ return this.addPointCloud(spec);
985
+ case 'models':
986
+ return this.addModels(spec);
987
+ default:
988
+ throw new Error(`isard: no layer of type ${String(spec.type)}`);
989
+ }
990
+ }
991
+ /** @internal A layer made anew from its description, in the place of `old` in the drawing order (old removed) */
992
+ rebuildLayer(old, spec) {
993
+ const index = this.layers.indexOf(old);
994
+ const above = index >= 0 ? this.layers[index + 1] : undefined;
995
+ const layer = this.add(spec);
996
+ if (!('before' in spec && spec.before) && index >= 0)
997
+ this.moveLayer(layer, above);
998
+ old.remove();
999
+ return layer;
1000
+ }
1001
+ /** @internal Resolves once the map is idle (everything in view loaded and drawn) */
1002
+ whenIdle() {
1003
+ if (this.gone)
1004
+ return Promise.resolve();
1005
+ return new Promise((resolve) => {
1006
+ const off = this.on('idle', () => {
1007
+ off();
1008
+ resolve();
1009
+ });
1010
+ this.requestRender();
1011
+ });
921
1012
  }
922
1013
  /** Lines from GeoJSON (line strings, and polygon outlines), styled per feature */
923
1014
  addLines(options) {
@@ -1005,7 +1096,7 @@ export class GeoMap {
1005
1096
  * when it asks for another count or URL
1006
1097
  */
1007
1098
  basemapWorkers(count, url) {
1008
- const sharedUrl = this.basemapWorkerUrl ?? defaultWorkerUrl();
1099
+ const sharedUrl = this.basemapWorkerUrl;
1009
1100
  const shared = defaultWorkerCount();
1010
1101
  const workers = Math.max(1, count ?? shared);
1011
1102
  const workerUrl = url ?? sharedUrl;
@@ -1041,7 +1132,7 @@ export class GeoMap {
1041
1132
  };
1042
1133
  /** Adds a layer, under `before` if given */
1043
1134
  place(layer, before) {
1044
- this.add(layer);
1135
+ this.addLayer(layer);
1045
1136
  if (before)
1046
1137
  this.moveLayer(layer, before);
1047
1138
  return layer;
@@ -1049,7 +1140,7 @@ export class GeoMap {
1049
1140
  /** Textured meshes in 3D Tiles (photogrammetry, buildings), drawn with depth over the basemap */
1050
1141
  addTiles3d(options) {
1051
1142
  const { url, maxScreenSpaceError = 16, opacity = 1, pointSize, color, geoid = false } = options;
1052
- return this.add(new Tiles3dLayer(this, url, geoid, {
1143
+ return this.addLayer(new Tiles3dLayer(this, url, geoid, {
1053
1144
  maxScreenSpaceError,
1054
1145
  opacity,
1055
1146
  ...(pointSize !== undefined ? { pointSize } : {}),