isard 1.7.0 → 1.9.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.
- package/CHANGELOG.md +53 -0
- package/dist/basemap/grid.js +2 -5
- package/dist/basemap/grid.js.map +1 -1
- package/dist/basemap/models/furniture.d.ts +12 -0
- package/dist/basemap/{furniture.js → models/furniture.js} +6 -8
- package/dist/basemap/models/furniture.js.map +1 -0
- package/dist/basemap/{meshes.js → models/meshes.js} +1 -1
- package/dist/basemap/models/meshes.js.map +1 -0
- package/dist/basemap/models/trees.d.ts +21 -0
- package/dist/basemap/{trees.js → models/trees.js} +4 -36
- package/dist/basemap/models/trees.js.map +1 -0
- package/dist/basemap/placed.d.ts +2 -0
- package/dist/basemap/placed.js +2 -0
- package/dist/basemap/placed.js.map +1 -1
- package/dist/basemap/pmtiles.js +4 -3
- package/dist/basemap/pmtiles.js.map +1 -1
- package/dist/basemap/pmtileslayer.d.ts +4 -4
- package/dist/basemap/pmtileslayer.js +2 -1
- package/dist/basemap/pmtileslayer.js.map +1 -1
- package/dist/basemap/resample.js +3 -2
- package/dist/basemap/resample.js.map +1 -1
- package/dist/basemap/terrain.d.ts +5 -0
- package/dist/basemap/terrain.js +6 -4
- package/dist/basemap/terrain.js.map +1 -1
- package/dist/basemap/vectortiles/context.d.ts +3 -2
- package/dist/basemap/vectortiles/context.js.map +1 -1
- package/dist/basemap/vectortiles/extrusions.js.map +1 -1
- package/dist/basemap/vectortiles/furniture.d.ts +3 -3
- package/dist/basemap/vectortiles/furniture.js +2 -1
- package/dist/basemap/vectortiles/furniture.js.map +1 -1
- package/dist/basemap/vectortiles/labels.js +2 -1
- package/dist/basemap/vectortiles/labels.js.map +1 -1
- package/dist/basemap/vectortiles/lamps.d.ts +3 -3
- package/dist/basemap/vectortiles/lamps.js +1 -1
- package/dist/basemap/vectortiles/lamps.js.map +1 -1
- package/dist/basemap/vectortiles/placed.d.ts +3 -2
- package/dist/basemap/vectortiles/placed.js +5 -10
- package/dist/basemap/vectortiles/placed.js.map +1 -1
- package/dist/basemap/vectortiles/street-wind.js +2 -2
- package/dist/basemap/vectortiles/street-wind.js.map +1 -1
- package/dist/basemap/vectortiles/style.js +7 -8
- package/dist/basemap/vectortiles/style.js.map +1 -1
- package/dist/basemap/vectortiles/tiles.d.ts +1 -3
- package/dist/basemap/vectortiles/tiles.js +1 -1
- package/dist/basemap/vectortiles/tiles.js.map +1 -1
- package/dist/basemap/vectortiles/trees.d.ts +4 -4
- package/dist/basemap/vectortiles/trees.js +2 -1
- package/dist/basemap/vectortiles/trees.js.map +1 -1
- package/dist/basemap/vectortiles/vectors.d.ts +2 -3
- package/dist/basemap/vectortiles/vectors.js.map +1 -1
- package/dist/basemap/vectortiles.d.ts +6 -5
- package/dist/basemap/vectortiles.js +4 -3
- package/dist/basemap/vectortiles.js.map +1 -1
- package/dist/basemap/wmts.js +3 -4
- package/dist/basemap/wmts.js.map +1 -1
- package/dist/basemap/{trees.d.ts → woods.d.ts} +2 -19
- package/dist/basemap/woods.js +38 -0
- package/dist/basemap/woods.js.map +1 -0
- package/dist/basemap/workerpool.d.ts +1 -1
- package/dist/basemap/workerpool.js +3 -3
- package/dist/basemap/workerpool.js.map +1 -1
- package/dist/basemap.worker.js +2 -2
- package/dist/basemap.worker.js.map +23 -22
- package/dist/bind/layers.d.ts +10 -3
- package/dist/bind/layers.js +11 -4
- package/dist/bind/layers.js.map +1 -1
- package/dist/data/collada.js +4 -4
- package/dist/data/collada.js.map +1 -1
- package/dist/data/ifc.js +6 -11
- package/dist/data/ifc.js.map +1 -1
- package/dist/decoder.worker.js +5 -5
- package/dist/decoder.worker.js.map +7 -6
- package/dist/decoding/decoders.js.map +1 -0
- package/dist/{engine → decoding}/loader.js +2 -2
- package/dist/decoding/loader.js.map +1 -0
- package/dist/{engine → decoding}/protocol.d.ts +1 -1
- package/dist/decoding/protocol.js.map +1 -0
- package/dist/engine-loader.d.ts +1 -1
- package/dist/engine-loader.js +3 -2
- package/dist/engine-loader.js.map +1 -1
- package/dist/geoplateforme.d.ts +4 -3
- package/dist/geoplateforme.js +8 -10
- package/dist/geoplateforme.js.map +1 -1
- package/dist/index.d.ts +16 -8
- package/dist/index.js +9 -3
- package/dist/index.js.map +1 -1
- package/dist/isard_bg.wasm +0 -0
- package/dist/isard_core_bg.wasm +0 -0
- package/dist/isard_grid_bg.wasm +0 -0
- package/dist/isard_tess_bg.wasm +0 -0
- package/dist/layers/custom.d.ts +56 -0
- package/dist/layers/custom.js +93 -0
- package/dist/layers/custom.js.map +1 -0
- package/dist/layers/extrusions.d.ts +4 -2
- package/dist/layers/extrusions.js +2 -1
- package/dist/layers/extrusions.js.map +1 -1
- package/dist/layers/features.d.ts +3 -14
- package/dist/layers/features.js +4 -25
- package/dist/layers/features.js.map +1 -1
- package/dist/layers/flow.d.ts +3 -3
- package/dist/layers/flow.js +3 -4
- package/dist/layers/flow.js.map +1 -1
- package/dist/layers/glyphs.js +5 -3
- package/dist/layers/glyphs.js.map +1 -1
- package/dist/layers/ground.d.ts +57 -0
- package/dist/layers/ground.js +78 -0
- package/dist/layers/ground.js.map +1 -0
- package/dist/layers/icons.js +8 -6
- package/dist/layers/icons.js.map +1 -1
- package/dist/layers/layers.d.ts +2 -199
- package/dist/layers/layers.js +2 -469
- package/dist/layers/layers.js.map +1 -1
- package/dist/layers/models.d.ts +48 -0
- package/dist/layers/models.js +111 -0
- package/dist/layers/models.js.map +1 -0
- package/dist/layers/network.d.ts +26 -0
- package/dist/layers/network.js +127 -0
- package/dist/layers/network.js.map +1 -0
- package/dist/layers/panoramas.d.ts +2 -11
- package/dist/layers/panoramas.js +19 -9
- package/dist/layers/panoramas.js.map +1 -1
- package/dist/layers/photos.d.ts +4 -7
- package/dist/layers/photos.js +3 -4
- package/dist/layers/photos.js.map +1 -1
- package/dist/layers/pointclouds.d.ts +3 -2
- package/dist/layers/pointclouds.js +3 -3
- package/dist/layers/pointclouds.js.map +1 -1
- package/dist/layers/raster.d.ts +9 -0
- package/dist/layers/raster.js +24 -0
- package/dist/layers/raster.js.map +1 -0
- package/dist/layers/symbols.d.ts +2 -2
- package/dist/layers/symbols.js +2 -1
- package/dist/layers/symbols.js.map +1 -1
- package/dist/layers/tiles3d.d.ts +15 -0
- package/dist/layers/tiles3d.js +55 -0
- package/dist/layers/tiles3d.js.map +1 -0
- package/dist/layers/trees.d.ts +5 -7
- package/dist/layers/trees.js +2 -1
- package/dist/layers/trees.js.map +1 -1
- package/dist/layers/vectors.js.map +1 -1
- package/dist/map/basemap-layers.js +1 -1
- package/dist/map/basemap-layers.js.map +1 -1
- package/dist/map/engine-settings.d.ts +1 -1
- package/dist/map/engine-settings.js +1 -1
- package/dist/map/engine-settings.js.map +1 -1
- package/dist/map/engines.js.map +1 -1
- package/dist/map/layer-spec.d.ts +7 -13
- package/dist/map/layer-spec.js.map +1 -1
- package/dist/map/workers.js +3 -4
- package/dist/map/workers.js.map +1 -1
- package/dist/map.d.ts +15 -58
- package/dist/map.js +39 -52
- package/dist/map.js.map +1 -1
- package/dist/panoramax.d.ts +15 -2
- package/dist/panoramax.js +38 -21
- package/dist/panoramax.js.map +1 -1
- package/dist/react/CustomLayer.d.ts +1 -1
- package/dist/react/CustomLayer.js +5 -4
- package/dist/react/CustomLayer.js.map +1 -1
- package/dist/react/Layer.d.ts +6 -2
- package/dist/react/Layer.js +6 -5
- package/dist/react/Layer.js.map +1 -1
- package/dist/react/VectorGeometry.js +5 -4
- package/dist/react/VectorGeometry.js.map +1 -1
- package/dist/react/VectorTiles.d.ts +2 -2
- package/dist/react/VectorTiles.js +1 -1
- package/dist/react/VectorTiles.js.map +1 -1
- package/dist/react/context.d.ts +3 -0
- package/dist/react/context.js +8 -1
- package/dist/react/context.js.map +1 -1
- package/dist/types.d.ts +14 -4
- package/dist/types.js.map +1 -1
- package/dist/ui/controls.js +2 -1
- package/dist/ui/controls.js.map +1 -1
- package/dist/ui/interaction.js +6 -5
- package/dist/ui/interaction.js.map +1 -1
- package/dist/ui/minimap.js +1 -1
- package/dist/ui/minimap.js.map +1 -1
- package/dist/ui/overlay.js +3 -3
- package/dist/ui/overlay.js.map +1 -1
- package/dist/ui/search.js +1 -1
- package/dist/ui/search.js.map +1 -1
- package/dist/util/animation.js +3 -2
- package/dist/util/animation.js.map +1 -1
- package/dist/util/color.d.ts +10 -0
- package/dist/util/color.js +29 -9
- package/dist/util/color.js.map +1 -1
- package/dist/util/fetch.d.ts +5 -0
- package/dist/util/fetch.js +11 -0
- package/dist/util/fetch.js.map +1 -0
- package/dist/util/geo.d.ts +5 -0
- package/dist/util/geo.js +8 -2
- package/dist/util/geo.js.map +1 -1
- package/dist/util/math.d.ts +3 -0
- package/dist/util/math.js +4 -0
- package/dist/util/math.js.map +1 -0
- package/dist/util/requests.js.map +1 -0
- package/dist/util/roofs.d.ts +0 -2
- package/dist/util/roofs.js +0 -3
- package/dist/util/roofs.js.map +1 -1
- package/dist/wasm/isard.js +1 -1
- package/dist/wasm/isard_core.js +1 -1
- package/dist/workers/basemap/geometry.d.ts +9 -19
- package/dist/workers/{basemap.worker.d.ts → basemap/protocol.d.ts} +29 -23
- package/dist/workers/basemap/street.d.ts +4 -2
- package/dist/workers/basemap/tiles.d.ts +1 -3
- package/dist/workers/basemap/trees.d.ts +2 -2
- package/package.json +1 -1
- package/dist/basemap/furniture.d.ts +0 -26
- package/dist/basemap/furniture.js.map +0 -1
- package/dist/basemap/meshes.js.map +0 -1
- package/dist/basemap/trees.js.map +0 -1
- package/dist/engine/decoders.js.map +0 -1
- package/dist/engine/loader.js.map +0 -1
- package/dist/engine/protocol.js.map +0 -1
- package/dist/engine/requests.js.map +0 -1
- package/dist/workers/basemap/furniture.d.ts +0 -13
- package/dist/workers/basemap/labels.d.ts +0 -24
- package/dist/workers/basemap/lamps.d.ts +0 -10
- package/dist/workers/basemap/raster.d.ts +0 -10
- package/dist/workers/basemap.worker.js +0 -221
- package/dist/workers/basemap.worker.js.map +0 -1
- /package/dist/basemap/{meshes.d.ts → models/meshes.d.ts} +0 -0
- /package/dist/{engine → decoding}/decoders.d.ts +0 -0
- /package/dist/{engine → decoding}/decoders.js +0 -0
- /package/dist/{engine → decoding}/loader.d.ts +0 -0
- /package/dist/{engine → decoding}/protocol.js +0 -0
- /package/dist/{engine → util}/requests.d.ts +0 -0
- /package/dist/{engine → util}/requests.js +0 -0
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* context loss or once the engine with 3D Tiles is loaded), with the page's request headers.
|
|
4
4
|
*/
|
|
5
5
|
import { SEA } from "../basemap/basemaps.js";
|
|
6
|
-
import { headerRules } from "../engine/requests.js";
|
|
7
6
|
import { atmosphereSettings, bodySettings, haloSettings, rgb, terrainSettings, } from "../settings.js";
|
|
7
|
+
import { headerRules } from "../util/requests.js";
|
|
8
8
|
/** The settings of a map from its options; `earth`: the map is of the Earth */
|
|
9
9
|
export const mapSettings = (options, earth, terrainLoader) => {
|
|
10
10
|
const body = bodySettings(options.body);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine-settings.js","sourceRoot":"","sources":["../../src/map/engine-settings.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAE7C,OAAO,
|
|
1
|
+
{"version":3,"file":"engine-settings.js","sourceRoot":"","sources":["../../src/map/engine-settings.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAE7C,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,YAAY,EACZ,GAAG,EAGH,eAAe,GAChB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAoB,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGpE,+EAA+E;AAC/E,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,OAAsB,EACtB,KAAc,EACd,aAAoF,EAC1E,EAAE;IACZ,MAAM,IAAI,GAAG,YAAY,CAAC,OAAO,CAAC,IAAI,CAA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of the map's engine: made from the options, given to each new engine (at creation, and again after a\n * context loss or once the engine with 3D Tiles is loaded), with the page's request headers.\n */\n\nimport { SEA } from '../basemap/basemaps.ts';\nimport type { PngEncoding } from '../basemap/terrain.ts';\nimport {\n atmosphereSettings,\n bodySettings,\n haloSettings,\n rgb,\n type Settings,\n type TerrainLoader,\n terrainSettings,\n} from '../settings.ts';\nimport type { GeoMapOptions } from '../types.ts';\nimport { type HeaderRules, headerRules } from '../util/requests.ts';\nimport type { Engine } from '../wasm/isard.js';\n\n/** The settings of a map from its options; `earth`: the map is of the Earth */\nexport const mapSettings = (\n options: GeoMapOptions,\n earth: boolean,\n terrainLoader: (url: string, encoding: PngEncoding, floor?: number) => TerrainLoader,\n): Settings => {\n const body = bodySettings(options.body);\n\n return {\n body,\n zoomRange: [options.minZoom ?? 0, options.maxZoom ?? 22],\n maxPitch: options.maxPitch ?? 70,\n globe: (options.projection ?? 'globe') === 'globe',\n sky: options.sky ?? true,\n atmosphere: atmosphereSettings(options.atmosphere),\n terrain: terrainSettings(options.terrain, options.body, body.radius, terrainLoader),\n loading: options.loading ?? 'immediate',\n background: rgb(options.background ?? (earth ? '#f2f2f0' : '#000000')),\n globeColor: earth ? SEA['osm-positron'] : rgb(body.color),\n };\n};\n\n/** Gives a new engine the settings and the page's request headers */\nexport const applySettings = (engine: Engine, settings: Settings): void => {\n // The body first: the layers' shaders may take its size\n const { radius, flattening, atmosphere: air, relief } = settings.body;\n\n engine.setBody(radius, flattening, haloSettings(air), ...relief);\n sendHeaders(engine, headerRules());\n\n const { zoomRange, maxPitch, globe, sky, atmosphere, terrain, loading, background, globeColor } = settings;\n\n engine.setZoomRange(...zoomRange);\n engine.setMaxPitch(maxPitch);\n engine.setGlobe(globe);\n engine.setSky(sky);\n engine.setAtmosphere(atmosphere);\n engine.setTerrain(terrain?.url, terrain?.exaggeration ?? 1, terrain?.maxZoom, terrain?.geoid, terrain?.loader);\n engine.setImmediateLoading(loading === 'immediate');\n engine.setBackground(...background);\n engine.setGlobeColor(...globeColor);\n};\n\n/** The page's request headers to an engine (its own requests: raster tiles, tilesets, point clouds) */\nexport const sendHeaders = (engine: Engine, rules: HeaderRules): void => {\n engine.setRequestHeaders(\n rules.map(([prefix]) => prefix),\n Uint32Array.from(rules, ([, headers]) => Object.keys(headers).length),\n rules.flatMap(([, headers]) => Object.entries(headers).flat()),\n );\n};\n"]}
|
package/dist/map/engines.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engines.js","sourceRoot":"","sources":["../../src/map/engines.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAEL,SAAS,EACT,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,GAChB,MAAM,qBAAqB,CAAC;AAI7B,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAQrD,iFAAiF;AACjF,MAAM,OAAO,UAAU;IACrB,iHAAiH;IACzG,WAAW,CAAc;IACjC,oGAAoG;IAC5F,MAAM,CAAiC;IAC/C,UAAU,CAA4B;IAC9B,MAAM,CAAyB;IACtB,OAAO,CAAuB;IAC/C,wDAAwD;IACvC,IAAI,CAAgB;IAErC,uFAAuF;IACvF,YACE,WAAwB,EACxB,MAAsC,EACtC,OAA6B,EAC7B,IAAmB;QAEnB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,EAAE,GAAG,OAAO,EAAE,CAAC;QAC9B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,4CAA4C;IAC5C,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,MAAM,KAAK,SAAS,CAAC;IACnC,CAAC;IAED,4FAA4F;IAC5F,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED,8GAA8G;IAC9G,MAAM,CAAC,MAAyB,EAAE,MAAkB,EAAE,QAAkB;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IAAI,CAAC,IAAI,EAAE;gBAAE,OAAO;YACxB,MAAM,CAAC,KAAK,CAAC,CAAC;QAChB,CAAC,CACF,CAAC;IACJ,CAAC;IAED,mHAAmH;IACnH,OAAO;QACL,iBAAiB,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACzF,CAAC;IAED,iCAAiC;IACjC,OAAO;QACL,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC;IACzB,CAAC;CACF","sourcesContent":["/**\n * Which engine a map runs: the core one, or the one with 3D Tiles, from the start or loaded once a layer needs it\n * (the map is rebuilt on it then); and the workers decoding its 3D Tiles, started with the first engine that has them.\n */\n\nimport type { TileLoader } from '../
|
|
1
|
+
{"version":3,"file":"engines.js","sourceRoot":"","sources":["../../src/map/engines.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAEL,SAAS,EACT,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,GAChB,MAAM,qBAAqB,CAAC;AAI7B,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAQrD,iFAAiF;AACjF,MAAM,OAAO,UAAU;IACrB,iHAAiH;IACzG,WAAW,CAAc;IACjC,oGAAoG;IAC5F,MAAM,CAAiC;IAC/C,UAAU,CAA4B;IAC9B,MAAM,CAAyB;IACtB,OAAO,CAAuB;IAC/C,wDAAwD;IACvC,IAAI,CAAgB;IAErC,uFAAuF;IACvF,YACE,WAAwB,EACxB,MAAsC,EACtC,OAA6B,EAC7B,IAAmB;QAEnB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,EAAE,GAAG,OAAO,EAAE,CAAC;QAC9B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC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B,IAAI,IAAI,CAAC,IAAI,EAAE;gBAAE,OAAO;YACxB,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC;YAC1B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;YACrB,MAAM,EAAE,CAAC;QACX,CAAC,EACD,CAAC,KAAc,EAAE,EAAE;YACjB,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;YAC5B,IAAI,IAAI,CAAC,IAAI,EAAE;gBAAE,OAAO;YACxB,MAAM,CAAC,KAAK,CAAC,CAAC;QAChB,CAAC,CACF,CAAC;IACJ,CAAC;IAED,mHAAmH;IACnH,OAAO;QACL,iBAAiB,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACzF,CAAC;IAED,iCAAiC;IACjC,OAAO;QACL,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC;IACzB,CAAC;CACF","sourcesContent":["/**\n * Which engine a map runs: the core one, or the one with 3D Tiles, from the start or loaded once a layer needs it\n * (the map is rebuilt on it then); and the workers decoding its 3D Tiles, started with the first engine that has them.\n */\n\nimport type { TileLoader } from '../decoding/loader.ts';\nimport {\n type EngineClass,\n engineUrl,\n loadFullEngineLater,\n preloadFullEngine,\n startTileLoader,\n} from '../engine-loader.ts';\nimport type { Settings } from '../settings.ts';\nimport type { GeoMapOptions } from '../types.ts';\nimport type { Engine } from '../wasm/isard.js';\nimport { applySettings } from './engine-settings.ts';\n\n/** What loading the engine with 3D Tiles and its workers needs */\nexport type Tiles3dEngineOptions = Pick<\n GeoMapOptions,\n 'wasmUrl' | 'workers' | 'workerUrl' | 'decoders' | 'pointsWasmUrl' | 'assetsUrl'\n>;\n\n/** The engine class of a map, and the engine with 3D Tiles loaded when needed */\nexport class MapEngines {\n /** The class of the engine: without 3D Tiles until a 3D Tiles layer is added, unless asked for from the start */\n private engineClass: EngineClass;\n /** The module of the engine with 3D Tiles once it runs the map (the decoding workers run it too) */\n private module: WebAssembly.Module | undefined;\n #upgrading: Promise<void> | undefined;\n private loader: TileLoader | undefined;\n private readonly options: Tiles3dEngineOptions;\n /** The map is destroyed: a loaded engine is not used */\n private readonly gone: () => boolean;\n\n /** `module`: the module of the engine with 3D Tiles if `engineClass` is that engine */\n constructor(\n engineClass: EngineClass,\n module: WebAssembly.Module | undefined,\n options: Tiles3dEngineOptions,\n gone: () => boolean,\n ) {\n this.engineClass = engineClass;\n this.module = module;\n this.options = { ...options };\n this.gone = gone;\n }\n\n /** The engine with 3D Tiles runs the map */\n get tiles3d(): boolean {\n return this.module !== undefined;\n }\n\n /** The engine with 3D Tiles is loading, for the 3D Tiles layers added on the core engine */\n get upgrading(): Promise<void> | undefined {\n return this.#upgrading;\n }\n\n /** A new engine drawing on `canvas`, with the settings and the decoding workers of 3D Tiles if it has them */\n create(canvas: HTMLCanvasElement, redraw: () => void, settings: Settings): Engine {\n const engine = new this.engineClass(canvas, redraw);\n\n applySettings(engine, settings);\n // The decoding workers of 3D Tiles, with the engine that has them (they run its module) and unless turned off\n this.loader ??= this.module && startTileLoader(this.module, this.options, engine);\n if (this.loader) engine.setTileLoader(this.loader);\n\n return engine;\n }\n\n /** Height of the geoid above the ellipsoid at a position, in metres */\n geoidHeight(lon: number, lat: number): number {\n return this.engineClass.geoidHeight(lon, lat);\n }\n\n /** The matrix of a custom layer's model at a position */\n customMatrix(lon: number, lat: number, altitude: number): Float32Array | undefined {\n return this.engineClass.customMatrix(lon, lat, altitude);\n }\n\n /** Loads the engine with 3D Tiles, once at a time: `loaded` once it is the map's class, `failed` with the error;\n * neither if the map is gone by then */\n upgrade(loaded: () => void, failed: (error: unknown) => void): void {\n this.#upgrading ??= loadFullEngineLater(engineUrl('full', this.options)).then(\n ({ module, Engine }) => {\n this.#upgrading = undefined;\n if (this.gone()) return;\n this.engineClass = Engine;\n this.module = module;\n loaded();\n },\n (error: unknown) => {\n this.#upgrading = undefined;\n if (this.gone()) return;\n failed(error);\n },\n );\n }\n\n /** Downloads and compiles the engine with 3D Tiles without running it, unless the map is gone or has it by then */\n preload(): void {\n preloadFullEngine(engineUrl('full', this.options), () => !this.gone() && !this.module);\n }\n\n /** Stops the decoding workers */\n destroy(): void {\n this.loader?.destroy();\n }\n}\n"]}
|
package/dist/map/layer-spec.d.ts
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
import type { ExtrusionOptions } from '../layers/extrusions.ts';
|
|
3
3
|
import type { CircleOptions, FillOptions, LineOptions } from '../layers/features.ts';
|
|
4
4
|
import type { FlowOptions } from '../layers/flow.ts';
|
|
5
|
-
import type { GroundOptions
|
|
5
|
+
import type { GroundOptions } from '../layers/ground.ts';
|
|
6
|
+
import type { Layer } from '../layers/layers.ts';
|
|
7
|
+
import type { ModelOptions } from '../layers/models.ts';
|
|
6
8
|
import type { PointCloudOptions } from '../layers/pointclouds.ts';
|
|
7
9
|
import type { SymbolOptions } from '../layers/symbols.ts';
|
|
8
10
|
import type { TreeOptions } from '../layers/trees.ts';
|
|
@@ -21,25 +23,17 @@ export type LayerSpec<P = Record<string, unknown>> = ({
|
|
|
21
23
|
type: 'extrusions';
|
|
22
24
|
} & ExtrusionOptions<P>) | ({
|
|
23
25
|
type: 'raster';
|
|
24
|
-
} & RasterOptions
|
|
25
|
-
before?: Layer;
|
|
26
|
-
}) | ({
|
|
26
|
+
} & RasterOptions) | ({
|
|
27
27
|
type: 'ground';
|
|
28
|
-
} & GroundOptions
|
|
29
|
-
before?: Layer;
|
|
30
|
-
}) | ({
|
|
28
|
+
} & GroundOptions) | ({
|
|
31
29
|
type: 'network';
|
|
32
30
|
} & NetworkOptions) | ({
|
|
33
31
|
type: 'tiles3d';
|
|
34
32
|
} & Tiles3dOptions) | ({
|
|
35
33
|
type: 'pointcloud';
|
|
36
|
-
} & PointCloudOptions
|
|
37
|
-
before?: Layer;
|
|
38
|
-
}) | ({
|
|
34
|
+
} & PointCloudOptions) | ({
|
|
39
35
|
type: 'models';
|
|
40
|
-
} & ModelOptions
|
|
41
|
-
before?: Layer;
|
|
42
|
-
}) | ({
|
|
36
|
+
} & ModelOptions) | ({
|
|
43
37
|
type: 'trees';
|
|
44
38
|
} & TreeOptions<P>) | ({
|
|
45
39
|
type: 'flow';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layer-spec.js","sourceRoot":"","sources":["../../src/map/layer-spec.ts"],"names":[],"mappings":"AAAA,oHAAoH;
|
|
1
|
+
{"version":3,"file":"layer-spec.js","sourceRoot":"","sources":["../../src/map/layer-spec.ts"],"names":[],"mappings":"AAAA,oHAAoH;AA8BpH,oGAAoG;AACpG,MAAM,CAAC,MAAM,OAAO,GAAG,CAA8B,GAAW,EAAE,IAAkB,EAAS,EAAE;IAC7F,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,OAAO;YACV,OAAO,GAAG,CAAC,QAAQ,CAAI,IAAI,CAAC,CAAC;QAC/B,KAAK,SAAS;YACZ,OAAO,GAAG,CAAC,UAAU,CAAI,IAAI,CAAC,CAAC;QACjC,KAAK,OAAO;YACV,OAAO,GAAG,CAAC,QAAQ,CAAI,IAAI,CAAC,CAAC;QAC/B,KAAK,SAAS;YACZ,OAAO,GAAG,CAAC,UAAU,CAAI,IAAI,CAAC,CAAC;QACjC,KAAK,YAAY;YACf,OAAO,GAAG,CAAC,aAAa,CAAI,IAAI,CAAC,CAAC;QACpC,KAAK,QAAQ;YACX,OAAO,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAC7B,KAAK,QAAQ;YACX,OAAO,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAC7B,KAAK,SAAS;YACZ,OAAO,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAC9B,KAAK,SAAS;YACZ,OAAO,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAC9B,KAAK,YAAY;YACf,OAAO,GAAG,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QACjC,KAAK,QAAQ;YACX,OAAO,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAC7B,KAAK,OAAO;YACV,OAAO,GAAG,CAAC,QAAQ,CAAI,IAAI,CAAC,CAAC;QAC/B,KAAK,MAAM;YACT,OAAO,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC3B,OAAO,CAAC,CAAC,CAAC;YACR,sFAAsF;YACtF,MAAM,EAAE,IAAI,EAAE,GAAuB,IAAI,CAAC;YAE1C,MAAM,IAAI,KAAK,CAAC,2BAA2B,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;AACH,CAAC,CAAC","sourcesContent":["/** A layer described by its type and options, as an application's configuration gives it, and the map adding it. */\n\nimport type { ExtrusionOptions } from '../layers/extrusions.ts';\nimport type { CircleOptions, FillOptions, LineOptions } from '../layers/features.ts';\nimport type { FlowOptions } from '../layers/flow.ts';\nimport type { GroundOptions } from '../layers/ground.ts';\nimport type { Layer } from '../layers/layers.ts';\nimport type { ModelOptions } from '../layers/models.ts';\nimport type { PointCloudOptions } from '../layers/pointclouds.ts';\nimport type { SymbolOptions } from '../layers/symbols.ts';\nimport type { TreeOptions } from '../layers/trees.ts';\nimport type { GeoMap } from '../map.ts';\nimport type { NetworkOptions, RasterOptions, Tiles3dOptions } from '../types.ts';\n\n/** A layer by its type and the options of its `add…` method (`GeoMap.add`) */\nexport type LayerSpec<P = Record<string, unknown>> =\n | ({ type: 'lines' } & LineOptions<P>)\n | ({ type: 'circles' } & CircleOptions<P>)\n | ({ type: 'fills' } & FillOptions<P>)\n | ({ type: 'symbols' } & SymbolOptions<P>)\n | ({ type: 'extrusions' } & ExtrusionOptions<P>)\n | ({ type: 'raster' } & RasterOptions)\n | ({ type: 'ground' } & GroundOptions)\n | ({ type: 'network' } & NetworkOptions)\n | ({ type: 'tiles3d' } & Tiles3dOptions)\n | ({ type: 'pointcloud' } & PointCloudOptions)\n | ({ type: 'models' } & ModelOptions)\n | ({ type: 'trees' } & TreeOptions<P>)\n | ({ type: 'flow' } & FlowOptions);\n\n/** Adds the layer a description gives with the `add…` method of its type; an unknown type throws */\nexport const addSpec = <P = Record<string, unknown>>(map: GeoMap, spec: LayerSpec<P>): Layer => {\n switch (spec.type) {\n case 'lines':\n return map.addLines<P>(spec);\n case 'circles':\n return map.addCircles<P>(spec);\n case 'fills':\n return map.addFills<P>(spec);\n case 'symbols':\n return map.addSymbols<P>(spec);\n case 'extrusions':\n return map.addExtrusions<P>(spec);\n case 'raster':\n return map.addRaster(spec);\n case 'ground':\n return map.addGround(spec);\n case 'network':\n return map.addNetwork(spec);\n case 'tiles3d':\n return map.addTiles3d(spec);\n case 'pointcloud':\n return map.addPointCloud(spec);\n case 'models':\n return map.addModels(spec);\n case 'trees':\n return map.addTrees<P>(spec);\n case 'flow':\n return map.addFlow(spec);\n default: {\n // Only from an application's configuration, untyped: the cases above cover every type\n const { type }: { type?: unknown } = spec;\n\n throw new Error(`isard: no layer of type ${String(type)}`);\n }\n }\n};\n"]}
|
package/dist/map/workers.js
CHANGED
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { encodedTerrainLoader } from "../basemap/terrain.js";
|
|
6
6
|
import { BasemapWorkers, defaultWorkerCount } from "../basemap/workerpool.js";
|
|
7
|
-
import { withHeaders } from "../engine/requests.js";
|
|
8
7
|
import { decodeGrids } from "../grid-module.js";
|
|
9
8
|
import { gridOf } from "../grids.js";
|
|
9
|
+
import { fetchOk } from "../util/fetch.js";
|
|
10
|
+
import { withHeaders } from "../util/requests.js";
|
|
10
11
|
/** The workers of a map, created on first use */
|
|
11
12
|
export class MapWorkers {
|
|
12
13
|
/** URL of the workers' script */
|
|
@@ -73,9 +74,7 @@ export class MapWorkers {
|
|
|
73
74
|
// Against the page: the workers fetch it, and a relative URL would be theirs
|
|
74
75
|
const absolute = url && typeof document !== 'undefined' ? new URL(url, document.baseURI).href : url;
|
|
75
76
|
const fetchFile = async (at) => {
|
|
76
|
-
const response = await
|
|
77
|
-
if (!response.ok)
|
|
78
|
-
throw new Error(`isard: ${at}: ${response.status}`);
|
|
77
|
+
const response = await fetchOk(at, withHeaders(at, signal ? { signal } : {}));
|
|
79
78
|
return response.arrayBuffer();
|
|
80
79
|
};
|
|
81
80
|
const inPage = async () => decodeGrids(new Uint8Array(bytes ?? (await fetchFile(absolute ?? ''))), module);
|
package/dist/map/workers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workers.js","sourceRoot":"","sources":["../../src/map/workers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,oBAAoB,EAAwC,MAAM,uBAAuB,CAAC;AACnG,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9E,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAa,MAAM,EAAE,MAAM,aAAa,CAAC;AAIhD,iDAAiD;AACjD,MAAM,OAAO,UAAU;IACrB,iCAAiC;IACxB,GAAG,CAAe;IACV,OAAO,CAA2B;IACnD,gEAAgE;IAC/C,IAAI,CAAgB;IACrC,8DAA8D;IAC7C,KAAK,CAAS;IAC/B,4CAA4C;IACpC,MAAM,CAA6B;IAC3C;mDAC+C;IAC9B,cAAc,GAAG,IAAI,GAAG,EAAyB,CAAC;IAEnE,4EAA4E;IAC5E,YAAY,GAAiB,EAAE,OAAiC,EAAE,IAAmB,EAAE,KAAa;QAClG,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED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;QACP,CAAC,CAAC;QACF,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,EAAE,CAAC;QAEvC,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,IAAI,YAAY,EAAE,CAAC,CAAC,CAAC;IACzE,CAAC;IAED;;;OAGG;IACK,YAAY;QAClB,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAE7B,IAAI,IAAI,CAAC,IAAI,EAAE,IAAI,OAAO,KAAK,KAAK,IAAI,CAAC,OAAO,KAAK,SAAS,IAAI,OAAO,IAAI,CAAC,CAAC;YAAE,OAAO,SAAS,CAAC;QAClG,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,eAAe,KAAK,WAAW;YAAE,OAAO,SAAS,CAAC;QAE9F,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC;IAC1B,CAAC;CACF","sourcesContent":["/**\n * A map's workers: the pool drawing vector tiles, shared by the map's `VectorTiles`, which also decodes the relief and\n * reprojects rasters off the page; and the loaders of the relief, one per tile source.\n */\n\nimport type { RemoteReprojection } from '../basemap/grid.ts';\nimport { encodedTerrainLoader, type PngEncoding, type RemoteHeights } from '../basemap/terrain.ts';\nimport { BasemapWorkers, defaultWorkerCount } from '../basemap/workerpool.ts';\nimport { withHeaders } from '../engine/requests.ts';\nimport { decodeGrids } from '../grid-module.ts';\nimport { type Grid, gridOf } from '../grids.ts';\nimport type { TerrainLoader } from '../settings.ts';\nimport type { GeoMapOptions } from '../types.ts';\n\n/** The workers of a map, created on first use */\nexport class MapWorkers {\n /** URL of the workers' script */\n readonly url: string | URL;\n private readonly workers: GeoMapOptions['workers'];\n /** The map is destroyed: nothing more is sent to the workers */\n private readonly gone: () => boolean;\n /** Whose requests the workers' answer (cancelled together) */\n private readonly owner: object;\n /** The shared pool, created on first use */\n private shared: BasemapWorkers | undefined;\n /** The loaders of the relief by encoding, URL and floor: the same loader for the same tiles (the engine keeps its\n * tiles when only the exaggeration changes) */\n private readonly terrainLoaders = new Map<string, TerrainLoader>();\n\n /** `workers`: the map's option (false or 0, no worker); `owner`: the map */\n constructor(url: string | URL, workers: GeoMapOptions['workers'], gone: () => boolean, owner: object) {\n this.url = url;\n this.workers = workers;\n this.gone = gone;\n this.owner = owner;\n }\n\n /**\n * The workers for a `VectorTiles`: the shared pool, or a pool of its own (`own`, to stop with it) when it asks for\n * another count or URL\n */\n pool(count?: number, url?: string | URL): { pool: BasemapWorkers; own: boolean } {\n // Workers started after the map went would never be stopped\n if (this.gone()) throw new Error('isard: the map was destroyed');\n\n const shared = defaultWorkerCount();\n const workers = Math.max(1, count ?? shared);\n const workerUrl = url ?? this.url;\n\n if (workers === shared && String(workerUrl) === String(this.url)) {\n this.shared ??= new BasemapWorkers(shared, this.url);\n\n return { pool: this.shared, own: false };\n }\n\n return { pool: new BasemapWorkers(workers, workerUrl), own: true };\n }\n\n /** Stops the shared pool */\n terminate(): void {\n this.shared?.terminate();\n this.shared = undefined;\n }\n\n /** Rasters reprojected by the workers (in the page without them) */\n readonly remoteReprojection: RemoteReprojection = (job, tile, signal) =>\n this.decodingPool()?.reproject(job, tile, signal, this.owner);\n\n /** The loader of the relief tiles of `url` in a PNG encoding (one per URL, encoding and floor) */\n readonly terrainLoader = (url: string, encoding: PngEncoding, floor?: number): TerrainLoader => {\n const key = `${encoding} ${floor ?? ''} ${url}`;\n const cached = this.terrainLoaders.get(key);\n\n if (cached) return cached;\n\n const loader = encodedTerrainLoader(url, encoding, floor, this.remoteHeights);\n\n this.terrainLoaders.set(key, loader);\n\n return loader;\n };\n\n private readonly remoteHeights: RemoteHeights = (url, encoding, floor, tile, signal) =>\n this.decodingPool()?.heights(url, encoding, floor, tile, signal, this.owner);\n\n /** A GRIB2 or NetCDF file read into grids by the grid module (`module`), in a worker (in the page without them, or if\n * the worker fails) */\n async readGrids(\n source: string | URL | ArrayBuffer | Uint8Array,\n module: string,\n signal?: AbortSignal,\n ): Promise<Grid[]> {\n const pool = this.decodingPool();\n const url = typeof source === 'string' || source instanceof URL ? String(source) : undefined;\n const copy = source instanceof Uint8Array ? source.slice().buffer : undefined;\n const bytes = copy ?? (source instanceof ArrayBuffer ? source : undefined);\n // Against the page: the workers fetch it, and a relative URL would be theirs\n const absolute = url && typeof document !== 'undefined' ? new URL(url, document.baseURI).href : url;\n const fetchFile = async (at: string) => {\n const response = await fetch(at, withHeaders(at, signal ? { signal } : {}));\n\n if (!response.ok) throw new Error(`isard: ${at}: ${response.status}`);\n\n return response.arrayBuffer();\n };\n const inPage = async () => decodeGrids(new Uint8Array(bytes ?? (await fetchFile(absolute ?? ''))), module);\n const read = async () => {\n if (!pool) return inPage();\n\n return pool\n .grids(absolute ? { url: absolute } : { bytes: bytes ?? new ArrayBuffer(0) }, module, signal, this.owner)\n .catch((error: unknown) => {\n // A worker's failure (the module not fetched, a worker of an older build): read again in the page, unless\n // cancelled or its bytes handed over\n if (signal?.aborted || bytes?.byteLength === 0) throw error;\n\n return inPage();\n });\n };\n const { grids, values } = await read();\n\n return grids.map((g, i) => gridOf(g, values[i] ?? new Float32Array()));\n }\n\n /**\n * The workers decoding the relief and reprojecting rasters: the shared pool, unless the map has no workers\n * (`workers: false` or 0, or none in this browser): that is done in the page then\n */\n private decodingPool(): BasemapWorkers | undefined {\n const workers = this.workers;\n\n if (this.gone() || workers === false || (workers !== undefined && workers <= 0)) return undefined;\n if (typeof Worker === 'undefined' || typeof OffscreenCanvas === 'undefined') return undefined;\n\n return this.pool().pool;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"workers.js","sourceRoot":"","sources":["../../src/map/workers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,oBAAoB,EAAwC,MAAM,uBAAuB,CAAC;AACnG,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,C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B,CAAC;CACF","sourcesContent":["/**\n * A map's workers: the pool drawing vector tiles, shared by the map's `VectorTiles`, which also decodes the relief and\n * reprojects rasters off the page; and the loaders of the relief, one per tile source.\n */\n\nimport type { RemoteReprojection } from '../basemap/grid.ts';\nimport { encodedTerrainLoader, type PngEncoding, type RemoteHeights } from '../basemap/terrain.ts';\nimport { BasemapWorkers, defaultWorkerCount } from '../basemap/workerpool.ts';\nimport { decodeGrids } from '../grid-module.ts';\nimport { type Grid, gridOf } from '../grids.ts';\nimport type { TerrainLoader } from '../settings.ts';\nimport type { GeoMapOptions } from '../types.ts';\nimport { fetchOk } from '../util/fetch.ts';\nimport { withHeaders } from '../util/requests.ts';\n\n/** The workers of a map, created on first use */\nexport class MapWorkers {\n /** URL of the workers' script */\n readonly url: string | URL;\n private readonly workers: GeoMapOptions['workers'];\n /** The map is destroyed: nothing more is sent to the workers */\n private readonly gone: () => boolean;\n /** Whose requests the workers' answer (cancelled together) */\n private readonly owner: object;\n /** The shared pool, created on first use */\n private shared: BasemapWorkers | undefined;\n /** The loaders of the relief by encoding, URL and floor: the same loader for the same tiles (the engine keeps its\n * tiles when only the exaggeration changes) */\n private readonly terrainLoaders = new Map<string, TerrainLoader>();\n\n /** `workers`: the map's option (false or 0, no worker); `owner`: the map */\n constructor(url: string | URL, workers: GeoMapOptions['workers'], gone: () => boolean, owner: object) {\n this.url = url;\n this.workers = workers;\n this.gone = gone;\n this.owner = owner;\n }\n\n /**\n * The workers for a `VectorTiles`: the shared pool, or a pool of its own (`own`, to stop with it) when it asks for\n * another count or URL\n */\n pool(count?: number, url?: string | URL): { pool: BasemapWorkers; own: boolean } {\n // Workers started after the map went would never be stopped\n if (this.gone()) throw new Error('isard: the map was destroyed');\n\n const shared = defaultWorkerCount();\n const workers = Math.max(1, count ?? shared);\n const workerUrl = url ?? this.url;\n\n if (workers === shared && String(workerUrl) === String(this.url)) {\n this.shared ??= new BasemapWorkers(shared, this.url);\n\n return { pool: this.shared, own: false };\n }\n\n return { pool: new BasemapWorkers(workers, workerUrl), own: true };\n }\n\n /** Stops the shared pool */\n terminate(): void {\n this.shared?.terminate();\n this.shared = undefined;\n }\n\n /** Rasters reprojected by the workers (in the page without them) */\n readonly remoteReprojection: RemoteReprojection = (job, tile, signal) =>\n this.decodingPool()?.reproject(job, tile, signal, this.owner);\n\n /** The loader of the relief tiles of `url` in a PNG encoding (one per URL, encoding and floor) */\n readonly terrainLoader = (url: string, encoding: PngEncoding, floor?: number): TerrainLoader => {\n const key = `${encoding} ${floor ?? ''} ${url}`;\n const cached = this.terrainLoaders.get(key);\n\n if (cached) return cached;\n\n const loader = encodedTerrainLoader(url, encoding, floor, this.remoteHeights);\n\n this.terrainLoaders.set(key, loader);\n\n return loader;\n };\n\n private readonly remoteHeights: RemoteHeights = (url, encoding, floor, tile, signal) =>\n this.decodingPool()?.heights(url, encoding, floor, tile, signal, this.owner);\n\n /** A GRIB2 or NetCDF file read into grids by the grid module (`module`), in a worker (in the page without them, or if\n * the worker fails) */\n async readGrids(\n source: string | URL | ArrayBuffer | Uint8Array,\n module: string,\n signal?: AbortSignal,\n ): Promise<Grid[]> {\n const pool = this.decodingPool();\n const url = typeof source === 'string' || source instanceof URL ? String(source) : undefined;\n const copy = source instanceof Uint8Array ? source.slice().buffer : undefined;\n const bytes = copy ?? (source instanceof ArrayBuffer ? source : undefined);\n // Against the page: the workers fetch it, and a relative URL would be theirs\n const absolute = url && typeof document !== 'undefined' ? new URL(url, document.baseURI).href : url;\n const fetchFile = async (at: string) => {\n const response = await fetchOk(at, withHeaders(at, signal ? { signal } : {}));\n\n return response.arrayBuffer();\n };\n const inPage = async () => decodeGrids(new Uint8Array(bytes ?? (await fetchFile(absolute ?? ''))), module);\n const read = async () => {\n if (!pool) return inPage();\n\n return pool\n .grids(absolute ? { url: absolute } : { bytes: bytes ?? new ArrayBuffer(0) }, module, signal, this.owner)\n .catch((error: unknown) => {\n // A worker's failure (the module not fetched, a worker of an older build): read again in the page, unless\n // cancelled or its bytes handed over\n if (signal?.aborted || bytes?.byteLength === 0) throw error;\n\n return inPage();\n });\n };\n const { grids, values } = await read();\n\n return grids.map((g, i) => gridOf(g, values[i] ?? new Float32Array()));\n }\n\n /**\n * The workers decoding the relief and reprojecting rasters: the shared pool, unless the map has no workers\n * (`workers: false` or 0, or none in this browser): that is done in the page then\n */\n private decodingPool(): BasemapWorkers | undefined {\n const workers = this.workers;\n\n if (this.gone() || workers === false || (workers !== undefined && workers <= 0)) return undefined;\n if (typeof Worker === 'undefined' || typeof OffscreenCanvas === 'undefined') return undefined;\n\n return this.pool().pool;\n }\n}\n"]}
|
package/dist/map.d.ts
CHANGED
|
@@ -8,19 +8,25 @@
|
|
|
8
8
|
import { type PmtilesOptions } from './basemap/pmtileslayer.ts';
|
|
9
9
|
import { VectorTiles, type VectorTilesOptions } from './basemap/vectortiles.ts';
|
|
10
10
|
import type { Grid } from './grids.ts';
|
|
11
|
+
import { CustomLayer, type CustomLayerInterface } from './layers/custom.ts';
|
|
11
12
|
import { ExtrusionLayer, type ExtrusionOptions } from './layers/extrusions.ts';
|
|
12
13
|
import { CircleLayer, type CircleOptions, FillLayer, type FillOptions, LineLayer, type LineOptions } from './layers/features.ts';
|
|
13
14
|
import { FlowLayer, type FlowOptions } from './layers/flow.ts';
|
|
15
|
+
import { GroundLayer, type GroundOptions } from './layers/ground.ts';
|
|
14
16
|
import type { ImageOptions, Pixels } from './layers/icons.ts';
|
|
15
|
-
import
|
|
17
|
+
import type { Layer } from './layers/layers.ts';
|
|
18
|
+
import { ModelLayer, type ModelOptions } from './layers/models.ts';
|
|
19
|
+
import { NetworkLayer } from './layers/network.ts';
|
|
16
20
|
import { type PanoramaOptions, type Panoramas } from './layers/panoramas.ts';
|
|
17
21
|
import { type PhotoOptions } from './layers/photos.ts';
|
|
18
22
|
import { PointCloudLayer, type PointCloudOptions } from './layers/pointclouds.ts';
|
|
23
|
+
import { RasterLayer } from './layers/raster.ts';
|
|
19
24
|
import { SymbolLayer, type SymbolOptions } from './layers/symbols.ts';
|
|
25
|
+
import { Tiles3dLayer } from './layers/tiles3d.ts';
|
|
20
26
|
import { type TreeOptions } from './layers/trees.ts';
|
|
21
27
|
import { type HoverPicking } from './map/hover-pick.ts';
|
|
22
28
|
import { type LayerSpec } from './map/layer-spec.ts';
|
|
23
|
-
import type { AnimationOptions, AtmosphereOptions, Basemap, FeatureHit, FirstPersonView, FlyToOptions, GeoMapOptions, LoadingMode, LonLat, MapEvents, NetworkOptions, Point, Projection, RasterOptions, SunOptions, SwipeOptions, TerrainModel, TerrainOptions, Tiles3dOptions, ViewshedOptions } from './types.ts';
|
|
29
|
+
import type { AnimationOptions, AtmosphereOptions, Basemap, FeatureHit, FirstPersonView, FlyToOptions, GeoMapOptions, LoadingMode, LonLat, MapEvents, NetworkOptions, PickOptions, Point, Projection, RasterOptions, SunOptions, SwipeOptions, TerrainModel, TerrainOptions, Tiles3dOptions, ViewshedOptions } from './types.ts';
|
|
24
30
|
import { type Control, type ControlPosition } from './ui/controls.ts';
|
|
25
31
|
import type { Camera, PickHit, RasterLayerStats } from './wasm/isard.js';
|
|
26
32
|
export type { LayerSpec } from './map/layer-spec.ts';
|
|
@@ -108,44 +114,6 @@ export declare class GeoMap {
|
|
|
108
114
|
private addLayer;
|
|
109
115
|
/** Listens to an event; returns the function that stops listening */
|
|
110
116
|
on<K extends keyof MapEvents>(type: K, listener: (event: MapEvents[K]) => void): () => void;
|
|
111
|
-
/**
|
|
112
|
-
* The camera's methods together: `get`, `set`, `easeTo`, `flyTo`, `bounds`, `firstPerson` and `setFirstPerson`
|
|
113
|
-
* (street level), `project`, `unproject`; the same as the map's own (`getCamera`, `setCamera`…)
|
|
114
|
-
*/
|
|
115
|
-
readonly camera: {
|
|
116
|
-
readonly get: () => Camera;
|
|
117
|
-
readonly set: (camera: Partial<Camera>) => void;
|
|
118
|
-
readonly easeTo: (camera: Partial<Camera>, options?: number | AnimationOptions) => void;
|
|
119
|
-
readonly flyTo: (camera: Partial<Camera>, options?: FlyToOptions) => void;
|
|
120
|
-
readonly bounds: () => [west: number, south: number, east: number, north: number];
|
|
121
|
-
readonly firstPerson: () => Readonly<Required<FirstPersonView>> | undefined;
|
|
122
|
-
readonly setFirstPerson: (view: FirstPersonView | undefined) => void;
|
|
123
|
-
readonly project: (lonLat: LonLat, height?: number) => Point | undefined;
|
|
124
|
-
readonly unproject: (point: Point) => LonLat | undefined;
|
|
125
|
-
};
|
|
126
|
-
/**
|
|
127
|
-
* What lies under a point or at a position, together: `feature` (`pickFeature`), `surface` (`pickSurface`),
|
|
128
|
-
* `surfaceAt`, `elevationAt`, `metersPerPixel`
|
|
129
|
-
*/
|
|
130
|
-
readonly query: {
|
|
131
|
-
readonly feature: (point: Point, options?: {
|
|
132
|
-
radius?: number;
|
|
133
|
-
layers?: readonly Layer[];
|
|
134
|
-
}) => FeatureHit | undefined;
|
|
135
|
-
readonly surface: (point: Point) => {
|
|
136
|
-
lonLat: LonLat;
|
|
137
|
-
height: number;
|
|
138
|
-
} | undefined;
|
|
139
|
-
readonly surfaceAt: (lonLat: LonLat) => number | undefined;
|
|
140
|
-
readonly elevationAt: (lonLat: LonLat) => number | undefined;
|
|
141
|
-
readonly metersPerPixel: (point?: Point) => number | undefined;
|
|
142
|
-
};
|
|
143
|
-
/** What is drawn over the scene, together: `viewshed` (`setViewshed`), `sun` (`setSun`), `swipe` (`setSwipe`) */
|
|
144
|
-
readonly effects: {
|
|
145
|
-
readonly viewshed: (options: ViewshedOptions | readonly ViewshedOptions[] | undefined) => void;
|
|
146
|
-
readonly sun: (options: SunOptions | undefined) => void;
|
|
147
|
-
readonly swipe: (options: SwipeOptions | undefined) => void;
|
|
148
|
-
};
|
|
149
117
|
getCamera(): Camera;
|
|
150
118
|
setCamera(camera: Partial<Camera>): void;
|
|
151
119
|
/** Animated move to a camera: over `duration` milliseconds (or the options), ease-out by default */
|
|
@@ -201,16 +169,13 @@ export declare class GeoMap {
|
|
|
201
169
|
* offscreen picking pass, whatever the number of features, but waits for the GPU to finish the frame (a stall): for
|
|
202
170
|
* clicks and one-off queries. On hover, listen to 'hoverfeature' instead, which picks without waiting.
|
|
203
171
|
*/
|
|
204
|
-
pick(point: Point, radius
|
|
172
|
+
pick(point: Point, { radius, layers }?: PickOptions): PickHit | undefined;
|
|
205
173
|
/**
|
|
206
174
|
* The feature under a screen point (CSS pixels), or the nearest one within `radius` pixels: its layer handle, its
|
|
207
175
|
* index there and, for line, circle and fill layers, the feature itself; undefined if none. `layers` restricts the
|
|
208
176
|
* search to some layers (the others hide nothing).
|
|
209
177
|
*/
|
|
210
|
-
pickFeature(point: Point, options?:
|
|
211
|
-
radius?: number;
|
|
212
|
-
layers?: readonly Layer[];
|
|
213
|
-
}): FeatureHit | undefined;
|
|
178
|
+
pickFeature(point: Point, options?: PickOptions): FeatureHit | undefined;
|
|
214
179
|
/** A hit with its layer handle and feature; undefined if the layer is gone */
|
|
215
180
|
private featureHit;
|
|
216
181
|
/** Screen point (CSS pixels) of a position on the ground (the relief), or `height` metres above it, undefined
|
|
@@ -252,16 +217,14 @@ export declare class GeoMap {
|
|
|
252
217
|
setBasemap(basemap: Basemap, hillshade?: number): void;
|
|
253
218
|
/** Raster tiles ({z}, {x}, {y} URL; Web Mercator, or reprojected from another `grid`: longitudes and latitudes,
|
|
254
219
|
* Lambert-93, UTM…), over the layers already added */
|
|
255
|
-
addRaster(options: RasterOptions
|
|
256
|
-
before?: Layer;
|
|
257
|
-
}): RasterLayer;
|
|
220
|
+
addRaster(options: RasterOptions): RasterLayer;
|
|
258
221
|
/**
|
|
259
222
|
* A PMTiles archive (v3) read by range requests: a raster layer of its images, or vector tiles drawn with `style` (by
|
|
260
223
|
* default a plain style of the archive's layers) with their labels. Its header decides which unless `kind` says;
|
|
261
224
|
* `url` with or without `pmtiles://`, relative to the page, or a `blob:` URL. `addRaster({ url: 'pmtiles://…' })` and
|
|
262
225
|
* a style source `pmtiles://…` in `vectorTiles` read archives too
|
|
263
226
|
*/
|
|
264
|
-
addPmtiles(
|
|
227
|
+
addPmtiles(options: PmtilesOptions): Promise<RasterLayer | VectorTiles>;
|
|
265
228
|
/** Line network colored by a value per node; `layer.setValues` recolors it in one texture upload */
|
|
266
229
|
addNetwork(options: NetworkOptions): NetworkLayer;
|
|
267
230
|
/**
|
|
@@ -277,9 +240,7 @@ export declare class GeoMap {
|
|
|
277
240
|
/** Filled polygons from GeoJSON (holes included), styled per feature; over the relief they lie on the ground */
|
|
278
241
|
addFills<P = Record<string, unknown>>(options: FillOptions<P>): FillLayer<P>;
|
|
279
242
|
/** The application's fragment shader over the ground (see `GroundOptions`); under `before` if given */
|
|
280
|
-
addGround(options: GroundOptions
|
|
281
|
-
before?: Layer;
|
|
282
|
-
}): GroundLayer;
|
|
243
|
+
addGround(options: GroundOptions): GroundLayer;
|
|
283
244
|
/** Polygons raised into blocks with depth (buildings), styled per feature; tiles of them come with `setTile` */
|
|
284
245
|
addExtrusions<P = Record<string, unknown>>(options?: ExtrusionOptions<P>): ExtrusionLayer<P>;
|
|
285
246
|
/** Text labels from GeoJSON (points, the middle of lines, the center of polygons), placed without overlaps */
|
|
@@ -310,9 +271,7 @@ export declare class GeoMap {
|
|
|
310
271
|
* A point cloud (see `PointCloudOptions`): a COPC file read by range requests (IGN's LiDAR HD…), or 3D Tiles
|
|
311
272
|
* points; with depth, on the engine with 3D Tiles; under `before` if given
|
|
312
273
|
*/
|
|
313
|
-
addPointCloud(options: PointCloudOptions
|
|
314
|
-
before?: Layer;
|
|
315
|
-
}): PointCloudLayer;
|
|
274
|
+
addPointCloud(options: PointCloudOptions): PointCloudLayer;
|
|
316
275
|
/**
|
|
317
276
|
* The grids of a GRIB2 or classic NetCDF file (its URL, or its bytes): a weather or ocean model's fields on grids of
|
|
318
277
|
* longitudes and latitudes, read in a worker by the grid module (loaded with the first file). GRIB2 on a regular
|
|
@@ -326,9 +285,7 @@ export declare class GeoMap {
|
|
|
326
285
|
* the globe and the relief (see `FlowOptions`) */
|
|
327
286
|
addFlow(options: FlowOptions): FlowLayer;
|
|
328
287
|
/** A glTF model drawn at positions (see `ModelOptions`), with depth; on the engine with 3D Tiles, as they are */
|
|
329
|
-
addModels(options: ModelOptions
|
|
330
|
-
before?: Layer;
|
|
331
|
-
}): ModelLayer;
|
|
288
|
+
addModels(options: ModelOptions): ModelLayer;
|
|
332
289
|
/** Trees at the points of a source that has them (a city's street trees), broadleaved or conifers by their data,
|
|
333
290
|
* scaled to their height (see `TreeOptions`); the conifers on a layer that goes with the one returned */
|
|
334
291
|
addTrees<P = Record<string, unknown>>(options: TreeOptions<P>): ModelLayer;
|
package/dist/map.js
CHANGED
|
@@ -9,17 +9,21 @@ import { SEA } from "./basemap/basemaps.js";
|
|
|
9
9
|
import { pmtilesLayer } from "./basemap/pmtileslayer.js";
|
|
10
10
|
import { VectorTiles } from "./basemap/vectortiles.js";
|
|
11
11
|
import { defaultWorkerUrl } from "./basemap/workerpool.js";
|
|
12
|
-
import { onHeaderRules } from "./engine/requests.js";
|
|
13
12
|
import { destroyedEngine, engineUrl, gridUrl, loadEngine, tessUrl } from "./engine-loader.js";
|
|
14
13
|
import { IGN_PRESETS } from "./geoplateforme.js";
|
|
14
|
+
import { CustomLayer } from "./layers/custom.js";
|
|
15
15
|
import { ExtrusionLayer, extrusionStyle } from "./layers/extrusions.js";
|
|
16
16
|
import { CircleLayer, circleStyle, FillLayer, fillStyle, LineLayer, lineStyle, } from "./layers/features.js";
|
|
17
17
|
import { FlowLayer } from "./layers/flow.js";
|
|
18
|
-
import {
|
|
18
|
+
import { GroundLayer } from "./layers/ground.js";
|
|
19
|
+
import { ModelLayer } from "./layers/models.js";
|
|
20
|
+
import { NetworkLayer } from "./layers/network.js";
|
|
19
21
|
import { loadPanoramas } from "./layers/panoramas.js";
|
|
20
22
|
import { addPhoto } from "./layers/photos.js";
|
|
21
23
|
import { PointCloudLayer } from "./layers/pointclouds.js";
|
|
24
|
+
import { RasterLayer } from "./layers/raster.js";
|
|
22
25
|
import { SymbolLayer, symbolStyle } from "./layers/symbols.js";
|
|
26
|
+
import { Tiles3dLayer } from "./layers/tiles3d.js";
|
|
23
27
|
import { addTrees } from "./layers/trees.js";
|
|
24
28
|
import { VectorLayer } from "./layers/vectors.js";
|
|
25
29
|
import { BasemapLayers } from "./map/basemap-layers.js";
|
|
@@ -43,7 +47,22 @@ import { atmosphereSettings, rgb, terrainSettings } from "./settings.js";
|
|
|
43
47
|
import { AttributionControl } from "./ui/controls.js";
|
|
44
48
|
import { Interaction } from "./ui/interaction.js";
|
|
45
49
|
import { easeTo, flyTo } from "./util/animation.js";
|
|
50
|
+
import { RAD } from "./util/geo.js";
|
|
51
|
+
import { clamp } from "./util/math.js";
|
|
52
|
+
import { onHeaderRules } from "./util/requests.js";
|
|
46
53
|
import { sunPosition } from "./util/sun.js";
|
|
54
|
+
/** Where a map of the Earth opens without a camera given: Saint-Mandé, the IGN's home, its streets in view; of another
|
|
55
|
+
* body, all of it */
|
|
56
|
+
const EARTH_START = { center: [2.4246, 48.8457], zoom: 13, pitch: 0, bearing: 0 };
|
|
57
|
+
const BODY_START = { center: [0, 0], zoom: 2, pitch: 0, bearing: 0 };
|
|
58
|
+
/** The eye's pitch at street level (degrees from straight down): off the vertical, where its heading means nothing */
|
|
59
|
+
const FIRST_PERSON_PITCH = [1, 179];
|
|
60
|
+
/** The eye's field of view at street level (degrees): from a telephoto to a wide angle, the projection still sane */
|
|
61
|
+
const FIRST_PERSON_FOV = [10, 140];
|
|
62
|
+
/** A network's defaults: the values past which it is unreached (half an hour of travel, in seconds), its halo's
|
|
63
|
+
* opacity at the middle of a line (a glow, not a second line) */
|
|
64
|
+
const NETWORK_MAX = 1800;
|
|
65
|
+
const NETWORK_HALO_OPACITY = 0.11;
|
|
47
66
|
/** A layer whose picked features come back with their properties (lines, circles, fills, extrusions, 3D Tiles…) */
|
|
48
67
|
const hasFeatures = (layer) => 'featureAt' in layer && typeof layer.featureAt === 'function';
|
|
49
68
|
/** A map (see `GeoMap.create`); layers take it as their host */
|
|
@@ -154,9 +173,7 @@ export class GeoMap {
|
|
|
154
173
|
this.lost = true;
|
|
155
174
|
this.frames.cancel();
|
|
156
175
|
}, () => this.restore());
|
|
157
|
-
const start = this.earth
|
|
158
|
-
? { center: [2.4246, 48.8457], zoom: 13, pitch: 0, bearing: 0 }
|
|
159
|
-
: { center: [0, 0], zoom: 2, pitch: 0, bearing: 0 };
|
|
176
|
+
const start = this.earth ? EARTH_START : BODY_START;
|
|
160
177
|
this.setCamera({ ...start, ...options });
|
|
161
178
|
this.setBasemap(options.basemap ?? (this.earth ? 'osm-positron' : 'none'), options.hillshade ?? 0);
|
|
162
179
|
if (options.sun)
|
|
@@ -270,8 +287,8 @@ export class GeoMap {
|
|
|
270
287
|
}
|
|
271
288
|
const lonLat = [view.lonLat[0], view.lonLat[1]];
|
|
272
289
|
const eye = { height: 1.7, pitch: 90, fov: 75, ...view, lonLat };
|
|
273
|
-
eye.pitch =
|
|
274
|
-
eye.fov =
|
|
290
|
+
eye.pitch = clamp(eye.pitch, ...FIRST_PERSON_PITCH);
|
|
291
|
+
eye.fov = clamp(eye.fov, ...FIRST_PERSON_FOV);
|
|
275
292
|
eye.bearing = ((eye.bearing % 360) + 360) % 360;
|
|
276
293
|
this.#firstPerson = eye;
|
|
277
294
|
this.engine.setFirstPerson(eye.lonLat[0], eye.lonLat[1], eye.height, eye.bearing, eye.pitch, eye.fov);
|
|
@@ -343,38 +360,6 @@ export class GeoMap {
|
|
|
343
360
|
this.listeners.emit(type, event);
|
|
344
361
|
}
|
|
345
362
|
// ── Camera ──
|
|
346
|
-
/**
|
|
347
|
-
* The camera's methods together: `get`, `set`, `easeTo`, `flyTo`, `bounds`, `firstPerson` and `setFirstPerson`
|
|
348
|
-
* (street level), `project`, `unproject`; the same as the map's own (`getCamera`, `setCamera`…)
|
|
349
|
-
*/
|
|
350
|
-
camera = {
|
|
351
|
-
get: () => this.getCamera(),
|
|
352
|
-
set: (camera) => this.setCamera(camera),
|
|
353
|
-
easeTo: (camera, options) => this.easeTo(camera, options),
|
|
354
|
-
flyTo: (camera, options) => this.flyTo(camera, options),
|
|
355
|
-
bounds: () => this.getBounds(),
|
|
356
|
-
firstPerson: () => this.firstPerson,
|
|
357
|
-
setFirstPerson: (view) => this.setFirstPerson(view),
|
|
358
|
-
project: (lonLat, height) => this.project(lonLat, height),
|
|
359
|
-
unproject: (point) => this.unproject(point),
|
|
360
|
-
};
|
|
361
|
-
/**
|
|
362
|
-
* What lies under a point or at a position, together: `feature` (`pickFeature`), `surface` (`pickSurface`),
|
|
363
|
-
* `surfaceAt`, `elevationAt`, `metersPerPixel`
|
|
364
|
-
*/
|
|
365
|
-
query = {
|
|
366
|
-
feature: (point, options) => this.pickFeature(point, options),
|
|
367
|
-
surface: (point) => this.pickSurface(point),
|
|
368
|
-
surfaceAt: (lonLat) => this.surfaceAt(lonLat),
|
|
369
|
-
elevationAt: (lonLat) => this.elevationAt(lonLat),
|
|
370
|
-
metersPerPixel: (point) => this.metersPerPixel(point),
|
|
371
|
-
};
|
|
372
|
-
/** What is drawn over the scene, together: `viewshed` (`setViewshed`), `sun` (`setSun`), `swipe` (`setSwipe`) */
|
|
373
|
-
effects = {
|
|
374
|
-
viewshed: (options) => this.setViewshed(options),
|
|
375
|
-
sun: (options) => this.setSun(options),
|
|
376
|
-
swipe: (options) => this.setSwipe(options),
|
|
377
|
-
};
|
|
378
363
|
getCamera() {
|
|
379
364
|
return this.frames.camera ?? this.engine.camera();
|
|
380
365
|
}
|
|
@@ -524,7 +509,7 @@ export class GeoMap {
|
|
|
524
509
|
* offscreen picking pass, whatever the number of features, but waits for the GPU to finish the frame (a stall): for
|
|
525
510
|
* clicks and one-off queries. On hover, listen to 'hoverfeature' instead, which picks without waiting.
|
|
526
511
|
*/
|
|
527
|
-
pick(point, radius = 0, layers) {
|
|
512
|
+
pick(point, { radius = 0, layers } = {}) {
|
|
528
513
|
const only = layers && Uint32Array.from(layers.map((l) => l.id));
|
|
529
514
|
return this.engine.pick(point[0], point[1], radius, only);
|
|
530
515
|
}
|
|
@@ -534,7 +519,7 @@ export class GeoMap {
|
|
|
534
519
|
* search to some layers (the others hide nothing).
|
|
535
520
|
*/
|
|
536
521
|
pickFeature(point, options = {}) {
|
|
537
|
-
const hit = this.pick(point, options
|
|
522
|
+
const hit = this.pick(point, options);
|
|
538
523
|
return hit && this.featureHit(hit);
|
|
539
524
|
}
|
|
540
525
|
/** A hit with its layer handle and feature; undefined if the layer is gone */
|
|
@@ -569,6 +554,9 @@ export class GeoMap {
|
|
|
569
554
|
const host = panoramaHost(this, (lon, lat) => this.engines.geoidHeight(lon, lat));
|
|
570
555
|
const panoramas = await loadPanoramas(host, options);
|
|
571
556
|
this.panoramaSets.add(panoramas);
|
|
557
|
+
panoramas.whenRemoved.push(() => {
|
|
558
|
+
this.panoramaSets.delete(panoramas);
|
|
559
|
+
});
|
|
572
560
|
return panoramas;
|
|
573
561
|
}
|
|
574
562
|
/** The panorama sets, their panorama shown again in a new engine */
|
|
@@ -587,9 +575,8 @@ export class GeoMap {
|
|
|
587
575
|
if (!a || !b)
|
|
588
576
|
return undefined;
|
|
589
577
|
// Haversine, on the mean radius of the body
|
|
590
|
-
const
|
|
591
|
-
const
|
|
592
|
-
const h = Math.sin(dLat / 2) ** 2 + Math.cos(a[1] * rad) * Math.cos(b[1] * rad) * Math.sin(dLon / 2) ** 2;
|
|
578
|
+
const [dLat, dLon] = [(b[1] - a[1]) * RAD, (b[0] - a[0]) * RAD];
|
|
579
|
+
const h = Math.sin(dLat / 2) ** 2 + Math.cos(a[1] * RAD) * Math.cos(b[1] * RAD) * Math.sin(dLon / 2) ** 2;
|
|
593
580
|
return 2 * this.settings.body.radius * Math.asin(Math.min(1, Math.sqrt(h)));
|
|
594
581
|
}
|
|
595
582
|
/** Whether a double click zooms in (Shift: out), on by default: off while a drawing takes double clicks */
|
|
@@ -662,16 +649,16 @@ export class GeoMap {
|
|
|
662
649
|
* `url` with or without `pmtiles://`, relative to the page, or a `blob:` URL. `addRaster({ url: 'pmtiles://…' })` and
|
|
663
650
|
* a style source `pmtiles://…` in `vectorTiles` read archives too
|
|
664
651
|
*/
|
|
665
|
-
addPmtiles(
|
|
666
|
-
return pmtilesLayer(this,
|
|
652
|
+
addPmtiles(options) {
|
|
653
|
+
return pmtilesLayer(this, options);
|
|
667
654
|
}
|
|
668
655
|
/** Line network colored by a value per node; `layer.setValues` recolors it in one texture upload */
|
|
669
656
|
addNetwork(options) {
|
|
670
|
-
const { nodes, edges, lines, costs, edgeWidths, width = 2, max =
|
|
671
|
-
const { halo = 0, haloOpacity =
|
|
657
|
+
const { nodes, edges, lines, costs, edgeWidths, width = 2, max = NETWORK_MAX, contour = 0, opacity = 1 } = options;
|
|
658
|
+
const { halo = 0, haloOpacity = NETWORK_HALO_OPACITY, ramp, unreachedColor = 'rgba(140, 140, 140, 0.25)', fade = 0, } = options;
|
|
672
659
|
const style = { width, max, contour, opacity, halo, haloOpacity, ramp, unreachedColor, fade };
|
|
673
660
|
validateNetwork(nodes, edges);
|
|
674
|
-
return this.
|
|
661
|
+
return this.place(new NetworkLayer(this, { nodes, edges, lines }, costs, style, edgeWidths), options.before);
|
|
675
662
|
}
|
|
676
663
|
/**
|
|
677
664
|
* A layer from its description, as an application's configuration gives it: `{ type, ...options }`, the options of
|
|
@@ -804,12 +791,12 @@ export class GeoMap {
|
|
|
804
791
|
/** Textured meshes in 3D Tiles (photogrammetry, buildings), drawn with depth over the basemap */
|
|
805
792
|
addTiles3d(options) {
|
|
806
793
|
const { url, maxScreenSpaceError = 16, opacity = 1, pointSize, color, geoid = false } = options;
|
|
807
|
-
return this.
|
|
794
|
+
return this.place(new Tiles3dLayer(this, url, geoid, {
|
|
808
795
|
maxScreenSpaceError,
|
|
809
796
|
opacity,
|
|
810
797
|
...(pointSize !== undefined ? { pointSize } : {}),
|
|
811
798
|
...(color !== undefined ? { color } : {}),
|
|
812
|
-
}));
|
|
799
|
+
}), options.before);
|
|
813
800
|
}
|
|
814
801
|
/**
|
|
815
802
|
* A point cloud (see `PointCloudOptions`): a COPC file read by range requests (IGN's LiDAR HD…), or 3D Tiles
|
|
@@ -900,7 +887,7 @@ export class GeoMap {
|
|
|
900
887
|
this.hoverPick.cancel();
|
|
901
888
|
this.basemaps.destroy();
|
|
902
889
|
[...this.vectorSets].forEach((tiles) => {
|
|
903
|
-
tiles.
|
|
890
|
+
tiles.remove();
|
|
904
891
|
});
|
|
905
892
|
this.vectorSets.clear();
|
|
906
893
|
this.workers.terminate();
|