isard 1.5.0 → 1.7.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 (159) hide show
  1. package/CHANGELOG.md +213 -1
  2. package/README.md +3 -2
  3. package/dist/basemap/furniture.d.ts +26 -0
  4. package/dist/basemap/furniture.js +95 -0
  5. package/dist/basemap/furniture.js.map +1 -0
  6. package/dist/basemap/meshes.d.ts +21 -0
  7. package/dist/basemap/meshes.js +159 -0
  8. package/dist/basemap/meshes.js.map +1 -0
  9. package/dist/basemap/placed.d.ts +13 -0
  10. package/dist/basemap/placed.js +14 -0
  11. package/dist/basemap/placed.js.map +1 -0
  12. package/dist/basemap/trees.d.ts +25 -8
  13. package/dist/basemap/trees.js +77 -105
  14. package/dist/basemap/trees.js.map +1 -1
  15. package/dist/basemap/vectorstyle.d.ts +9 -3
  16. package/dist/basemap/vectorstyle.js +5 -6
  17. package/dist/basemap/vectorstyle.js.map +1 -1
  18. package/dist/basemap/vectortiles/context.d.ts +7 -2
  19. package/dist/basemap/vectortiles/context.js.map +1 -1
  20. package/dist/basemap/vectortiles/extrusions.d.ts +4 -0
  21. package/dist/basemap/vectortiles/extrusions.js +9 -3
  22. package/dist/basemap/vectortiles/extrusions.js.map +1 -1
  23. package/dist/basemap/vectortiles/furniture.d.ts +19 -0
  24. package/dist/basemap/vectortiles/furniture.js +29 -0
  25. package/dist/basemap/vectortiles/furniture.js.map +1 -0
  26. package/dist/basemap/vectortiles/labels.d.ts +3 -0
  27. package/dist/basemap/vectortiles/labels.js +50 -18
  28. package/dist/basemap/vectortiles/labels.js.map +1 -1
  29. package/dist/basemap/vectortiles/lamps.d.ts +23 -0
  30. package/dist/basemap/vectortiles/lamps.js +25 -0
  31. package/dist/basemap/vectortiles/lamps.js.map +1 -0
  32. package/dist/basemap/vectortiles/placed.d.ts +38 -0
  33. package/dist/basemap/vectortiles/placed.js +143 -0
  34. package/dist/basemap/vectortiles/placed.js.map +1 -0
  35. package/dist/basemap/vectortiles/requests.d.ts +4 -0
  36. package/dist/basemap/vectortiles/requests.js +15 -2
  37. package/dist/basemap/vectortiles/requests.js.map +1 -1
  38. package/dist/basemap/vectortiles/street-wind.js +4 -6
  39. package/dist/basemap/vectortiles/street-wind.js.map +1 -1
  40. package/dist/basemap/vectortiles/trees.d.ts +2 -0
  41. package/dist/basemap/vectortiles/trees.js +40 -86
  42. package/dist/basemap/vectortiles/trees.js.map +1 -1
  43. package/dist/basemap/vectortiles/vectors.d.ts +16 -0
  44. package/dist/basemap/vectortiles/vectors.js +76 -11
  45. package/dist/basemap/vectortiles/vectors.js.map +1 -1
  46. package/dist/basemap/vectortiles.d.ts +37 -7
  47. package/dist/basemap/vectortiles.js +78 -17
  48. package/dist/basemap/vectortiles.js.map +1 -1
  49. package/dist/basemap/wmts.js +2 -2
  50. package/dist/basemap/wmts.js.map +1 -1
  51. package/dist/basemap.worker.js +2 -2
  52. package/dist/basemap.worker.js.map +19 -13
  53. package/dist/bind/layers.js +1 -0
  54. package/dist/bind/layers.js.map +1 -1
  55. package/dist/data/collada.d.ts +19 -0
  56. package/dist/data/collada.js +305 -0
  57. package/dist/data/collada.js.map +1 -0
  58. package/dist/data/crs.js +1 -1
  59. package/dist/data/crs.js.map +1 -1
  60. package/dist/data/ifc.d.ts +100 -0
  61. package/dist/data/ifc.js +371 -0
  62. package/dist/data/ifc.js.map +1 -0
  63. package/dist/decoder.worker.js +5 -5
  64. package/dist/decoder.worker.js.map +3 -3
  65. package/dist/formats.d.ts +7 -2
  66. package/dist/formats.js +7 -2
  67. package/dist/formats.js.map +1 -1
  68. package/dist/geoplateforme.d.ts +14 -2
  69. package/dist/geoplateforme.js +24 -2
  70. package/dist/geoplateforme.js.map +1 -1
  71. package/dist/index.d.ts +11 -3
  72. package/dist/index.js +8 -3
  73. package/dist/index.js.map +1 -1
  74. package/dist/isard_bg.wasm +0 -0
  75. package/dist/isard_core_bg.wasm +0 -0
  76. package/dist/isard_grid_bg.wasm +0 -0
  77. package/dist/isard_tess_bg.wasm +0 -0
  78. package/dist/layers/extrusions.d.ts +10 -0
  79. package/dist/layers/extrusions.js +33 -6
  80. package/dist/layers/extrusions.js.map +1 -1
  81. package/dist/layers/features.d.ts +0 -2
  82. package/dist/layers/features.js +5 -6
  83. package/dist/layers/features.js.map +1 -1
  84. package/dist/layers/layers.d.ts +14 -0
  85. package/dist/layers/layers.js +55 -1
  86. package/dist/layers/layers.js.map +1 -1
  87. package/dist/layers/panoramas.d.ts +32 -10
  88. package/dist/layers/panoramas.js +55 -28
  89. package/dist/layers/panoramas.js.map +1 -1
  90. package/dist/layers/photos.d.ts +48 -0
  91. package/dist/layers/photos.js +139 -0
  92. package/dist/layers/photos.js.map +1 -0
  93. package/dist/layers/symbols.d.ts +5 -1
  94. package/dist/layers/symbols.js +111 -32
  95. package/dist/layers/symbols.js.map +1 -1
  96. package/dist/layers/trees.d.ts +28 -0
  97. package/dist/layers/trees.js +51 -0
  98. package/dist/layers/trees.js.map +1 -0
  99. package/dist/layers/vectors.d.ts +29 -2
  100. package/dist/layers/vectors.js +98 -9
  101. package/dist/layers/vectors.js.map +1 -1
  102. package/dist/map/frame-loop.d.ts +2 -0
  103. package/dist/map/frame-loop.js +3 -3
  104. package/dist/map/frame-loop.js.map +1 -1
  105. package/dist/map/layer-spec.d.ts +3 -0
  106. package/dist/map/layer-spec.js +2 -0
  107. package/dist/map/layer-spec.js.map +1 -1
  108. package/dist/map.d.ts +8 -0
  109. package/dist/map.js +32 -2
  110. package/dist/map.js.map +1 -1
  111. package/dist/panoramax.d.ts +55 -0
  112. package/dist/panoramax.js +97 -0
  113. package/dist/panoramax.js.map +1 -0
  114. package/dist/react/Layer.d.ts +1 -0
  115. package/dist/react/Layer.js.map +1 -1
  116. package/dist/react/VectorGeometry.d.ts +22 -8
  117. package/dist/react/VectorGeometry.js +36 -14
  118. package/dist/react/VectorGeometry.js.map +1 -1
  119. package/dist/react/VectorTiles.d.ts +65 -0
  120. package/dist/react/VectorTiles.js +112 -0
  121. package/dist/react/VectorTiles.js.map +1 -0
  122. package/dist/react/context.d.ts +9 -0
  123. package/dist/react/context.js +32 -0
  124. package/dist/react/context.js.map +1 -1
  125. package/dist/react/index.d.ts +7 -1
  126. package/dist/react/index.js +7 -1
  127. package/dist/react/index.js.map +1 -1
  128. package/dist/types.d.ts +2 -0
  129. package/dist/types.js.map +1 -1
  130. package/dist/util/geo.d.ts +8 -0
  131. package/dist/util/geo.js +8 -0
  132. package/dist/util/geo.js.map +1 -1
  133. package/dist/util/gltf.d.ts +26 -0
  134. package/dist/util/gltf.js +52 -0
  135. package/dist/util/gltf.js.map +1 -0
  136. package/dist/util/roofs.d.ts +18 -0
  137. package/dist/util/roofs.js +44 -0
  138. package/dist/util/roofs.js.map +1 -0
  139. package/dist/util/style-floats.d.ts +33 -0
  140. package/dist/util/style-floats.js +34 -0
  141. package/dist/util/style-floats.js.map +1 -0
  142. package/dist/util/sun.js +1 -1
  143. package/dist/util/sun.js.map +1 -1
  144. package/dist/wasm/isard.d.ts +56 -17
  145. package/dist/wasm/isard.js +128 -18
  146. package/dist/wasm/isard_core.d.ts +44 -17
  147. package/dist/wasm/isard_core.js +104 -18
  148. package/dist/wasm/isard_tess.d.ts +6 -3
  149. package/dist/wasm/isard_tess.js +27 -4
  150. package/dist/workers/basemap/furniture.d.ts +13 -0
  151. package/dist/workers/basemap/geometry.d.ts +35 -22
  152. package/dist/workers/basemap/labels.d.ts +18 -2
  153. package/dist/workers/basemap/lamps.d.ts +10 -0
  154. package/dist/workers/basemap/tiles.d.ts +2 -0
  155. package/dist/workers/basemap/trees.d.ts +6 -1
  156. package/dist/workers/basemap.worker.d.ts +58 -2
  157. package/dist/workers/basemap.worker.js +26 -3
  158. package/dist/workers/basemap.worker.js.map +1 -1
  159. package/package.json +1 -1
package/dist/formats.d.ts CHANGED
@@ -1,11 +1,16 @@
1
1
  /**
2
- * `isard/formats`: KML, GPX and TopoJSON read into GeoJSON feature collections, for the feature layers.
2
+ * `isard/formats`: KML, GPX and TopoJSON read into GeoJSON feature collections, for the feature layers; COLLADA models
3
+ * (BIM and CAD exports) into glTF binaries, and IFC models (BIM) into a glTF binary per storey with their elements, for
4
+ * the model layers.
3
5
  *
4
6
  * ```ts
5
- * import { parseGpx } from 'isard/formats';
7
+ * import { loadCollada, parseGpx } from 'isard/formats';
6
8
  * map.addLines({ data: parseGpx(await (await fetch('track.gpx')).text()), color: '#0057b8' });
9
+ * map.addModels({ data: await loadCollada('building.dae'), instances: [{ lonLat: [4.2165, 44.844] }] });
7
10
  * ```
8
11
  */
12
+ export { type ColladaImages, colladaImages, loadCollada, parseCollada } from './data/collada.ts';
9
13
  export { parseGpx } from './data/gpx.ts';
14
+ export { type IfcElement, type IfcModel, type IfcOptions, type IfcPlace, type IfcProperties, type IfcStorey, loadIfc, WEB_IFC, } from './data/ifc.ts';
10
15
  export { parseKml } from './data/kml.ts';
11
16
  export { parseTopoJson, type TopoGeometry, type Topology } from './data/topojson.ts';
package/dist/formats.js CHANGED
@@ -1,12 +1,17 @@
1
1
  /**
2
- * `isard/formats`: KML, GPX and TopoJSON read into GeoJSON feature collections, for the feature layers.
2
+ * `isard/formats`: KML, GPX and TopoJSON read into GeoJSON feature collections, for the feature layers; COLLADA models
3
+ * (BIM and CAD exports) into glTF binaries, and IFC models (BIM) into a glTF binary per storey with their elements, for
4
+ * the model layers.
3
5
  *
4
6
  * ```ts
5
- * import { parseGpx } from 'isard/formats';
7
+ * import { loadCollada, parseGpx } from 'isard/formats';
6
8
  * map.addLines({ data: parseGpx(await (await fetch('track.gpx')).text()), color: '#0057b8' });
9
+ * map.addModels({ data: await loadCollada('building.dae'), instances: [{ lonLat: [4.2165, 44.844] }] });
7
10
  * ```
8
11
  */
12
+ export { colladaImages, loadCollada, parseCollada } from "./data/collada.js";
9
13
  export { parseGpx } from "./data/gpx.js";
14
+ export { loadIfc, WEB_IFC, } from "./data/ifc.js";
10
15
  export { parseKml } from "./data/kml.js";
11
16
  export { parseTopoJson } from "./data/topojson.js";
12
17
  //# sourceMappingURL=formats.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"formats.js","sourceRoot":"","sources":["../src/formats.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,aAAa,EAAoC,MAAM,oBAAoB,CAAC","sourcesContent":["/**\n * `isard/formats`: KML, GPX and TopoJSON read into GeoJSON feature collections, for the feature layers.\n *\n * ```ts\n * import { parseGpx } from 'isard/formats';\n * map.addLines({ data: parseGpx(await (await fetch('track.gpx')).text()), color: '#0057b8' });\n * ```\n */\nexport { parseGpx } from './data/gpx.ts';\nexport { parseKml } from './data/kml.ts';\nexport { parseTopoJson, type TopoGeometry, type Topology } from './data/topojson.ts';\n"]}
1
+ {"version":3,"file":"formats.js","sourceRoot":"","sources":["../src/formats.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAsB,aAAa,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjG,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAOL,OAAO,EACP,OAAO,GACR,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,aAAa,EAAoC,MAAM,oBAAoB,CAAC","sourcesContent":["/**\n * `isard/formats`: KML, GPX and TopoJSON read into GeoJSON feature collections, for the feature layers; COLLADA models\n * (BIM and CAD exports) into glTF binaries, and IFC models (BIM) into a glTF binary per storey with their elements, for\n * the model layers.\n *\n * ```ts\n * import { loadCollada, parseGpx } from 'isard/formats';\n * map.addLines({ data: parseGpx(await (await fetch('track.gpx')).text()), color: '#0057b8' });\n * map.addModels({ data: await loadCollada('building.dae'), instances: [{ lonLat: [4.2165, 44.844] }] });\n * ```\n */\n\nexport { type ColladaImages, colladaImages, loadCollada, parseCollada } from './data/collada.ts';\nexport { parseGpx } from './data/gpx.ts';\nexport {\n type IfcElement,\n type IfcModel,\n type IfcOptions,\n type IfcPlace,\n type IfcProperties,\n type IfcStorey,\n loadIfc,\n WEB_IFC,\n} from './data/ifc.ts';\nexport { parseKml } from './data/kml.ts';\nexport { parseTopoJson, type TopoGeometry, type Topology } from './data/topojson.ts';\n"]}
@@ -88,13 +88,25 @@ export declare const BATIMENTS_3D_URL = "https://prd-ign-mut-bat3.s3.sbg.io.clou
88
88
  * through a proxy (`url`)
89
89
  */
90
90
  export declare const batiments3d: (options?: Partial<Tiles3dOptions>) => Tiles3dOptions;
91
- /** What a building of the BD TOPO gives its extrusion */
91
+ /** What a building of the BD TOPO gives its extrusion: its height to the eaves (`hauteur`), the altitudes of its foot,
92
+ * its eaves and its ridge (metres; the ridge's known in some places only) */
92
93
  export interface BdTopoBuilding {
93
94
  hauteur: number | null;
95
+ altitude_minimale_sol?: number | null;
96
+ altitude_minimale_toit?: number | null;
97
+ altitude_maximale_toit?: number | null;
94
98
  }
99
+ /**
100
+ * A BD TOPO building's height, roof and roof height as `addExtrusions` takes them: raised to its ridge, its roof as
101
+ * high as from its eaves to its ridge (flat under half a metre), where the BD TOPO gives its ridge's altitude (most of
102
+ * the towns, not Paris yet); else to its `hauteur` (`defaultHeight` without one), its roof generated from its outline
103
+ * within it
104
+ */
105
+ export declare const bdtopoRoofs: (defaultHeight?: number) => Pick<ExtrusionOptions<BdTopoBuilding>, "height" | "roof" | "roofHeight">;
95
106
  /**
96
107
  * The BD TOPO buildings of a box (west, south, east, north, degrees) as an extrusion layer, ready for
97
- * `map.addExtrusions`: from the Géoplateforme's WFS, raised to their `hauteur` (`defaultHeight` without one)
108
+ * `map.addExtrusions`: from the Géoplateforme's WFS, raised to their ridge under a roof of its height where the BD
109
+ * TOPO gives it (`bdtopoRoofs`), else to their `hauteur` (`defaultHeight` without one)
98
110
  */
99
111
  export declare const bdtopoBuildings: (box: [number, number, number, number], options?: Partial<ExtrusionOptions<BdTopoBuilding>> & {
100
112
  defaultHeight?: number;
@@ -140,14 +140,36 @@ export const BATIMENTS_3D_URL = 'https://prd-ign-mut-bat3.s3.sbg.io.cloud.ovh.ne
140
140
  export const batiments3d = (options = {}) => {
141
141
  return { url: BATIMENTS_3D_URL, geoid: true, color: '#e4e1d8', maxScreenSpaceError: 16, ...options };
142
142
  };
143
+ /** Metres under which a BD TOPO roof, from its eaves to its ridge, is drawn flat */
144
+ const FLAT_ROOF_METRES = 0.5;
145
+ /** A BD TOPO building's roof over its eaves (metres, from its ridge's and its eaves' altitudes), undefined unknown */
146
+ const roofOver = (p) => {
147
+ const [eaves, ridge] = [p.altitude_minimale_toit, p.altitude_maximale_toit];
148
+ return typeof eaves === 'number' && typeof ridge === 'number' && ridge >= eaves ? ridge - eaves : undefined;
149
+ };
150
+ /**
151
+ * A BD TOPO building's height, roof and roof height as `addExtrusions` takes them: raised to its ridge, its roof as
152
+ * high as from its eaves to its ridge (flat under half a metre), where the BD TOPO gives its ridge's altitude (most of
153
+ * the towns, not Paris yet); else to its `hauteur` (`defaultHeight` without one), its roof generated from its outline
154
+ * within it
155
+ */
156
+ export const bdtopoRoofs = (defaultHeight = 6) => ({
157
+ height: (p) => (p.hauteur ?? defaultHeight) + (roofOver(p) ?? 0),
158
+ roof: (p) => {
159
+ const over = roofOver(p);
160
+ return over === undefined || over >= FLAT_ROOF_METRES ? 'generated' : 'flat';
161
+ },
162
+ roofHeight: (p) => roofOver(p) ?? Number.NaN,
163
+ });
143
164
  /**
144
165
  * The BD TOPO buildings of a box (west, south, east, north, degrees) as an extrusion layer, ready for
145
- * `map.addExtrusions`: from the Géoplateforme's WFS, raised to their `hauteur` (`defaultHeight` without one)
166
+ * `map.addExtrusions`: from the Géoplateforme's WFS, raised to their ridge under a roof of its height where the BD
167
+ * TOPO gives it (`bdtopoRoofs`), else to their `hauteur` (`defaultHeight` without one)
146
168
  */
147
169
  export const bdtopoBuildings = async (box, options = {}) => {
148
170
  const { defaultHeight = 6, signal, ...style } = options;
149
171
  const data = await geoplateformeWfs('BDTOPO_V3:batiment', box, signal ? { signal } : {});
150
- return { data, height: (p) => p.hauteur ?? defaultHeight, color: '#e4e1d8', ...style };
172
+ return { data, ...bdtopoRoofs(defaultHeight), color: '#e4e1d8', ...style };
151
173
  };
152
174
  const GEOCODING_URL = 'https://data.geopf.fr/geocodage/completion';
153
175
  /** One result of the completion service: what is read of it, checked (JSON from elsewhere) */
@@ -1 +1 @@
1
- {"version":3,"file":"geoplateforme.js","sourceRoot":"","sources":["../src/geoplateforme.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAInD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,wGAAwG;AACxG,MAAM,CAAC,MAAM,eAAe,GAC1B,mGAAmG,CAAC;AAEtG;SACS;AACT,MAAM,MAAM,GAAqC,CAAC,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;AAEtE;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,IAAY,EAAE,GAAW,EAAE,GAAW,EAAY,EAAE;IAChF,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAc,EAAE;QACvF,MAAM,KAAK,GAAG,GAAG,GAAG,CAAC,CAAC;QAEtB,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,GAAG,CAAC,IAAI,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,QAAQ,CAAC,EAAE,CAAC;IACjF,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,GAAG,EAAE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MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE,WAAW,CAAC,GAAG,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAEtG,IAAI,CAAC,QAAQ,CAAC,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,qBAAqB,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IAE1E,MAAM,IAAI,GAAY,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IAC5C,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;IAElF,OAAO,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAC9C,KAAK,EAAE,CAAC,CAAC,QAAQ;QACjB,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAClB,IAAI,EAAE,CAAC,CAAC,IAAI,KAAK,eAAe,IAAI,CAAC,CAAC,IAAI,KAAK,aAAa,IAAI,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO;KAC1G,CAAC,CAAC,CAAC;AACN,CAAC,CAAC","sourcesContent":["/**\n * The Géoplateforme's data (IGN, France; open, no key): its WMTS and WMS rasters as raster layers, its WFS features as\n * GeoJSON. Its basemaps, hillshade, terrain model and vector styles are named options of the map (`'ign-plan'`,\n * `hillshade`, `terrain: 'ign'`, `PLAN_STYLES`); the rasters credit the IGN by themselves.\n */\n\nimport type { TileGrid, TileMatrix } from './basemap/grid.ts';\nimport { withHeaders } from './engine/requests.ts';\nimport type { ExtrusionOptions } from './layers/extrusions.ts';\nimport type { FeatureCollection, Properties } from './layers/features.ts';\nimport type { GeoMapOptions, RasterOptions, Tiles3dOptions } from './types.ts';\nimport { isRecord } from './util/guards.ts';\n\n/** Credits of the Géoplateforme's data: its basemaps, hillshade, terrain model, rasters and features */\nexport const IGN_ATTRIBUTION =\n '<a href=\"https://www.ign.fr/\">© IGN</a> – <a href=\"https://geoservices.ign.fr/\">Géoplateforme</a>';\n\n/** France (metropolitan, Corsica included) in longitudes and latitudes, where the Géoplateforme's Lambert-93 layers\n * lie */\nconst FRANCE: [number, number, number, number] = [-5.5, 41, 10, 51.5];\n\n/**\n * The Géoplateforme's Lambert-93 tile matrix sets of 5 and 10 cm (`2154_10cm_6_20`, `2154_5cm_6_22`…: one pyramid,\n * 209 715.2 m per pixel at level 0, halved at each level, from the corner (0, 12 000 000)), levels `min` to `max`, over\n * France\n */\nexport const lambert93Grid = (name: string, min: number, max: number): TileGrid => {\n const matrices = Array.from({ length: Math.max(0, max - min + 1) }, (_, i): TileMatrix => {\n const level = min + i;\n\n return { id: level, resolution: 209715.2 / 2 ** level, origin: [0, 12000000] };\n });\n\n return { crs: 'EPSG:2154', matrices, bounds: FRANCE, name };\n};\n\n/**\n * A layer of the Géoplateforme's WMTS as raster options for `addRaster`, crediting the IGN:\n * `geoplateformeWmts('ORTHOIMAGERY.ORTHOPHOTOS', { format: 'image/jpeg' })`. The layer names are those of its\n * capabilities (https://data.geopf.fr/wmts?SERVICE=WMTS&REQUEST=GetCapabilities). In its Web Mercator grid (`PM`) by\n * default; a Lambert-93 layer in its matrix set (`matrixSet: '2154_10cm_6_20'`, a set of 5 or 10 cm, read from the\n * capabilities) or another `grid` (from `wmtsGrid`, its set named) is reprojected by the map\n */\nexport const geoplateformeWmts = (\n layer: string,\n options: { format?: string; style?: string; matrixSet?: string } & Omit<RasterOptions, 'url'> = {},\n): RasterOptions => {\n const { format = 'image/png', style = 'normal', matrixSet, ...raster } = options;\n const set = (typeof raster.grid === 'object' ? raster.grid.name : undefined) ?? matrixSet ?? 'PM';\n const lambert = /^2154_(?:5|10)cm_(\\d+)_(\\d+)$/.exec(set);\n\n if (lambert && raster.grid === undefined) raster.grid = lambert93Grid(set, Number(lambert[1]), Number(lambert[2]));\n else if (set !== 'PM' && raster.grid === undefined) {\n throw new Error(`isard: the grid of the matrix set ${set}: wmtsGrid(capabilities, '${layer}', '${set}')`);\n }\n\n return {\n ...(raster.grid === undefined ? { maxZoom: 19 } : {}),\n attribution: IGN_ATTRIBUTION,\n ...raster,\n url:\n `https://data.geopf.fr/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&STYLE=${encodeURIComponent(style)}` +\n `&TILEMATRIXSET=${encodeURIComponent(set)}&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}` +\n `&LAYER=${encodeURIComponent(layer)}&FORMAT=${format}`,\n };\n};\n\n/**\n * Layers of the Géoplateforme's WMS (raster, `wms-r`) as raster options for `addRaster`, crediting the IGN: 256 px\n * images of each tile, transparent where empty. `geoplateformeWms('CADASTRALPARCELS.PARCELLAIRE_EXPRESS')`. Asked for\n * in EPSG:3857, or in `crs` (`'EPSG:2154'`: the box of each tile in Lambert-93, at the tile's `size`, reprojected by\n * the map; `'EPSG:4326'` is asked for as CRS:84, longitude first)\n */\nexport const geoplateformeWms = (\n layers: string,\n options: { format?: string; styles?: string; crs?: string } & Omit<RasterOptions, 'url'> = {},\n): RasterOptions => {\n const { format = 'image/png', styles = '', crs = 'EPSG:3857', ...raster } = options;\n const projected = crs !== 'EPSG:3857';\n // WMS 1.3 puts the latitude first in EPSG:4326; {bbox} is x, y\n const asked = crs === 'EPSG:4326' ? 'CRS:84' : crs;\n\n return {\n maxZoom: 20,\n attribution: IGN_ATTRIBUTION,\n ...(projected ? { grid: { crs, ...(crs === 'EPSG:2154' ? { bounds: FRANCE } : {}) } } : {}),\n ...raster,\n url:\n `https://data.geopf.fr/wms-r/wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&CRS=${asked}&BBOX={bbox}` +\n // Reprojected, the image of each tile at its size\n `&${projected ? 'WIDTH={width}&HEIGHT={height}' : 'WIDTH=256&HEIGHT=256'}&TRANSPARENT=TRUE` +\n `&LAYERS=${encodeURIComponent(layers)}` +\n `&STYLES=${encodeURIComponent(styles)}&FORMAT=${format}`,\n };\n};\n\n/** Features the Géoplateforme's WFS returns per request at most */\nconst WFS_PAGE = 5000;\n\n/** A page of WFS features in GeoJSON, with the number of features matched (a string from some servers) */\ntype WfsPage<P> = FeatureCollection<P> & { numberMatched?: number | string };\n\nconst isWfsPage = <P>(value: unknown): value is WfsPage<P> =>\n typeof value === 'object' && value !== null && 'features' in value && Array.isArray(value.features);\n\n/**\n * Features of the Géoplateforme's WFS in a box (west, south, east, north, degrees), as GeoJSON in longitudes and\n * latitudes: `await geoplateformeWfs('BDTOPO_V3:batiment', [2.41, 48.84, 2.43, 48.85])`. At most `count` features\n * (default 50 000), asked by pages of 5000: the first one tells how many there are, the others are asked together.\n * The type names are those of its capabilities (BD TOPO, ADMIN EXPRESS…). With `srsName` (`'EPSG:2154'`), the\n * features come in that CRS (the box stays in degrees), the collection naming it in its `crs` member: the feature\n * layers reproject it by themselves\n */\nexport const geoplateformeWfs = async <P = Properties>(\n typeName: string,\n [west, south, east, north]: [number, number, number, number],\n options: { count?: number; signal?: AbortSignal; srsName?: string } = {},\n): Promise<FeatureCollection<P>> => {\n const limit = Math.max(1, options.count ?? 50_000);\n const page = async (start: number, count: number) => {\n const url = new URL('https://data.geopf.fr/wfs/ows');\n\n url.search = new URLSearchParams({\n SERVICE: 'WFS',\n VERSION: '2.0.0',\n REQUEST: 'GetFeature',\n TYPENAMES: typeName,\n OUTPUTFORMAT: 'application/json',\n SRSNAME: options.srsName ?? 'EPSG:4326',\n // WFS 2.0 in EPSG:4326: latitude first\n BBOX: `${south},${west},${north},${east},urn:ogc:def:crs:EPSG::4326`,\n COUNT: String(count),\n // The first page as a single request always was\n ...(start > 0 ? { STARTINDEX: String(start) } : {}),\n }).toString();\n\n const response = await fetch(url, withHeaders(url, options.signal ? { signal: options.signal } : {}));\n\n if (!response.ok) throw new Error(`isard: ${typeName}: ${response.status}`);\n\n const json: unknown = await response.json();\n\n if (!isWfsPage<P>(json)) throw new Error(`isard: ${typeName}: not a GeoJSON feature collection`);\n\n return json;\n };\n const first = await page(0, Math.min(WFS_PAGE, limit));\n const matched = Number(first.numberMatched);\n const total = Math.min(Number.isFinite(matched) ? matched : 0, limit);\n\n if (first.features.length < WFS_PAGE || total <= first.features.length) return first;\n\n const starts = Array.from(\n { length: Math.ceil((total - first.features.length) / WFS_PAGE) },\n (_, i) => first.features.length + i * WFS_PAGE,\n );\n const rest = await Promise.all(starts.map((start) => page(start, Math.min(WFS_PAGE, total - start))));\n // Pages may overlap where the server's order shifts: each feature once, by its id\n const seen = new Set<unknown>();\n const features = [first, ...rest]\n .flatMap((r) => r.features)\n .filter((f) => f.id === undefined || (!seen.has(f.id) && seen.add(f.id) !== undefined));\n\n return { ...first, features };\n};\n\n/** Map presets over France, the IGN's data in a word: spread into `GeoMap.create`'s options or named by `preset` */\nexport const IGN_PRESETS = {\n /** PLAN IGN (vector, grey) seen from above */\n ign: { basemap: 'ign-plan-grey-vector', projection: 'mercator' },\n /** PLAN IGN over the IGN relief (RGE ALTI), for 3D: buildings, meshes, viewsheds */\n 'ign-3d': { basemap: 'ign-plan-grey-vector', terrain: { model: 'ign' }, projection: 'mercator', pitch: 55 },\n /** The IGN orthophotos over the IGN relief */\n 'ign-ortho-3d': { basemap: 'ign-ortho', terrain: { model: 'ign' }, projection: 'mercator', pitch: 55 },\n} as const satisfies Record<string, GeoMapOptions>;\n\n/** A preset of `IGN_PRESETS` by name */\nexport type IgnPreset = keyof typeof IGN_PRESETS;\n\n/** The IGN's Bâtiments 3D (France, 3D Tiles 1.1): its tileset */\nexport const BATIMENTS_3D_URL = 'https://prd-ign-mut-bat3.s3.sbg.io.cloud.ovh.net/tileset.json';\n\n/**\n * The IGN's Bâtiments 3D as a 3D Tiles layer, ready for `map.addTiles3d`: their heights are altitudes (NGF-IGN69),\n * raised by the geoid onto the IGN relief; untextured, colored and shaded; picked with their BD TOPO attributes\n * (`cleabs`, `hauteur`, `nature`, `usage_1`…). Its server sends no CORS headers yet: from a page of another origin,\n * through a proxy (`url`)\n */\nexport const batiments3d = (options: Partial<Tiles3dOptions> = {}): Tiles3dOptions => {\n return { url: BATIMENTS_3D_URL, geoid: true, color: '#e4e1d8', maxScreenSpaceError: 16, ...options };\n};\n\n/** What a building of the BD TOPO gives its extrusion */\nexport interface BdTopoBuilding {\n hauteur: number | null;\n}\n\n/**\n * The BD TOPO buildings of a box (west, south, east, north, degrees) as an extrusion layer, ready for\n * `map.addExtrusions`: from the Géoplateforme's WFS, raised to their `hauteur` (`defaultHeight` without one)\n */\nexport const bdtopoBuildings = async (\n box: [number, number, number, number],\n options: Partial<ExtrusionOptions<BdTopoBuilding>> & { defaultHeight?: number; signal?: AbortSignal } = {},\n): Promise<ExtrusionOptions<BdTopoBuilding>> => {\n const { defaultHeight = 6, signal, ...style } = options;\n const data = await geoplateformeWfs<BdTopoBuilding>('BDTOPO_V3:batiment', box, signal ? { signal } : {});\n\n return { data, height: (p) => p.hauteur ?? defaultHeight, color: '#e4e1d8', ...style };\n};\n\n/** A place the Géoplateforme's geocoding found: its label, position and kind */\nexport interface GeocodedPlace {\n /** The full label (`10 Rue de Rivoli, 75004 Paris`) */\n label: string;\n lonLat: [lon: number, lat: number];\n /** `'address'` (a street address) or `'place'` (a place name: a town, a monument, a summit) */\n kind: 'address' | 'place';\n}\n\nconst GEOCODING_URL = 'https://data.geopf.fr/geocodage/completion';\n\n/** One result of the completion service: what is read of it, checked (JSON from elsewhere) */\nconst isCompletion = (value: unknown): value is { fulltext: string; x: number; y: number; kind?: unknown } =>\n isRecord(value) && typeof value.fulltext === 'string' && Number.isFinite(value.x) && Number.isFinite(value.y);\n\n/**\n * Places of France matching `text` as it is typed, from the Géoplateforme's completion service (addresses and place\n * names, no key), the best first; an empty list for a text under 3 characters\n */\nexport const geoplateformeGeocode = async (\n text: string,\n options: { count?: number; signal?: AbortSignal } = {},\n): Promise<GeocodedPlace[]> => {\n if (text.trim().length < 3) return [];\n\n const url = `${GEOCODING_URL}?text=${encodeURIComponent(text)}&type=StreetAddress,PositionOfInterest&maximumResponses=${options.count ?? 10}`;\n const response = await fetch(url, withHeaders(url, options.signal ? { signal: options.signal } : {}));\n\n if (!response.ok) throw new Error(`isard: geocoding: ${response.status}`);\n\n const json: unknown = await response.json();\n const results = isRecord(json) && Array.isArray(json.results) ? json.results : [];\n\n return results.filter(isCompletion).map((r) => ({\n label: r.fulltext,\n lonLat: [r.x, r.y],\n kind: r.kind === 'StreetAddress' || r.kind === 'housenumber' || r.kind === 'street' ? 'address' : 'place',\n }));\n};\n"]}
1
+ {"version":3,"file":"geoplateforme.js","sourceRoot":"","sources":["../src/geoplateforme.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAInD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,wGAAwG;AACxG,MAAM,CAAC,MAAM,eAAe,GAC1B,mGAAmG,CAAC;AAEtG;SACS;AACT,MAAM,MAAM,GAAqC,CAAC,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;AAEtE;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,IAAY,EAAE,GAAW,EAAE,GAAW,EAAY,EAAE;IAChF,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAc,EAAE;QACvF,MAAM,KAAK,GAAG,GAAG,GAAG,CAAC,CAAC;QAEtB,OAAO,EAAE,EA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,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAEtG,IAAI,CAAC,QAAQ,CAAC,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,qBAAqB,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IAE1E,MAAM,IAAI,GAAY,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IAC5C,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;IAElF,OAAO,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAC9C,KAAK,EAAE,CAAC,CAAC,QAAQ;QACjB,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAClB,IAAI,EAAE,CAAC,CAAC,IAAI,KAAK,eAAe,IAAI,CAAC,CAAC,IAAI,KAAK,aAAa,IAAI,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO;KAC1G,CAAC,CAAC,CAAC;AACN,CAAC,CAAC","sourcesContent":["/**\n * The Géoplateforme's data (IGN, France; open, no key): its WMTS and WMS rasters as raster layers, its WFS features as\n * GeoJSON. Its basemaps, hillshade, terrain model and vector styles are named options of the map (`'ign-plan'`,\n * `hillshade`, `terrain: 'ign'`, `PLAN_STYLES`); the rasters credit the IGN by themselves.\n */\n\nimport type { TileGrid, TileMatrix } from './basemap/grid.ts';\nimport { withHeaders } from './engine/requests.ts';\nimport type { ExtrusionOptions } from './layers/extrusions.ts';\nimport type { FeatureCollection, Properties } from './layers/features.ts';\nimport type { GeoMapOptions, RasterOptions, Tiles3dOptions } from './types.ts';\nimport { isRecord } from './util/guards.ts';\n\n/** Credits of the Géoplateforme's data: its basemaps, hillshade, terrain model, rasters and features */\nexport const IGN_ATTRIBUTION =\n '<a href=\"https://www.ign.fr/\">© IGN</a> – <a href=\"https://geoservices.ign.fr/\">Géoplateforme</a>';\n\n/** France (metropolitan, Corsica included) in longitudes and latitudes, where the Géoplateforme's Lambert-93 layers\n * lie */\nconst FRANCE: [number, number, number, number] = [-5.5, 41, 10, 51.5];\n\n/**\n * The Géoplateforme's Lambert-93 tile matrix sets of 5 and 10 cm (`2154_10cm_6_20`, `2154_5cm_6_22`…: one pyramid,\n * 209 715.2 m per pixel at level 0, halved at each level, from the corner (0, 12 000 000)), levels `min` to `max`, over\n * France\n */\nexport const lambert93Grid = (name: string, min: number, max: number): TileGrid => {\n const matrices = Array.from({ length: Math.max(0, max - min + 1) }, (_, i): TileMatrix => {\n const level = min + i;\n\n return { id: level, resolution: 209715.2 / 2 ** level, origin: [0, 12000000] };\n });\n\n return { crs: 'EPSG:2154', matrices, bounds: FRANCE, name };\n};\n\n/**\n * A layer of the Géoplateforme's WMTS as raster options for `addRaster`, crediting the IGN:\n * `geoplateformeWmts('ORTHOIMAGERY.ORTHOPHOTOS', { format: 'image/jpeg' })`. The layer names are those of its\n * capabilities (https://data.geopf.fr/wmts?SERVICE=WMTS&REQUEST=GetCapabilities). In its Web Mercator grid (`PM`) by\n * default; a Lambert-93 layer in its matrix set (`matrixSet: '2154_10cm_6_20'`, a set of 5 or 10 cm, read from the\n * capabilities) or another `grid` (from `wmtsGrid`, its set named) is reprojected by the map\n */\nexport const geoplateformeWmts = (\n layer: string,\n options: { format?: string; style?: string; matrixSet?: string } & Omit<RasterOptions, 'url'> = {},\n): RasterOptions => {\n const { format = 'image/png', style = 'normal', matrixSet, ...raster } = options;\n const set = (typeof raster.grid === 'object' ? raster.grid.name : undefined) ?? matrixSet ?? 'PM';\n const lambert = /^2154_(?:5|10)cm_(\\d+)_(\\d+)$/.exec(set);\n\n if (lambert && raster.grid === undefined) raster.grid = lambert93Grid(set, Number(lambert[1]), Number(lambert[2]));\n else if (set !== 'PM' && raster.grid === undefined) {\n throw new Error(`isard: the grid of the matrix set ${set}: wmtsGrid(capabilities, '${layer}', '${set}')`);\n }\n\n return {\n ...(raster.grid === undefined ? { maxZoom: 19 } : {}),\n attribution: IGN_ATTRIBUTION,\n ...raster,\n url:\n `https://data.geopf.fr/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&STYLE=${encodeURIComponent(style)}` +\n `&TILEMATRIXSET=${encodeURIComponent(set)}&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}` +\n `&LAYER=${encodeURIComponent(layer)}&FORMAT=${format}`,\n };\n};\n\n/**\n * Layers of the Géoplateforme's WMS (raster, `wms-r`) as raster options for `addRaster`, crediting the IGN: 256 px\n * images of each tile, transparent where empty. `geoplateformeWms('CADASTRALPARCELS.PARCELLAIRE_EXPRESS')`. Asked for\n * in EPSG:3857, or in `crs` (`'EPSG:2154'`: the box of each tile in Lambert-93, at the tile's `size`, reprojected by\n * the map; `'EPSG:4326'` is asked for as CRS:84, longitude first)\n */\nexport const geoplateformeWms = (\n layers: string,\n options: { format?: string; styles?: string; crs?: string } & Omit<RasterOptions, 'url'> = {},\n): RasterOptions => {\n const { format = 'image/png', styles = '', crs = 'EPSG:3857', ...raster } = options;\n const projected = crs !== 'EPSG:3857';\n // WMS 1.3 puts the latitude first in EPSG:4326; {bbox} is x, y\n const asked = crs === 'EPSG:4326' ? 'CRS:84' : crs;\n\n return {\n maxZoom: 20,\n attribution: IGN_ATTRIBUTION,\n ...(projected ? { grid: { crs, ...(crs === 'EPSG:2154' ? { bounds: FRANCE } : {}) } } : {}),\n ...raster,\n url:\n `https://data.geopf.fr/wms-r/wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&CRS=${asked}&BBOX={bbox}` +\n // Reprojected, the image of each tile at its size\n `&${projected ? 'WIDTH={width}&HEIGHT={height}' : 'WIDTH=256&HEIGHT=256'}&TRANSPARENT=TRUE` +\n `&LAYERS=${encodeURIComponent(layers)}` +\n `&STYLES=${encodeURIComponent(styles)}&FORMAT=${format}`,\n };\n};\n\n/** Features the Géoplateforme's WFS returns per request at most */\nconst WFS_PAGE = 5000;\n\n/** A page of WFS features in GeoJSON, with the number of features matched (a string from some servers) */\ntype WfsPage<P> = FeatureCollection<P> & { numberMatched?: number | string };\n\nconst isWfsPage = <P>(value: unknown): value is WfsPage<P> =>\n typeof value === 'object' && value !== null && 'features' in value && Array.isArray(value.features);\n\n/**\n * Features of the Géoplateforme's WFS in a box (west, south, east, north, degrees), as GeoJSON in longitudes and\n * latitudes: `await geoplateformeWfs('BDTOPO_V3:batiment', [2.41, 48.84, 2.43, 48.85])`. At most `count` features\n * (default 50 000), asked by pages of 5000: the first one tells how many there are, the others are asked together.\n * The type names are those of its capabilities (BD TOPO, ADMIN EXPRESS…). With `srsName` (`'EPSG:2154'`), the\n * features come in that CRS (the box stays in degrees), the collection naming it in its `crs` member: the feature\n * layers reproject it by themselves\n */\nexport const geoplateformeWfs = async <P = Properties>(\n typeName: string,\n [west, south, east, north]: [number, number, number, number],\n options: { count?: number; signal?: AbortSignal; srsName?: string } = {},\n): Promise<FeatureCollection<P>> => {\n const limit = Math.max(1, options.count ?? 50_000);\n const page = async (start: number, count: number) => {\n const url = new URL('https://data.geopf.fr/wfs/ows');\n\n url.search = new URLSearchParams({\n SERVICE: 'WFS',\n VERSION: '2.0.0',\n REQUEST: 'GetFeature',\n TYPENAMES: typeName,\n OUTPUTFORMAT: 'application/json',\n SRSNAME: options.srsName ?? 'EPSG:4326',\n // WFS 2.0 in EPSG:4326: latitude first\n BBOX: `${south},${west},${north},${east},urn:ogc:def:crs:EPSG::4326`,\n COUNT: String(count),\n // The first page as a single request always was\n ...(start > 0 ? { STARTINDEX: String(start) } : {}),\n }).toString();\n\n const response = await fetch(url, withHeaders(url, options.signal ? { signal: options.signal } : {}));\n\n if (!response.ok) throw new Error(`isard: ${typeName}: ${response.status}`);\n\n const json: unknown = await response.json();\n\n if (!isWfsPage<P>(json)) throw new Error(`isard: ${typeName}: not a GeoJSON feature collection`);\n\n return json;\n };\n const first = await page(0, Math.min(WFS_PAGE, limit));\n const matched = Number(first.numberMatched);\n const total = Math.min(Number.isFinite(matched) ? matched : 0, limit);\n\n if (first.features.length < WFS_PAGE || total <= first.features.length) return first;\n\n const starts = Array.from(\n { length: Math.ceil((total - first.features.length) / WFS_PAGE) },\n (_, i) => first.features.length + i * WFS_PAGE,\n );\n const rest = await Promise.all(starts.map((start) => page(start, Math.min(WFS_PAGE, total - start))));\n // Pages may overlap where the server's order shifts: each feature once, by its id\n const seen = new Set<unknown>();\n const features = [first, ...rest]\n .flatMap((r) => r.features)\n .filter((f) => f.id === undefined || (!seen.has(f.id) && seen.add(f.id) !== undefined));\n\n return { ...first, features };\n};\n\n/** Map presets over France, the IGN's data in a word: spread into `GeoMap.create`'s options or named by `preset` */\nexport const IGN_PRESETS = {\n /** PLAN IGN (vector, grey) seen from above */\n ign: { basemap: 'ign-plan-grey-vector', projection: 'mercator' },\n /** PLAN IGN over the IGN relief (RGE ALTI), for 3D: buildings, meshes, viewsheds */\n 'ign-3d': { basemap: 'ign-plan-grey-vector', terrain: { model: 'ign' }, projection: 'mercator', pitch: 55 },\n /** The IGN orthophotos over the IGN relief */\n 'ign-ortho-3d': { basemap: 'ign-ortho', terrain: { model: 'ign' }, projection: 'mercator', pitch: 55 },\n} as const satisfies Record<string, GeoMapOptions>;\n\n/** A preset of `IGN_PRESETS` by name */\nexport type IgnPreset = keyof typeof IGN_PRESETS;\n\n/** The IGN's Bâtiments 3D (France, 3D Tiles 1.1): its tileset */\nexport const BATIMENTS_3D_URL = 'https://prd-ign-mut-bat3.s3.sbg.io.cloud.ovh.net/tileset.json';\n\n/**\n * The IGN's Bâtiments 3D as a 3D Tiles layer, ready for `map.addTiles3d`: their heights are altitudes (NGF-IGN69),\n * raised by the geoid onto the IGN relief; untextured, colored and shaded; picked with their BD TOPO attributes\n * (`cleabs`, `hauteur`, `nature`, `usage_1`…). Its server sends no CORS headers yet: from a page of another origin,\n * through a proxy (`url`)\n */\nexport const batiments3d = (options: Partial<Tiles3dOptions> = {}): Tiles3dOptions => {\n return { url: BATIMENTS_3D_URL, geoid: true, color: '#e4e1d8', maxScreenSpaceError: 16, ...options };\n};\n\n/** What a building of the BD TOPO gives its extrusion: its height to the eaves (`hauteur`), the altitudes of its foot,\n * its eaves and its ridge (metres; the ridge's known in some places only) */\nexport interface BdTopoBuilding {\n hauteur: number | null;\n altitude_minimale_sol?: number | null;\n altitude_minimale_toit?: number | null;\n altitude_maximale_toit?: number | null;\n}\n\n/** Metres under which a BD TOPO roof, from its eaves to its ridge, is drawn flat */\nconst FLAT_ROOF_METRES = 0.5;\n\n/** A BD TOPO building's roof over its eaves (metres, from its ridge's and its eaves' altitudes), undefined unknown */\nconst roofOver = (p: BdTopoBuilding): number | undefined => {\n const [eaves, ridge] = [p.altitude_minimale_toit, p.altitude_maximale_toit];\n\n return typeof eaves === 'number' && typeof ridge === 'number' && ridge >= eaves ? ridge - eaves : undefined;\n};\n\n/**\n * A BD TOPO building's height, roof and roof height as `addExtrusions` takes them: raised to its ridge, its roof as\n * high as from its eaves to its ridge (flat under half a metre), where the BD TOPO gives its ridge's altitude (most of\n * the towns, not Paris yet); else to its `hauteur` (`defaultHeight` without one), its roof generated from its outline\n * within it\n */\nexport const bdtopoRoofs = (\n defaultHeight = 6,\n): Pick<ExtrusionOptions<BdTopoBuilding>, 'height' | 'roof' | 'roofHeight'> => ({\n height: (p) => (p.hauteur ?? defaultHeight) + (roofOver(p) ?? 0),\n roof: (p) => {\n const over = roofOver(p);\n\n return over === undefined || over >= FLAT_ROOF_METRES ? 'generated' : 'flat';\n },\n roofHeight: (p) => roofOver(p) ?? Number.NaN,\n});\n\n/**\n * The BD TOPO buildings of a box (west, south, east, north, degrees) as an extrusion layer, ready for\n * `map.addExtrusions`: from the Géoplateforme's WFS, raised to their ridge under a roof of its height where the BD\n * TOPO gives it (`bdtopoRoofs`), else to their `hauteur` (`defaultHeight` without one)\n */\nexport const bdtopoBuildings = async (\n box: [number, number, number, number],\n options: Partial<ExtrusionOptions<BdTopoBuilding>> & { defaultHeight?: number; signal?: AbortSignal } = {},\n): Promise<ExtrusionOptions<BdTopoBuilding>> => {\n const { defaultHeight = 6, signal, ...style } = options;\n const data = await geoplateformeWfs<BdTopoBuilding>('BDTOPO_V3:batiment', box, signal ? { signal } : {});\n\n return { data, ...bdtopoRoofs(defaultHeight), color: '#e4e1d8', ...style };\n};\n\n/** A place the Géoplateforme's geocoding found: its label, position and kind */\nexport interface GeocodedPlace {\n /** The full label (`10 Rue de Rivoli, 75004 Paris`) */\n label: string;\n lonLat: [lon: number, lat: number];\n /** `'address'` (a street address) or `'place'` (a place name: a town, a monument, a summit) */\n kind: 'address' | 'place';\n}\n\nconst GEOCODING_URL = 'https://data.geopf.fr/geocodage/completion';\n\n/** One result of the completion service: what is read of it, checked (JSON from elsewhere) */\nconst isCompletion = (value: unknown): value is { fulltext: string; x: number; y: number; kind?: unknown } =>\n isRecord(value) && typeof value.fulltext === 'string' && Number.isFinite(value.x) && Number.isFinite(value.y);\n\n/**\n * Places of France matching `text` as it is typed, from the Géoplateforme's completion service (addresses and place\n * names, no key), the best first; an empty list for a text under 3 characters\n */\nexport const geoplateformeGeocode = async (\n text: string,\n options: { count?: number; signal?: AbortSignal } = {},\n): Promise<GeocodedPlace[]> => {\n if (text.trim().length < 3) return [];\n\n const url = `${GEOCODING_URL}?text=${encodeURIComponent(text)}&type=StreetAddress,PositionOfInterest&maximumResponses=${options.count ?? 10}`;\n const response = await fetch(url, withHeaders(url, options.signal ? { signal: options.signal } : {}));\n\n if (!response.ok) throw new Error(`isard: geocoding: ${response.status}`);\n\n const json: unknown = await response.json();\n const results = isRecord(json) && Array.isArray(json.results) ? json.results : [];\n\n return results.filter(isCompletion).map((r) => ({\n label: r.fulltext,\n lonLat: [r.x, r.y],\n kind: r.kind === 'StreetAddress' || r.kind === 'housenumber' || r.kind === 'street' ? 'address' : 'place',\n }));\n};\n"]}
package/dist/index.d.ts CHANGED
@@ -15,10 +15,12 @@ export { OPENFREEMAP_ATTRIBUTION, TERRAIN_TILES_ATTRIBUTION } from './basemap/ba
15
15
  export type { TileGrid, TileMatrix } from './basemap/grid.ts';
16
16
  export { PMTiles, type PmtilesEntry, type PmtilesHeader, type PmtilesTileType, tileIdToZxy, zxyToTileId, } from './basemap/pmtiles.ts';
17
17
  export { basicStyle, type PmtilesOptions } from './basemap/pmtileslayer.ts';
18
- export { type TreeColors, treeModel } from './basemap/trees.ts';
18
+ export { coniferModel, type TreeColors, treeModel } from './basemap/trees.ts';
19
19
  export type { CandidateIcon, CandidateOverlap, Json, LabelCandidate, RasterSource, Style, StyleLayer, } from './basemap/vectorstyle.ts';
20
20
  export type { VectorExtrusionOptions } from './basemap/vectortiles/extrusions.ts';
21
+ export type { FurnitureOptions } from './basemap/vectortiles/furniture.ts';
21
22
  export type { LabelsOptions } from './basemap/vectortiles/labels.ts';
23
+ export type { LampsOptions } from './basemap/vectortiles/lamps.ts';
22
24
  export type { StreetWindLayer, StreetWindOptions } from './basemap/vectortiles/street-wind.ts';
23
25
  export type { LoadedStyle } from './basemap/vectortiles/style.ts';
24
26
  export type { TreesOptions } from './basemap/vectortiles/trees.ts';
@@ -26,13 +28,15 @@ export type { VectorsOptions } from './basemap/vectortiles/vectors.ts';
26
28
  export type { VectorTilesOptions } from './basemap/vectortiles.ts';
27
29
  export { OPENFREEMAP_STYLES, PLAN_STYLES, VectorTiles } from './basemap/vectortiles.ts';
28
30
  export { parseWmtsGrid, wmtsGrid } from './basemap/wmts.ts';
31
+ export { type ColladaImages, colladaImages, loadCollada, parseCollada } from './data/collada.ts';
29
32
  export { type Crs, type CrsLike, getCrs, lambertConformalConic, registerCrs, reproject, transverseMercator, } from './data/crs.ts';
30
33
  export { parseGpx } from './data/gpx.ts';
34
+ export { type IfcElement, type IfcModel, type IfcOptions, type IfcPlace, type IfcProperties, type IfcStorey, loadIfc, WEB_IFC, } from './data/ifc.ts';
31
35
  export { parseKml } from './data/kml.ts';
32
36
  export { parseTopoJson, type TopoGeometry, type Topology } from './data/topojson.ts';
33
37
  export type { DecoderUrls } from './engine/decoders.ts';
34
38
  export { setRequestHeaders } from './engine/requests.ts';
35
- export { BATIMENTS_3D_URL, type BdTopoBuilding, batiments3d, bdtopoBuildings, type GeocodedPlace, geoplateformeGeocode, geoplateformeWfs, geoplateformeWms, geoplateformeWmts, IGN_ATTRIBUTION, IGN_PRESETS, type IgnPreset, lambert93Grid, } from './geoplateforme.ts';
39
+ export { BATIMENTS_3D_URL, type BdTopoBuilding, batiments3d, bdtopoBuildings, bdtopoRoofs, type GeocodedPlace, geoplateformeGeocode, geoplateformeWfs, geoplateformeWms, geoplateformeWmts, IGN_ATTRIBUTION, IGN_PRESETS, type IgnPreset, lambert93Grid, } from './geoplateforme.ts';
36
40
  export { type Grid, windAt, windFields } from './grids.ts';
37
41
  export type { ExtrusionOptions, ExtrusionStyle, PolygonArrays, TileKey } from './layers/extrusions.ts';
38
42
  export { ExtrusionLayer } from './layers/extrusions.ts';
@@ -45,19 +49,23 @@ export { DEFAULT_FONT, GLYPHS_URL } from './layers/glyphs.ts';
45
49
  export type { ImageOptions, Pixels, SpriteIcon } from './layers/icons.ts';
46
50
  export type { CustomFrame, CustomLayerInterface, GroundOptions, GroundTexture, ModelInstance, ModelOptions, } from './layers/layers.ts';
47
51
  export { CustomLayer, GroundLayer, Layer, ModelLayer, NetworkLayer, RasterLayer, Tiles3dLayer, } from './layers/layers.ts';
48
- export { type Panorama, type PanoramaOptions, Panoramas } from './layers/panoramas.ts';
52
+ export { type CalibratedPanoramaOptions, type Panorama, type PanoramaOptions, type PanoramaPhoto, Panoramas, type PhotoPanoramaOptions, } from './layers/panoramas.ts';
53
+ export { type PhotoOptions, photoModel } from './layers/photos.ts';
49
54
  export type { ClassStyle, PointCloudOptions, PointCloudStyle, PointColor } from './layers/pointclouds.ts';
50
55
  export { CLASSIFICATIONS, ELEVATION_RAMP, PointCloudLayer } from './layers/pointclouds.ts';
51
56
  export type { Overlap, SymbolOptions, SymbolStyle } from './layers/symbols.ts';
52
57
  export { SymbolLayer } from './layers/symbols.ts';
58
+ export { type TreeKind, type TreeOptions, treeKind } from './layers/trees.ts';
53
59
  export { type VectorFeature, VectorLayer, type VectorSublayer } from './layers/vectors.ts';
54
60
  export type { HoverPicking } from './map/hover-pick.ts';
55
61
  export { GeoMap, type LayerSpec } from './map.ts';
62
+ export { PANORAMAX_API, type PanoramaxPicture, panoramaxPanoramas, panoramaxPhoto, panoramaxPicture, panoramaxSequence, panoramaxStyle, } from './panoramax.ts';
56
63
  export type { AnimationOptions, AtmosphereOptions, Basemap, BasemapName, BodyOptions, CelestialBody, FeatureHit, FirstPersonView, FlyToOptions, GeoMapOptions, LoadingMode, LonLat, MapEvents, MapHoverFeatureEvent, MapPointerEvent, NetworkOptions, NetworkStyle, Point, Projection, RasterGrid, RasterOptions, RasterStyle, SunOptions, SwipeOptions, TerrainEncoding, TerrainModel, TerrainOptions, Tiles3dOptions, Tiles3dStyle, ViewshedOptions, } from './types.ts';
57
64
  export { AttributionControl, type AttributionOptions, type Control, type ControlPosition, NavigationControl, type NavigationOptions, } from './ui/controls.ts';
58
65
  export { MinimapControl, type MinimapOptions } from './ui/minimap.ts';
59
66
  export { type Anchor, Marker, type MarkerEvent, type MarkerEvents, type MarkerOptions, Panel, type PanelOptions, Popup, type PopupEvents, type PopupOptions, } from './ui/overlay.ts';
60
67
  export { lengthLabel, roundLength, ScaleControl, type ScaleOptions } from './ui/scale.ts';
61
68
  export { SearchControl, type SearchOptions } from './ui/search.ts';
69
+ export type { RoofMode } from './util/roofs.ts';
62
70
  export { sunPosition } from './util/sun.ts';
63
71
  export type { Camera, NetworkStats, PickHit, PickResult, PointCloudInfo, PointCloudPoint, PointCloudStats, RasterLayerStats, Tiles3dStats, } from './wasm/isard.js';
package/dist/index.js CHANGED
@@ -14,26 +14,31 @@
14
14
  export { OPENFREEMAP_ATTRIBUTION, TERRAIN_TILES_ATTRIBUTION } from "./basemap/basemaps.js";
15
15
  export { PMTiles, tileIdToZxy, zxyToTileId, } from "./basemap/pmtiles.js";
16
16
  export { basicStyle } from "./basemap/pmtileslayer.js";
17
- export { treeModel } from "./basemap/trees.js";
17
+ export { coniferModel, treeModel } from "./basemap/trees.js";
18
18
  export { OPENFREEMAP_STYLES, PLAN_STYLES, VectorTiles } from "./basemap/vectortiles.js";
19
19
  export { parseWmtsGrid, wmtsGrid } from "./basemap/wmts.js";
20
+ export { colladaImages, loadCollada, parseCollada } from "./data/collada.js";
20
21
  export { getCrs, lambertConformalConic, registerCrs, reproject, transverseMercator, } from "./data/crs.js";
21
22
  export { parseGpx } from "./data/gpx.js";
23
+ export { loadIfc, WEB_IFC, } from "./data/ifc.js";
22
24
  export { parseKml } from "./data/kml.js";
23
25
  export { parseTopoJson } from "./data/topojson.js";
24
26
  export { setRequestHeaders } from "./engine/requests.js";
25
- export { BATIMENTS_3D_URL, batiments3d, bdtopoBuildings, geoplateformeGeocode, geoplateformeWfs, geoplateformeWms, geoplateformeWmts, IGN_ATTRIBUTION, IGN_PRESETS, lambert93Grid, } from "./geoplateforme.js";
27
+ export { BATIMENTS_3D_URL, batiments3d, bdtopoBuildings, bdtopoRoofs, geoplateformeGeocode, geoplateformeWfs, geoplateformeWms, geoplateformeWmts, IGN_ATTRIBUTION, IGN_PRESETS, lambert93Grid, } from "./geoplateforme.js";
26
28
  export { windAt, windFields } from "./grids.js";
27
29
  export { ExtrusionLayer } from "./layers/extrusions.js";
28
30
  export { CircleLayer, FeatureLayer, FillLayer, interpolate, LineLayer, parseColor } from "./layers/features.js";
29
31
  export { FlowLayer, flowFieldFromImage, flowFieldsFromImage } from "./layers/flow.js";
30
32
  export { DEFAULT_FONT, GLYPHS_URL } from "./layers/glyphs.js";
31
33
  export { CustomLayer, GroundLayer, Layer, ModelLayer, NetworkLayer, RasterLayer, Tiles3dLayer, } from "./layers/layers.js";
32
- export { Panoramas } from "./layers/panoramas.js";
34
+ export { Panoramas, } from "./layers/panoramas.js";
35
+ export { photoModel } from "./layers/photos.js";
33
36
  export { CLASSIFICATIONS, ELEVATION_RAMP, PointCloudLayer } from "./layers/pointclouds.js";
34
37
  export { SymbolLayer } from "./layers/symbols.js";
38
+ export { treeKind } from "./layers/trees.js";
35
39
  export { VectorLayer } from "./layers/vectors.js";
36
40
  export { GeoMap } from "./map.js";
41
+ export { PANORAMAX_API, panoramaxPanoramas, panoramaxPhoto, panoramaxPicture, panoramaxSequence, panoramaxStyle, } from "./panoramax.js";
37
42
  export { AttributionControl, NavigationControl, } from "./ui/controls.js";
38
43
  export { MinimapControl } from "./ui/minimap.js";
39
44
  export { Marker, Panel, Popup, } from "./ui/overlay.js";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAE3F,OAAO,EACL,OAAO,EAIP,WAAW,EACX,WAAW,GACZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAuB,MAAM,2BAA2B,CAAC;AAC5E,OAAO,EAAmB,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAiBhE,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACxF,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAGL,MAAM,EACN,qBAAqB,EACrB,WAAW,EACX,SAAS,EACT,kBAAkB,GACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,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AACzB,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAqB,MAAM,eAAe,CAAC;AAC1F,OAAO,EAAE,aAAa,EAAsB,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC","sourcesContent":["/**\n * isard: a WebGL2 map engine for large, interactive data layers, labels and 3D Tiles.\n *\n * ```ts\n * import { GeoMap } from 'isard';\n * const map = await GeoMap.create(container, { center: [2.4246, 48.8457], zoom: 13 });\n * const network = map.addNetwork({ nodes, edges, max: 1800, contour: 300 });\n * map.on('hover', ({ lonLat }) => lonLat && network.setValues(travelTimes(lonLat)));\n * map.addTiles3d({ url: 'https://…/tileset.json' });\n * map.addControl(new NavigationControl());\n * new Marker().setLonLat([2.4246, 48.8457]).setPopup(new Popup({ offset: [0, -34] }).setText('Here')).addTo(map);\n * ```\n */\nexport { OPENFREEMAP_ATTRIBUTION, TERRAIN_TILES_ATTRIBUTION } from './basemap/basemaps.ts';\nexport type { TileGrid, TileMatrix } from './basemap/grid.ts';\nexport {\n PMTiles,\n type PmtilesEntry,\n type PmtilesHeader,\n type PmtilesTileType,\n tileIdToZxy,\n zxyToTileId,\n} from './basemap/pmtiles.ts';\nexport { basicStyle, type PmtilesOptions } from './basemap/pmtileslayer.ts';\nexport { type TreeColors, treeModel } from './basemap/trees.ts';\nexport type {\n CandidateIcon,\n CandidateOverlap,\n Json,\n LabelCandidate,\n RasterSource,\n Style,\n StyleLayer,\n} from './basemap/vectorstyle.ts';\nexport type { VectorExtrusionOptions } from './basemap/vectortiles/extrusions.ts';\nexport type { LabelsOptions } from './basemap/vectortiles/labels.ts';\nexport type { StreetWindLayer, StreetWindOptions } from './basemap/vectortiles/street-wind.ts';\nexport type { LoadedStyle } from './basemap/vectortiles/style.ts';\nexport type { TreesOptions } from './basemap/vectortiles/trees.ts';\nexport type { VectorsOptions } from './basemap/vectortiles/vectors.ts';\nexport type { VectorTilesOptions } from './basemap/vectortiles.ts';\nexport { OPENFREEMAP_STYLES, PLAN_STYLES, VectorTiles } from './basemap/vectortiles.ts';\nexport { parseWmtsGrid, wmtsGrid } from './basemap/wmts.ts';\nexport {\n type Crs,\n type CrsLike,\n getCrs,\n lambertConformalConic,\n registerCrs,\n reproject,\n transverseMercator,\n} from './data/crs.ts';\nexport { parseGpx } from './data/gpx.ts';\nexport { parseKml } from './data/kml.ts';\nexport { parseTopoJson, type TopoGeometry, type Topology } from './data/topojson.ts';\nexport type { DecoderUrls } from './engine/decoders.ts';\nexport { setRequestHeaders } from './engine/requests.ts';\nexport {\n BATIMENTS_3D_URL,\n type BdTopoBuilding,\n batiments3d,\n bdtopoBuildings,\n type GeocodedPlace,\n geoplateformeGeocode,\n geoplateformeWfs,\n geoplateformeWms,\n geoplateformeWmts,\n IGN_ATTRIBUTION,\n IGN_PRESETS,\n type IgnPreset,\n lambert93Grid,\n} from './geoplateforme.ts';\nexport { type Grid, windAt, windFields } from './grids.ts';\nexport type { ExtrusionOptions, ExtrusionStyle, PolygonArrays, TileKey } from './layers/extrusions.ts';\nexport { ExtrusionLayer } from './layers/extrusions.ts';\nexport type {\n CircleOptions,\n CircleStyle,\n Feature,\n FeatureCollection,\n FeatureData,\n FeatureLayerStyle,\n FillOptions,\n FillStyle,\n Geometry,\n LineOptions,\n LineStyle,\n Placement,\n Position,\n Properties,\n Ramp,\n Size,\n Stops,\n Styled,\n} from './layers/features.ts';\nexport { CircleLayer, FeatureLayer, FillLayer, interpolate, LineLayer, parseColor } from './layers/features.ts';\nexport type { FlowField, FlowOptions, FlowStyle, TimedField } from './layers/flow.ts';\nexport { FlowLayer, flowFieldFromImage, flowFieldsFromImage } from './layers/flow.ts';\nexport type { TextPart } from './layers/glyphs.ts';\nexport { DEFAULT_FONT, GLYPHS_URL } from './layers/glyphs.ts';\nexport type { ImageOptions, Pixels, SpriteIcon } from './layers/icons.ts';\nexport type {\n CustomFrame,\n CustomLayerInterface,\n GroundOptions,\n GroundTexture,\n ModelInstance,\n ModelOptions,\n} from './layers/layers.ts';\nexport {\n CustomLayer,\n GroundLayer,\n Layer,\n ModelLayer,\n NetworkLayer,\n RasterLayer,\n Tiles3dLayer,\n} from './layers/layers.ts';\nexport { type Panorama, type PanoramaOptions, Panoramas } from './layers/panoramas.ts';\nexport type { ClassStyle, PointCloudOptions, PointCloudStyle, PointColor } from './layers/pointclouds.ts';\nexport { CLASSIFICATIONS, ELEVATION_RAMP, PointCloudLayer } from './layers/pointclouds.ts';\nexport type { Overlap, SymbolOptions, SymbolStyle } from './layers/symbols.ts';\nexport { SymbolLayer } from './layers/symbols.ts';\nexport { type VectorFeature, VectorLayer, type VectorSublayer } from './layers/vectors.ts';\nexport type { HoverPicking } from './map/hover-pick.ts';\nexport { GeoMap, type LayerSpec } from './map.ts';\nexport type {\n AnimationOptions,\n AtmosphereOptions,\n Basemap,\n BasemapName,\n BodyOptions,\n CelestialBody,\n FeatureHit,\n FirstPersonView,\n FlyToOptions,\n GeoMapOptions,\n LoadingMode,\n LonLat,\n MapEvents,\n MapHoverFeatureEvent,\n MapPointerEvent,\n NetworkOptions,\n NetworkStyle,\n Point,\n Projection,\n RasterGrid,\n RasterOptions,\n RasterStyle,\n SunOptions,\n SwipeOptions,\n TerrainEncoding,\n TerrainModel,\n TerrainOptions,\n Tiles3dOptions,\n Tiles3dStyle,\n ViewshedOptions,\n} from './types.ts';\nexport {\n AttributionControl,\n type AttributionOptions,\n type Control,\n type ControlPosition,\n NavigationControl,\n type NavigationOptions,\n} from './ui/controls.ts';\nexport { MinimapControl, type MinimapOptions } from './ui/minimap.ts';\nexport {\n type Anchor,\n Marker,\n type MarkerEvent,\n type MarkerEvents,\n type MarkerOptions,\n Panel,\n type PanelOptions,\n Popup,\n type PopupEvents,\n type PopupOptions,\n} from './ui/overlay.ts';\nexport { lengthLabel, roundLength, ScaleControl, type ScaleOptions } from './ui/scale.ts';\nexport { SearchControl, type SearchOptions } from './ui/search.ts';\nexport { sunPosition } from './util/sun.ts';\nexport type {\n Camera,\n NetworkStats,\n PickHit,\n PickResult,\n PointCloudInfo,\n PointCloudPoint,\n PointCloudStats,\n RasterLayerStats,\n Tiles3dStats,\n} from './wasm/isard.js';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAE3F,OAAO,EACL,OAAO,EAIP,WAAW,EACX,WAAW,GACZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAuB,MAAM,2BAA2B,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAmB,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAmB9E,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACxF,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAsB,aAAa,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjG,OAAO,EAGL,MAAM,EACN,qBAAqB,EACrB,WAAW,EACX,SAAS,EACT,kBAAkB,GACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAOL,OAAO,EACP,OAAO,GACR,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,aAAa,EAAoC,MAAM,oBAAoB,CAAC;AAErF,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EACL,gBAAgB,EAEhB,WAAW,EACX,eAAe,EACf,WAAW,EAEX,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,WAAW,EAEX,aAAa,GACd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,E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M,eAAe,CAAC;AAC1F,OAAO,EAAE,aAAa,EAAsB,MAAM,gBAAgB,CAAC;AAEnE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC","sourcesContent":["/**\n * isard: a WebGL2 map engine for large, interactive data layers, labels and 3D Tiles.\n *\n * ```ts\n * import { GeoMap } from 'isard';\n * const map = await GeoMap.create(container, { center: [2.4246, 48.8457], zoom: 13 });\n * const network = map.addNetwork({ nodes, edges, max: 1800, contour: 300 });\n * map.on('hover', ({ lonLat }) => lonLat && network.setValues(travelTimes(lonLat)));\n * map.addTiles3d({ url: 'https://…/tileset.json' });\n * map.addControl(new NavigationControl());\n * new Marker().setLonLat([2.4246, 48.8457]).setPopup(new Popup({ offset: [0, -34] }).setText('Here')).addTo(map);\n * ```\n */\nexport { OPENFREEMAP_ATTRIBUTION, TERRAIN_TILES_ATTRIBUTION } from './basemap/basemaps.ts';\nexport type { TileGrid, TileMatrix } from './basemap/grid.ts';\nexport {\n PMTiles,\n type PmtilesEntry,\n type PmtilesHeader,\n type PmtilesTileType,\n tileIdToZxy,\n zxyToTileId,\n} from './basemap/pmtiles.ts';\nexport { basicStyle, type PmtilesOptions } from './basemap/pmtileslayer.ts';\nexport { coniferModel, type TreeColors, treeModel } from './basemap/trees.ts';\nexport type {\n CandidateIcon,\n CandidateOverlap,\n Json,\n LabelCandidate,\n RasterSource,\n Style,\n StyleLayer,\n} from './basemap/vectorstyle.ts';\nexport type { VectorExtrusionOptions } from './basemap/vectortiles/extrusions.ts';\nexport type { FurnitureOptions } from './basemap/vectortiles/furniture.ts';\nexport type { LabelsOptions } from './basemap/vectortiles/labels.ts';\nexport type { LampsOptions } from './basemap/vectortiles/lamps.ts';\nexport type { StreetWindLayer, StreetWindOptions } from './basemap/vectortiles/street-wind.ts';\nexport type { LoadedStyle } from './basemap/vectortiles/style.ts';\nexport type { TreesOptions } from './basemap/vectortiles/trees.ts';\nexport type { VectorsOptions } from './basemap/vectortiles/vectors.ts';\nexport type { VectorTilesOptions } from './basemap/vectortiles.ts';\nexport { OPENFREEMAP_STYLES, PLAN_STYLES, VectorTiles } from './basemap/vectortiles.ts';\nexport { parseWmtsGrid, wmtsGrid } from './basemap/wmts.ts';\nexport { type ColladaImages, colladaImages, loadCollada, parseCollada } from './data/collada.ts';\nexport {\n type Crs,\n type CrsLike,\n getCrs,\n lambertConformalConic,\n registerCrs,\n reproject,\n transverseMercator,\n} from './data/crs.ts';\nexport { parseGpx } from './data/gpx.ts';\nexport {\n type IfcElement,\n type IfcModel,\n type IfcOptions,\n type IfcPlace,\n type IfcProperties,\n type IfcStorey,\n loadIfc,\n WEB_IFC,\n} from './data/ifc.ts';\nexport { parseKml } from './data/kml.ts';\nexport { parseTopoJson, type TopoGeometry, type Topology } from './data/topojson.ts';\nexport type { DecoderUrls } from './engine/decoders.ts';\nexport { setRequestHeaders } from './engine/requests.ts';\nexport {\n BATIMENTS_3D_URL,\n type BdTopoBuilding,\n batiments3d,\n bdtopoBuildings,\n bdtopoRoofs,\n type GeocodedPlace,\n geoplateformeGeocode,\n geoplateformeWfs,\n geoplateformeWms,\n geoplateformeWmts,\n IGN_ATTRIBUTION,\n IGN_PRESETS,\n type IgnPreset,\n lambert93Grid,\n} from './geoplateforme.ts';\nexport { type Grid, windAt, windFields } from './grids.ts';\nexport type { ExtrusionOptions, ExtrusionStyle, PolygonArrays, TileKey } from './layers/extrusions.ts';\nexport { ExtrusionLayer } from './layers/extrusions.ts';\nexport type {\n CircleOptions,\n CircleStyle,\n Feature,\n FeatureCollection,\n FeatureData,\n FeatureLayerStyle,\n FillOptions,\n FillStyle,\n Geometry,\n LineOptions,\n LineStyle,\n Placement,\n Position,\n Properties,\n Ramp,\n Size,\n Stops,\n Styled,\n} from './layers/features.ts';\nexport { CircleLayer, FeatureLayer, FillLayer, interpolate, LineLayer, parseColor } from './layers/features.ts';\nexport type { FlowField, FlowOptions, FlowStyle, TimedField } from './layers/flow.ts';\nexport { FlowLayer, flowFieldFromImage, flowFieldsFromImage } from './layers/flow.ts';\nexport type { TextPart } from './layers/glyphs.ts';\nexport { DEFAULT_FONT, GLYPHS_URL } from './layers/glyphs.ts';\nexport type { ImageOptions, Pixels, SpriteIcon } from './layers/icons.ts';\nexport type {\n CustomFrame,\n CustomLayerInterface,\n GroundOptions,\n GroundTexture,\n ModelInstance,\n ModelOptions,\n} from './layers/layers.ts';\nexport {\n CustomLayer,\n GroundLayer,\n Layer,\n ModelLayer,\n NetworkLayer,\n RasterLayer,\n Tiles3dLayer,\n} from './layers/layers.ts';\nexport {\n type CalibratedPanoramaOptions,\n type Panorama,\n type PanoramaOptions,\n type PanoramaPhoto,\n Panoramas,\n type PhotoPanoramaOptions,\n} from './layers/panoramas.ts';\nexport { type PhotoOptions, photoModel } from './layers/photos.ts';\nexport type { ClassStyle, PointCloudOptions, PointCloudStyle, PointColor } from './layers/pointclouds.ts';\nexport { CLASSIFICATIONS, ELEVATION_RAMP, PointCloudLayer } from './layers/pointclouds.ts';\nexport type { Overlap, SymbolOptions, SymbolStyle } from './layers/symbols.ts';\nexport { SymbolLayer } from './layers/symbols.ts';\nexport { type TreeKind, type TreeOptions, treeKind } from './layers/trees.ts';\nexport { type VectorFeature, VectorLayer, type VectorSublayer } from './layers/vectors.ts';\nexport type { HoverPicking } from './map/hover-pick.ts';\nexport { GeoMap, type LayerSpec } from './map.ts';\nexport {\n PANORAMAX_API,\n type PanoramaxPicture,\n panoramaxPanoramas,\n panoramaxPhoto,\n panoramaxPicture,\n panoramaxSequence,\n panoramaxStyle,\n} from './panoramax.ts';\nexport type {\n AnimationOptions,\n AtmosphereOptions,\n Basemap,\n BasemapName,\n BodyOptions,\n CelestialBody,\n FeatureHit,\n FirstPersonView,\n FlyToOptions,\n GeoMapOptions,\n LoadingMode,\n LonLat,\n MapEvents,\n MapHoverFeatureEvent,\n MapPointerEvent,\n NetworkOptions,\n NetworkStyle,\n Point,\n Projection,\n RasterGrid,\n RasterOptions,\n RasterStyle,\n SunOptions,\n SwipeOptions,\n TerrainEncoding,\n TerrainModel,\n TerrainOptions,\n Tiles3dOptions,\n Tiles3dStyle,\n ViewshedOptions,\n} from './types.ts';\nexport {\n AttributionControl,\n type AttributionOptions,\n type Control,\n type ControlPosition,\n NavigationControl,\n type NavigationOptions,\n} from './ui/controls.ts';\nexport { MinimapControl, type MinimapOptions } from './ui/minimap.ts';\nexport {\n type Anchor,\n Marker,\n type MarkerEvent,\n type MarkerEvents,\n type MarkerOptions,\n Panel,\n type PanelOptions,\n Popup,\n type PopupEvents,\n type PopupOptions,\n} from './ui/overlay.ts';\nexport { lengthLabel, roundLength, ScaleControl, type ScaleOptions } from './ui/scale.ts';\nexport { SearchControl, type SearchOptions } from './ui/search.ts';\nexport type { RoofMode } from './util/roofs.ts';\nexport { sunPosition } from './util/sun.ts';\nexport type {\n Camera,\n NetworkStats,\n PickHit,\n PickResult,\n PointCloudInfo,\n PointCloudPoint,\n PointCloudStats,\n RasterLayerStats,\n Tiles3dStats,\n} from './wasm/isard.js';\n"]}
Binary file
Binary file
Binary file
Binary file
@@ -13,6 +13,14 @@ export interface ExtrusionStyle<P = Properties> extends FeatureLayerStyle<P> {
13
13
  height: Styled<number, P>;
14
14
  /** Height of the foot of the walls, metres (default 0) */
15
15
  base: Styled<number, P>;
16
+ /** Its roof's shape (default `flat`): one of OpenStreetMap's `roof:shape` (hipped, gabled, pyramidal, mansard; the
17
+ * others drawn as the nearest of them), or `generated` from its outline (hipped or gabled under 450 m², a mansard
18
+ * under 3000 m², flat past that). Fitted into the building's height, at most half of it */
19
+ roof: Styled<string, P>;
20
+ /** Its roof's height over the walls' top, metres (default: as its slopes make it) */
21
+ roofHeight: Styled<number, P>;
22
+ /** The walls show their windows: glass by day, some lit at night (default false: only the lit ones) */
23
+ facades: boolean;
16
24
  }
17
25
  export interface ExtrusionOptions<P = Properties> extends Partial<ExtrusionStyle<P>>, Placement {
18
26
  /** Polygon and MultiPolygon features, as one set (tiles come with `setTile`) */
@@ -72,6 +80,8 @@ export declare class ExtrusionLayer<P = Properties> extends Layer {
72
80
  private put;
73
81
  private mask;
74
82
  private sendTile;
83
+ /** Each polygon's roof (`roofNumber`: none if all flat) and height, from its feature's style */
84
+ private roofs;
75
85
  private sendStyle;
76
86
  private sendLayer;
77
87
  private sendLink;
@@ -4,7 +4,9 @@
4
4
  * with `removeTile`. Colored by their color, by a value per building through the ramp (water at a building), or by
5
5
  * the node values of a network layer (`linkNetwork`: the travel time to each building, recolored with the network).
6
6
  */
7
- import { evaluate, FLOATS, featuresOf, parseColor, polygonGeometry, rampTexels, stops, } from "./features.js";
7
+ import { metresAt, roofNumber } from "../util/roofs.js";
8
+ import { FLOATS, STYLE } from "../util/style-floats.js";
9
+ import { evaluate, featuresOf, parseColor, polygonGeometry, rampTexels, stops, } from "./features.js";
8
10
  import { Layer } from "./layers.js";
9
11
  /** TileKey of the set given as `data` */
10
12
  const DATA = Symbol('data');
@@ -89,8 +91,13 @@ export class ExtrusionLayer extends Layer {
89
91
  setStyle(style) {
90
92
  this.style = { ...this.style, ...style };
91
93
  const engine = this.map.engine;
94
+ // The roofs are geometry: the blocks built again
95
+ const reshaped = style.roof !== undefined || style.roofHeight !== undefined;
92
96
  this.tiles.forEach((tile) => {
93
- this.sendStyle(engine, this.id, tile);
97
+ if (reshaped)
98
+ this.sendTile(engine, this.id, tile);
99
+ else
100
+ this.sendStyle(engine, this.id, tile);
94
101
  });
95
102
  this.sendLayer(engine, this.id);
96
103
  this.map.requestRender();
@@ -160,13 +167,29 @@ export class ExtrusionLayer extends Layer {
160
167
  sendTile(engine, id, tile) {
161
168
  const g = tile.arrays ?? polygonGeometry(tile.features ?? []);
162
169
  const n = tile.properties.length;
163
- engine.setExtrusionBatch(id, tile.batch, g.points, g.ringStart, g.polygonStart, g.feature, n);
170
+ const { roofs, heights } = this.roofs(tile, g.feature);
171
+ // The metres per Mercator unit at the middle of the batch (a batch spanning a country errs by a few hundredths)
172
+ const [north, south] = g.points.reduce(([lo, hi], v, i) => (i % 2 === 1 ? [Math.min(lo, v), Math.max(hi, v)] : [lo, hi]), [1, 0]);
173
+ const metres = north <= south ? metresAt((north + south) / 2) : 0;
174
+ engine.setExtrusionBatch(id, tile.batch, g.points, g.ringStart, g.polygonStart, g.feature, n, roofs, heights, metres);
164
175
  this.sendStyle(engine, id, tile);
165
176
  if (tile.values)
166
177
  engine.setFeatureValues(id, tile.values, tile.batch);
167
178
  if (tile.anchors)
168
179
  engine.setExtrusionAnchors(id, tile.batch, tile.anchors);
169
180
  }
181
+ /** Each polygon's roof (`roofNumber`: none if all flat) and height, from its feature's style */
182
+ roofs(tile, feature) {
183
+ const { roof, roofHeight } = this.style;
184
+ if (roof === 'flat')
185
+ return { roofs: new Uint8Array(), heights: new Float32Array() };
186
+ const shapes = tile.properties.map((p, i) => roofNumber(evaluate(roof, p, i)) ?? 0);
187
+ const heights = tile.properties.map((p, i) => evaluate(roofHeight, p, i));
188
+ return {
189
+ roofs: Uint8Array.from(feature, (f) => shapes[f] ?? 0),
190
+ heights: Float32Array.from(feature, (f) => heights[f] ?? Number.NaN),
191
+ };
192
+ }
170
193
  sendStyle(engine, id, tile) {
171
194
  const { color, height, base } = this.style;
172
195
  const out = new Float32Array(tile.properties.length * FLOATS);
@@ -174,9 +197,9 @@ export class ExtrusionLayer extends Layer {
174
197
  const fixed = typeof color === 'string' ? parseColor(color) : undefined;
175
198
  tile.properties.forEach((p, i) => {
176
199
  const o = i * FLOATS;
177
- out.set(fixed ?? parseColor(evaluate(color, p, i)), o);
178
- out.set(stops(evaluate(height, p, i)), o + 8);
179
- out.set(stops(evaluate(base, p, i)), o + 16);
200
+ out.set(fixed ?? parseColor(evaluate(color, p, i)), o + STYLE.color);
201
+ out.set(stops(evaluate(height, p, i)), o + STYLE.size);
202
+ out.set(stops(evaluate(base, p, i)), o + STYLE.size2);
180
203
  });
181
204
  engine.setFeatureStyle(id, out, tile.batch);
182
205
  engine.setFeatureMask(id, this.mask(tile), tile.batch);
@@ -186,6 +209,7 @@ export class ExtrusionLayer extends Layer {
186
209
  const r = ramp && rampTexels(ramp);
187
210
  engine.setFeatureRamp(id, r?.rgba, r?.min ?? 0, r?.max ?? 1);
188
211
  engine.setFeatureLayer(id, Float32Array.from(stops(opacity)), minZoom, maxZoom, visible);
212
+ engine.setFacades(id, this.style.facades);
189
213
  }
190
214
  sendLink(engine, id) {
191
215
  const n = this.network;
@@ -223,6 +247,9 @@ export const extrusionStyle = (options) => {
223
247
  color: '#e4e1dc',
224
248
  height: 6,
225
249
  base: 0,
250
+ roof: 'flat',
251
+ roofHeight: Number.NaN,
252
+ facades: false,
226
253
  ...rest,
227
254
  };
228
255
  };
@@ -1 +1 @@
1
- {"version":3,"file":"extrusions.js","sourceRoot":"","sources":["../../src/layers/extrusions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EACL,QAAQ,EAIR,MAAM,EACN,UAAU,EAGV,UAAU,EACV,eAAe,EACf,UAAU,EAEV,KAAK,GACN,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,KAAK,EAAqB,MAAM,aAAa,CAAC;AA0CvD,yCAAyC;AACzC,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;AAE5B,MAAM,OAAO,cAA+B,SAAQ,KAAK;IAS7C;IARO,KAAK,GAAG,IAAI,GAAG,EAAkC,CAAC;IAC3D,SAAS,GAAG,CAAC,CAAC;IACd,OAAO,CAAmD;IAElE,gBAAgB;IAChB,YACE,GAAc,EACd,IAAgC,EACxB,KAAwB;QAEhC,KAAK,CAAC,GAAG,CAAC,CAAC;QAFH,UAAK,GAAL,KAAK,CAAmB;QAGhC,IAAI,IAAI,EAAE,CAAC;YACT,MAAM,QAAQ,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;YAClC,MAAM,UAAU,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;YAErD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI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,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IAEjD,OAAO;QACL,OAAO,EAAE,CAAC;QACV,OAAO,EAAE,CAAC;QACV,OAAO,EAAE,EAAE;QACX,OAAO,EAAE,IAAI;QACb,MAAM,EAAE,SAAS;QACjB,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,SAAS;QAChB,MAAM,EAAE,CAAC;QACT,IAAI,EAAE,CAAC;QACP,GAAG,IAAI;KACR,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/**\n * Extruded polygons (buildings), styled per feature like the other feature layers, coming in tiles (or one set): an\n * application loading a tiled source (BD TOPO vector tiles…) hands each tile's buildings to `setTile` and drops them\n * with `removeTile`. Colored by their color, by a value per building through the ramp (water at a building), or by\n * the node values of a network layer (`linkNetwork`: the travel time to each building, recolored with the network).\n */\n\nimport type { LayerHost } from '../types.ts';\nimport type { Engine } from '../wasm/isard.js';\nimport {\n evaluate,\n type Feature,\n type FeatureData,\n type FeatureLayerStyle,\n FLOATS,\n featuresOf,\n type Placement,\n type Properties,\n parseColor,\n polygonGeometry,\n rampTexels,\n type Styled,\n stops,\n} from './features.ts';\nimport { Layer, type NetworkLayer } from './layers.ts';\n\nexport interface ExtrusionStyle<P = Properties> extends FeatureLayerStyle<P> {\n /** CSS color (default `#e4e1dc`) */\n color: Styled<string, P>;\n /** Height of the roof over the ground, metres (default 6) */\n height: Styled<number, P>;\n /** Height of the foot of the walls, metres (default 0) */\n base: Styled<number, P>;\n}\n\nexport interface ExtrusionOptions<P = Properties> extends Partial<ExtrusionStyle<P>>, Placement {\n /** Polygon and MultiPolygon features, as one set (tiles come with `setTile`) */\n data?: FeatureData<P>;\n}\n\n/** Key of a tile of extrusions (see `ExtrusionLayer.setTile`) */\nexport type TileKey = string | number;\n\n/**\n * Polygons as typed arrays, for tiles decoded in a worker (no GeoJSON in between): points in Mercator [0, 1] (x, y\n * interleaved, y towards the south), the first point of each ring and the first ring of each polygon (one more entry\n * than rings and polygons; the first ring of a polygon is its outline), the feature of each polygon\n */\nexport interface PolygonArrays {\n points: Float64Array;\n ringStart: Uint32Array;\n polygonStart: Uint32Array;\n feature: Uint32Array;\n}\n\ninterface Tile<P> {\n /** Batch number in the engine: tiles are drawn, and their features numbered for picking, in this order */\n batch: number;\n /** The properties of the features, which the style reads */\n properties: P[];\n features: Feature<P>[] | undefined;\n arrays: PolygonArrays | undefined;\n values: Float32Array | undefined;\n anchors: Float32Array | undefined;\n}\n\n/** TileKey of the set given as `data` */\nconst DATA = Symbol('data');\n\nexport class ExtrusionLayer<P = Properties> extends Layer {\n private readonly tiles = new Map<TileKey | typeof DATA, Tile<P>>();\n private nextBatch = 1;\n private network: { layer: NetworkLayer; max: number } | undefined;\n\n /** @internal */\n constructor(\n map: LayerHost,\n data: FeatureData<P> | undefined,\n private style: ExtrusionStyle<P>,\n ) {\n super(map);\n if (data) {\n const features = featuresOf(data);\n const properties = features.map((f) => f.properties);\n\n this.tiles.set(DATA, {\n batch: 0,\n properties,\n features,\n arrays: undefined,\n values: undefined,\n anchors: undefined,\n });\n }\n }\n\n /** Replaces the set given as `data` */\n setData(data: FeatureData<P>): void {\n const features = featuresOf(data);\n\n this.put(\n DATA,\n features.map((f) => f.properties),\n features,\n undefined,\n );\n }\n\n /** Adds or replaces the buildings of a tile: GeoJSON, or typed arrays with the properties of each feature */\n setTile(key: TileKey, data: FeatureData<P> | { arrays: PolygonArrays; properties: P[] }): void {\n if ('arrays' in data) this.put(key, data.properties, undefined, data.arrays);\n else {\n const features = featuresOf(data);\n\n this.put(\n key,\n features.map((f) => f.properties),\n features,\n undefined,\n );\n }\n }\n\n removeTile(key: TileKey): void {\n const tile = this.tiles.get(key);\n\n if (!tile) return;\n this.tiles.delete(key);\n this.map.engine.removeExtrusionBatch(this.id, tile.batch);\n this.map.requestRender();\n }\n\n /** Keys of the tiles held */\n get tileKeys(): TileKey[] {\n return [...this.tiles.keys()].filter((k): k is TileKey => k !== DATA);\n }\n\n /** The properties of the features of a tile (or of the data) */\n properties(key?: TileKey): readonly P[] {\n return this.tiles.get(key ?? DATA)?.properties ?? [];\n }\n\n /** The feature of a picked index (its geometry if given as GeoJSON): tiles are numbered one after the other, in the\n * order they were added */\n featureAt(index: number): Feature<P> | undefined {\n let rest = index;\n\n for (const tile of [...this.tiles.values()].sort((a, b) => a.batch - b.batch)) {\n const n = tile.properties.length;\n\n if (rest < n) {\n const properties = tile.properties[rest];\n\n if (properties === undefined) return undefined;\n\n return tile.features?.[rest] ?? { type: 'Feature', properties, geometry: null };\n }\n rest -= n;\n }\n\n return undefined;\n }\n\n /** The tile and the index in it of a picked index */\n tileAt(index: number): { key: TileKey | undefined; index: number } | undefined {\n let rest = index;\n\n for (const [key, tile] of [...this.tiles].sort((a, b) => a[1].batch - b[1].batch)) {\n if (rest < tile.properties.length) return { key: key === DATA ? undefined : key, index: rest };\n rest -= tile.properties.length;\n }\n\n return undefined;\n }\n\n setStyle(style: Partial<ExtrusionStyle<P>>): void {\n this.style = { ...this.style, ...style };\n\n const engine = this.map.engine;\n\n this.tiles.forEach((tile) => {\n this.sendStyle(engine, this.id, tile);\n });\n this.sendLayer(engine, this.id);\n this.map.requestRender();\n }\n\n setVisible(visible: boolean): void {\n this.setStyle({ visible });\n }\n\n setFilter(filter: ((properties: P, index: number) => boolean) | undefined): void {\n this.style = { ...this.style, filter };\n this.tiles.forEach((tile) => {\n this.map.engine.setFeatureMask(this.id, this.mask(tile), tile.batch);\n });\n this.map.requestRender();\n }\n\n /** One value per building of a tile (or of the data), colored through the ramp; NaN keeps a building's color */\n setValues(values: Float32Array | undefined, key?: TileKey): void {\n const tile = this.tiles.get(key ?? DATA);\n\n if (!tile) return;\n tile.values = values;\n this.map.engine.setFeatureValues(\n this.id,\n values ?? new Float32Array(tile.properties.length).fill(Number.NaN),\n tile.batch,\n );\n this.map.requestRender();\n }\n\n /**\n * Colors the buildings by the node values of a network layer, recolored with it: each building takes min(value(A)\n * + cost from A, value(B) + cost from B) from its anchors (`setAnchors`), through the ramp, up to `max` (above, or\n * unreached: its own color). Undefined: back to the buildings' own values.\n */\n linkNetwork(network: NetworkLayer | undefined, max = Number.POSITIVE_INFINITY): void {\n this.network = network && { layer: network, max };\n this.sendLink(this.map.engine, this.id);\n this.map.requestRender();\n }\n\n /** Per building of a tile (or of the data): node A, node B, cost from A, cost from B (4 floats each) */\n setAnchors(anchors: Float32Array, key?: TileKey): void {\n const tile = this.tiles.get(key ?? DATA);\n\n if (!tile) return;\n tile.anchors = anchors;\n this.map.engine.setExtrusionAnchors(this.id, tile.batch, anchors);\n this.map.requestRender();\n }\n\n private put(\n key: TileKey | typeof DATA,\n properties: P[],\n features: Feature<P>[] | undefined,\n arrays: PolygonArrays | undefined,\n ): void {\n const old = this.tiles.get(key);\n const tile: Tile<P> = {\n batch: old?.batch ?? (key === DATA ? 0 : this.nextBatch++),\n properties,\n features,\n arrays,\n values: undefined,\n anchors: undefined,\n };\n\n this.tiles.set(key, tile);\n this.sendTile(this.map.engine, this.id, tile);\n this.map.requestRender();\n }\n\n private mask(tile: Tile<P>): Uint8Array {\n const { filter } = this.style;\n const mask = new Uint8Array(tile.properties.length).fill(255);\n\n if (filter)\n tile.properties.forEach((p, i) => {\n if (!filter(p, i)) mask[i] = 0;\n });\n\n return mask;\n }\n\n private sendTile(engine: Engine, id: number, tile: Tile<P>): void {\n const g = tile.arrays ?? polygonGeometry(tile.features ?? []);\n const n = tile.properties.length;\n\n engine.setExtrusionBatch(id, tile.batch, g.points, g.ringStart, g.polygonStart, g.feature, n);\n this.sendStyle(engine, id, tile);\n if (tile.values) engine.setFeatureValues(id, tile.values, tile.batch);\n if (tile.anchors) engine.setExtrusionAnchors(id, tile.batch, tile.anchors);\n }\n\n private sendStyle(engine: Engine, id: number, tile: Tile<P>): void {\n const { color, height, base } = this.style;\n const out = new Float32Array(tile.properties.length * FLOATS);\n // Constant colors parsed once: a tile has thousands of buildings\n const fixed = typeof color === 'string' ? parseColor(color) : undefined;\n\n tile.properties.forEach((p, i) => {\n const o = i * FLOATS;\n\n out.set(fixed ?? parseColor(evaluate(color, p, i)), o);\n out.set(stops(evaluate(height, p, i)), o + 8);\n out.set(stops(evaluate(base, p, i)), o + 16);\n });\n engine.setFeatureStyle(id, out, tile.batch);\n engine.setFeatureMask(id, this.mask(tile), tile.batch);\n }\n\n private sendLayer(engine: Engine, id: number): void {\n const { ramp, opacity, minZoom, maxZoom, visible } = this.style;\n const r = ramp && rampTexels(ramp);\n\n engine.setFeatureRamp(id, r?.rgba, r?.min ?? 0, r?.max ?? 1);\n engine.setFeatureLayer(id, Float32Array.from(stops(opacity)), minZoom, maxZoom, visible);\n }\n\n private sendLink(engine: Engine, id: number): void {\n const n = this.network;\n // A network removed (or not created) links to nothing\n const network = n && n.layer.id >= 0 ? n.layer.id : undefined;\n\n engine.linkExtrusionNetwork(id, network, n ? Math.min(n.max, 1e29) : 0);\n }\n\n /** @internal */\n protected create(engine: Engine): number {\n const id = engine.addExtrusions();\n\n this.sendLayer(engine, id);\n this.tiles.forEach((tile) => {\n this.sendTile(engine, id, tile);\n });\n // A network created before (on a new engine, the map relinks once every layer is there)\n if (!this.network || this.network.layer.id >= 0) this.sendLink(engine, id);\n\n return id;\n }\n\n /** @internal On a new engine, the network may come after the buildings: linked once both are there */\n override relink(engine: Engine): void {\n if (this.network) this.sendLink(engine, this.id);\n }\n}\n\nexport const extrusionStyle = <P>(options: ExtrusionOptions<P>): ExtrusionStyle<P> => {\n const { data: _, before: __, ...rest } = options;\n\n return {\n opacity: 1,\n minZoom: 0,\n maxZoom: 24,\n visible: true,\n filter: undefined,\n ramp: undefined,\n color: '#e4e1dc',\n height: 6,\n base: 0,\n ...rest,\n };\n};\n"]}
1
+ {"version":3,"file":"extrusions.js","sourceRoot":"","sources":["../../src/layers/extrusions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,M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AAE,IAAI,CAAC;YAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAE3E,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,sGAAsG;IAC7F,MAAM,CAAC,MAAc;QAC5B,IAAI,IAAI,CAAC,OAAO;YAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IACnD,CAAC;CACF;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,CAAI,OAA4B,EAAqB,EAAE;IACnF,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IAEjD,OAAO;QACL,OAAO,EAAE,CAAC;QACV,OAAO,EAAE,CAAC;QACV,OAAO,EAAE,EAAE;QACX,OAAO,EAAE,IAAI;QACb,MAAM,EAAE,SAAS;QACjB,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,SAAS;QAChB,MAAM,EAAE,CAAC;QACT,IAAI,EAAE,CAAC;QACP,IAAI,EAAE,MAAM;QACZ,UAAU,EAAE,MAAM,CAAC,GAAG;QACtB,OAAO,EAAE,KAAK;QACd,GAAG,IAAI;KACR,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/**\n * Extruded polygons (buildings), styled per feature like the other feature layers, coming in tiles (or one set): an\n * application loading a tiled source (BD TOPO vector tiles…) hands each tile's buildings to `setTile` and drops them\n * with `removeTile`. Colored by their color, by a value per building through the ramp (water at a building), or by\n * the node values of a network layer (`linkNetwork`: the travel time to each building, recolored with the network).\n */\n\nimport type { LayerHost } from '../types.ts';\nimport { metresAt, roofNumber } from '../util/roofs.ts';\nimport { FLOATS, STYLE } from '../util/style-floats.ts';\nimport type { Engine } from '../wasm/isard.js';\nimport {\n evaluate,\n type Feature,\n type FeatureData,\n type FeatureLayerStyle,\n featuresOf,\n type Placement,\n type Properties,\n parseColor,\n polygonGeometry,\n rampTexels,\n type Styled,\n stops,\n} from './features.ts';\nimport { Layer, type NetworkLayer } from './layers.ts';\n\nexport interface ExtrusionStyle<P = Properties> extends FeatureLayerStyle<P> {\n /** CSS color (default `#e4e1dc`) */\n color: Styled<string, P>;\n /** Height of the roof over the ground, metres (default 6) */\n height: Styled<number, P>;\n /** Height of the foot of the walls, metres (default 0) */\n base: Styled<number, P>;\n /** Its roof's shape (default `flat`): one of OpenStreetMap's `roof:shape` (hipped, gabled, pyramidal, mansard; the\n * others drawn as the nearest of them), or `generated` from its outline (hipped or gabled under 450 m², a mansard\n * under 3000 m², flat past that). Fitted into the building's height, at most half of it */\n roof: Styled<string, P>;\n /** Its roof's height over the walls' top, metres (default: as its slopes make it) */\n roofHeight: Styled<number, P>;\n /** The walls show their windows: glass by day, some lit at night (default false: only the lit ones) */\n facades: boolean;\n}\n\nexport interface ExtrusionOptions<P = Properties> extends Partial<ExtrusionStyle<P>>, Placement {\n /** Polygon and MultiPolygon features, as one set (tiles come with `setTile`) */\n data?: FeatureData<P>;\n}\n\n/** Key of a tile of extrusions (see `ExtrusionLayer.setTile`) */\nexport type TileKey = string | number;\n\n/**\n * Polygons as typed arrays, for tiles decoded in a worker (no GeoJSON in between): points in Mercator [0, 1] (x, y\n * interleaved, y towards the south), the first point of each ring and the first ring of each polygon (one more entry\n * than rings and polygons; the first ring of a polygon is its outline), the feature of each polygon\n */\nexport interface PolygonArrays {\n points: Float64Array;\n ringStart: Uint32Array;\n polygonStart: Uint32Array;\n feature: Uint32Array;\n}\n\ninterface Tile<P> {\n /** Batch number in the engine: tiles are drawn, and their features numbered for picking, in this order */\n batch: number;\n /** The properties of the features, which the style reads */\n properties: P[];\n features: Feature<P>[] | undefined;\n arrays: PolygonArrays | undefined;\n values: Float32Array | undefined;\n anchors: Float32Array | undefined;\n}\n\n/** TileKey of the set given as `data` */\nconst DATA = Symbol('data');\n\nexport class ExtrusionLayer<P = Properties> extends Layer {\n private readonly tiles = new Map<TileKey | typeof DATA, Tile<P>>();\n private nextBatch = 1;\n private network: { layer: NetworkLayer; max: number } | undefined;\n\n /** @internal */\n constructor(\n map: LayerHost,\n data: FeatureData<P> | undefined,\n private style: ExtrusionStyle<P>,\n ) {\n super(map);\n if (data) {\n const features = featuresOf(data);\n const properties = features.map((f) => f.properties);\n\n this.tiles.set(DATA, {\n batch: 0,\n properties,\n features,\n arrays: undefined,\n values: undefined,\n anchors: undefined,\n });\n }\n }\n\n /** Replaces the set given as `data` */\n setData(data: FeatureData<P>): void {\n const features = featuresOf(data);\n\n this.put(\n DATA,\n features.map((f) => f.properties),\n features,\n undefined,\n );\n }\n\n /** Adds or replaces the buildings of a tile: GeoJSON, or typed arrays with the properties of each feature */\n setTile(key: TileKey, data: FeatureData<P> | { arrays: PolygonArrays; properties: P[] }): void {\n if ('arrays' in data) this.put(key, data.properties, undefined, data.arrays);\n else {\n const features = featuresOf(data);\n\n this.put(\n key,\n features.map((f) => f.properties),\n features,\n undefined,\n );\n }\n }\n\n removeTile(key: TileKey): void {\n const tile = this.tiles.get(key);\n\n if (!tile) return;\n this.tiles.delete(key);\n this.map.engine.removeExtrusionBatch(this.id, tile.batch);\n this.map.requestRender();\n }\n\n /** Keys of the tiles held */\n get tileKeys(): TileKey[] {\n return [...this.tiles.keys()].filter((k): k is TileKey => k !== DATA);\n }\n\n /** The properties of the features of a tile (or of the data) */\n properties(key?: TileKey): readonly P[] {\n return this.tiles.get(key ?? DATA)?.properties ?? [];\n }\n\n /** The feature of a picked index (its geometry if given as GeoJSON): tiles are numbered one after the other, in the\n * order they were added */\n featureAt(index: number): Feature<P> | undefined {\n let rest = index;\n\n for (const tile of [...this.tiles.values()].sort((a, b) => a.batch - b.batch)) {\n const n = tile.properties.length;\n\n if (rest < n) {\n const properties = tile.properties[rest];\n\n if (properties === undefined) return undefined;\n\n return tile.features?.[rest] ?? { type: 'Feature', properties, geometry: null };\n }\n rest -= n;\n }\n\n return undefined;\n }\n\n /** The tile and the index in it of a picked index */\n tileAt(index: number): { key: TileKey | undefined; index: number } | undefined {\n let rest = index;\n\n for (const [key, tile] of [...this.tiles].sort((a, b) => a[1].batch - b[1].batch)) {\n if (rest < tile.properties.length) return { key: key === DATA ? undefined : key, index: rest };\n rest -= tile.properties.length;\n }\n\n return undefined;\n }\n\n setStyle(style: Partial<ExtrusionStyle<P>>): void {\n this.style = { ...this.style, ...style };\n\n const engine = this.map.engine;\n // The roofs are geometry: the blocks built again\n const reshaped = style.roof !== undefined || style.roofHeight !== undefined;\n\n this.tiles.forEach((tile) => {\n if (reshaped) this.sendTile(engine, this.id, tile);\n else this.sendStyle(engine, this.id, tile);\n });\n this.sendLayer(engine, this.id);\n this.map.requestRender();\n }\n\n setVisible(visible: boolean): void {\n this.setStyle({ visible });\n }\n\n setFilter(filter: ((properties: P, index: number) => boolean) | undefined): void {\n this.style = { ...this.style, filter };\n this.tiles.forEach((tile) => {\n this.map.engine.setFeatureMask(this.id, this.mask(tile), tile.batch);\n });\n this.map.requestRender();\n }\n\n /** One value per building of a tile (or of the data), colored through the ramp; NaN keeps a building's color */\n setValues(values: Float32Array | undefined, key?: TileKey): void {\n const tile = this.tiles.get(key ?? DATA);\n\n if (!tile) return;\n tile.values = values;\n this.map.engine.setFeatureValues(\n this.id,\n values ?? new Float32Array(tile.properties.length).fill(Number.NaN),\n tile.batch,\n );\n this.map.requestRender();\n }\n\n /**\n * Colors the buildings by the node values of a network layer, recolored with it: each building takes min(value(A)\n * + cost from A, value(B) + cost from B) from its anchors (`setAnchors`), through the ramp, up to `max` (above, or\n * unreached: its own color). Undefined: back to the buildings' own values.\n */\n linkNetwork(network: NetworkLayer | undefined, max = Number.POSITIVE_INFINITY): void {\n this.network = network && { layer: network, max };\n this.sendLink(this.map.engine, this.id);\n this.map.requestRender();\n }\n\n /** Per building of a tile (or of the data): node A, node B, cost from A, cost from B (4 floats each) */\n setAnchors(anchors: Float32Array, key?: TileKey): void {\n const tile = this.tiles.get(key ?? DATA);\n\n if (!tile) return;\n tile.anchors = anchors;\n this.map.engine.setExtrusionAnchors(this.id, tile.batch, anchors);\n this.map.requestRender();\n }\n\n private put(\n key: TileKey | typeof DATA,\n properties: P[],\n features: Feature<P>[] | undefined,\n arrays: PolygonArrays | undefined,\n ): void {\n const old = this.tiles.get(key);\n const tile: Tile<P> = {\n batch: old?.batch ?? (key === DATA ? 0 : this.nextBatch++),\n properties,\n features,\n arrays,\n values: undefined,\n anchors: undefined,\n };\n\n this.tiles.set(key, tile);\n this.sendTile(this.map.engine, this.id, tile);\n this.map.requestRender();\n }\n\n private mask(tile: Tile<P>): Uint8Array {\n const { filter } = this.style;\n const mask = new Uint8Array(tile.properties.length).fill(255);\n\n if (filter)\n tile.properties.forEach((p, i) => {\n if (!filter(p, i)) mask[i] = 0;\n });\n\n return mask;\n }\n\n private sendTile(engine: Engine, id: number, tile: Tile<P>): void {\n const g = tile.arrays ?? polygonGeometry(tile.features ?? []);\n const n = tile.properties.length;\n const { roofs, heights } = this.roofs(tile, g.feature);\n // The metres per Mercator unit at the middle of the batch (a batch spanning a country errs by a few hundredths)\n const [north, south] = g.points.reduce(\n ([lo, hi], v, i) => (i % 2 === 1 ? [Math.min(lo, v), Math.max(hi, v)] : [lo, hi]),\n [1, 0],\n );\n const metres = north <= south ? metresAt((north + south) / 2) : 0;\n\n engine.setExtrusionBatch(\n id,\n tile.batch,\n g.points,\n g.ringStart,\n g.polygonStart,\n g.feature,\n n,\n roofs,\n heights,\n metres,\n );\n this.sendStyle(engine, id, tile);\n if (tile.values) engine.setFeatureValues(id, tile.values, tile.batch);\n if (tile.anchors) engine.setExtrusionAnchors(id, tile.batch, tile.anchors);\n }\n\n /** Each polygon's roof (`roofNumber`: none if all flat) and height, from its feature's style */\n private roofs(tile: Tile<P>, feature: Uint32Array): { roofs: Uint8Array; heights: Float32Array } {\n const { roof, roofHeight } = this.style;\n\n if (roof === 'flat') return { roofs: new Uint8Array(), heights: new Float32Array() };\n\n const shapes = tile.properties.map((p, i) => roofNumber(evaluate(roof, p, i)) ?? 0);\n const heights = tile.properties.map((p, i) => evaluate(roofHeight, p, i));\n\n return {\n roofs: Uint8Array.from(feature, (f) => shapes[f] ?? 0),\n heights: Float32Array.from(feature, (f) => heights[f] ?? Number.NaN),\n };\n }\n\n private sendStyle(engine: Engine, id: number, tile: Tile<P>): void {\n const { color, height, base } = this.style;\n const out = new Float32Array(tile.properties.length * FLOATS);\n // Constant colors parsed once: a tile has thousands of buildings\n const fixed = typeof color === 'string' ? parseColor(color) : undefined;\n\n tile.properties.forEach((p, i) => {\n const o = i * FLOATS;\n\n out.set(fixed ?? parseColor(evaluate(color, p, i)), o + STYLE.color);\n out.set(stops(evaluate(height, p, i)), o + STYLE.size);\n out.set(stops(evaluate(base, p, i)), o + STYLE.size2);\n });\n engine.setFeatureStyle(id, out, tile.batch);\n engine.setFeatureMask(id, this.mask(tile), tile.batch);\n }\n\n private sendLayer(engine: Engine, id: number): void {\n const { ramp, opacity, minZoom, maxZoom, visible } = this.style;\n const r = ramp && rampTexels(ramp);\n\n engine.setFeatureRamp(id, r?.rgba, r?.min ?? 0, r?.max ?? 1);\n engine.setFeatureLayer(id, Float32Array.from(stops(opacity)), minZoom, maxZoom, visible);\n engine.setFacades(id, this.style.facades);\n }\n\n private sendLink(engine: Engine, id: number): void {\n const n = this.network;\n // A network removed (or not created) links to nothing\n const network = n && n.layer.id >= 0 ? n.layer.id : undefined;\n\n engine.linkExtrusionNetwork(id, network, n ? Math.min(n.max, 1e29) : 0);\n }\n\n /** @internal */\n protected create(engine: Engine): number {\n const id = engine.addExtrusions();\n\n this.sendLayer(engine, id);\n this.tiles.forEach((tile) => {\n this.sendTile(engine, id, tile);\n });\n // A network created before (on a new engine, the map relinks once every layer is there)\n if (!this.network || this.network.layer.id >= 0) this.sendLink(engine, id);\n\n return id;\n }\n\n /** @internal On a new engine, the network may come after the buildings: linked once both are there */\n override relink(engine: Engine): void {\n if (this.network) this.sendLink(engine, this.id);\n }\n}\n\nexport const extrusionStyle = <P>(options: ExtrusionOptions<P>): ExtrusionStyle<P> => {\n const { data: _, before: __, ...rest } = options;\n\n return {\n opacity: 1,\n minZoom: 0,\n maxZoom: 24,\n visible: true,\n filter: undefined,\n ramp: undefined,\n color: '#e4e1dc',\n height: 6,\n base: 0,\n roof: 'flat',\n roofHeight: Number.NaN,\n facades: false,\n ...rest,\n };\n};\n"]}