isard 1.0.0 → 1.2.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 +51 -0
- package/dist/{basemaps.d.ts → basemap/basemaps.d.ts} +3 -3
- package/dist/{basemaps.js → basemap/basemaps.js} +3 -3
- package/dist/basemap/basemaps.js.map +1 -0
- package/dist/{grid.d.ts → basemap/grid.d.ts} +6 -6
- package/dist/{grid.js → basemap/grid.js} +61 -67
- package/dist/basemap/grid.js.map +1 -0
- package/dist/{mvt.d.ts → basemap/mvt.d.ts} +1 -1
- package/dist/{mvt.js → basemap/mvt.js} +6 -6
- package/dist/basemap/mvt.js.map +1 -0
- package/dist/{pmtiles.d.ts → basemap/pmtiles.d.ts} +16 -10
- package/dist/{pmtiles.js → basemap/pmtiles.js} +41 -33
- package/dist/basemap/pmtiles.js.map +1 -0
- package/dist/{resample.d.ts → basemap/resample.d.ts} +11 -2
- package/dist/{resample.js → basemap/resample.js} +18 -16
- package/dist/basemap/resample.js.map +1 -0
- package/dist/{terrain.d.ts → basemap/terrain.d.ts} +3 -3
- package/dist/{terrain.js → basemap/terrain.js} +7 -7
- package/dist/basemap/terrain.js.map +1 -0
- package/dist/{vectorstyle.d.ts → basemap/vectorstyle.d.ts} +12 -10
- package/dist/{vectorstyle.js → basemap/vectorstyle.js} +129 -111
- package/dist/basemap/vectorstyle.js.map +1 -0
- package/dist/{vectortiles.d.ts → basemap/vectortiles.d.ts} +18 -18
- package/dist/{vectortiles.js → basemap/vectortiles.js} +157 -109
- package/dist/basemap/vectortiles.js.map +1 -0
- package/dist/{wmts.d.ts → basemap/wmts.d.ts} +3 -3
- package/dist/{wmts.js → basemap/wmts.js} +19 -14
- package/dist/basemap/wmts.js.map +1 -0
- package/dist/basemap.worker.js +2 -2
- package/dist/basemap.worker.js.map +14 -13
- package/dist/bind/layers.d.ts +46 -0
- package/dist/bind/layers.js +154 -0
- package/dist/bind/layers.js.map +1 -0
- package/dist/{crs.d.ts → data/crs.d.ts} +11 -11
- package/dist/{crs.js → data/crs.js} +38 -34
- package/dist/data/crs.js.map +1 -0
- package/dist/{gpx.d.ts → data/gpx.d.ts} +2 -2
- package/dist/{gpx.js → data/gpx.js} +20 -20
- package/dist/data/gpx.js.map +1 -0
- package/dist/{kml.d.ts → data/kml.d.ts} +2 -2
- package/dist/{kml.js → data/kml.js} +42 -39
- package/dist/data/kml.js.map +1 -0
- package/dist/{topojson.d.ts → data/topojson.d.ts} +2 -2
- package/dist/{topojson.js → data/topojson.js} +15 -10
- package/dist/data/topojson.js.map +1 -0
- package/dist/{xml.d.ts → data/xml.d.ts} +5 -5
- package/dist/{xml.js → data/xml.js} +19 -18
- package/dist/data/xml.js.map +1 -0
- package/dist/decoder.worker.js +4 -4
- package/dist/decoder.worker.js.map +7 -7
- package/dist/{decoders.d.ts → engine/decoders.d.ts} +3 -3
- package/dist/{decoders.js → engine/decoders.js} +28 -25
- package/dist/engine/decoders.js.map +1 -0
- package/dist/{loader.d.ts → engine/loader.d.ts} +1 -1
- package/dist/{loader.js → engine/loader.js} +17 -14
- package/dist/engine/loader.js.map +1 -0
- package/dist/{protocol.d.ts → engine/protocol.d.ts} +1 -1
- package/dist/engine/protocol.js +3 -0
- package/dist/engine/protocol.js.map +1 -0
- package/dist/{requests.d.ts → engine/requests.d.ts} +1 -1
- package/dist/{requests.js → engine/requests.js} +19 -16
- package/dist/engine/requests.js.map +1 -0
- package/dist/engine-loader.d.ts +13 -9
- package/dist/engine-loader.js +30 -30
- package/dist/engine-loader.js.map +1 -1
- package/dist/formats.d.ts +3 -3
- package/dist/formats.js +3 -3
- package/dist/formats.js.map +1 -1
- package/dist/geoplateforme.d.ts +13 -13
- package/dist/geoplateforme.js +23 -21
- package/dist/geoplateforme.js.map +1 -1
- package/dist/index.d.ts +30 -29
- package/dist/index.js +18 -18
- 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_points_bg.wasm +0 -0
- package/dist/{extrusions.d.ts → layers/extrusions.d.ts} +1 -1
- package/dist/{extrusions.js → layers/extrusions.js} +10 -5
- package/dist/layers/extrusions.js.map +1 -0
- package/dist/{features.d.ts → layers/features.d.ts} +10 -10
- package/dist/{features.js → layers/features.js} +44 -45
- package/dist/layers/features.js.map +1 -0
- package/dist/{glyphs.d.ts → layers/glyphs.d.ts} +6 -6
- package/dist/{glyphs.js → layers/glyphs.js} +45 -41
- package/dist/layers/glyphs.js.map +1 -0
- package/dist/{icons.d.ts → layers/icons.d.ts} +10 -10
- package/dist/{icons.js → layers/icons.js} +84 -69
- package/dist/layers/icons.js.map +1 -0
- package/dist/{layers.d.ts → layers/layers.d.ts} +9 -4
- package/dist/{layers.js → layers/layers.js} +35 -31
- package/dist/layers/layers.js.map +1 -0
- package/dist/{panoramas.d.ts → layers/panoramas.d.ts} +3 -3
- package/dist/{panoramas.js → layers/panoramas.js} +54 -43
- package/dist/layers/panoramas.js.map +1 -0
- package/dist/{pointclouds.d.ts → layers/pointclouds.d.ts} +5 -5
- package/dist/{pointclouds.js → layers/pointclouds.js} +26 -34
- package/dist/layers/pointclouds.js.map +1 -0
- package/dist/{symbols.d.ts → layers/symbols.d.ts} +3 -3
- package/dist/{symbols.js → layers/symbols.js} +69 -72
- package/dist/layers/symbols.js.map +1 -0
- package/dist/map/basemap-layers.d.ts +26 -0
- package/dist/map/basemap-layers.js +61 -0
- package/dist/map/basemap-layers.js.map +1 -0
- package/dist/map/canvas.d.ts +17 -0
- package/dist/map/canvas.js +56 -0
- package/dist/map/canvas.js.map +1 -0
- package/dist/map/checks.d.ts +11 -0
- package/dist/map/checks.js +39 -0
- package/dist/map/checks.js.map +1 -0
- package/dist/map/credits.d.ts +17 -0
- package/dist/map/credits.js +34 -0
- package/dist/map/credits.js.map +1 -0
- package/dist/map/engine-settings.d.ts +15 -0
- package/dist/map/engine-settings.js +45 -0
- package/dist/map/engine-settings.js.map +1 -0
- package/dist/map/engines.d.ts +41 -0
- package/dist/map/engines.js +77 -0
- package/dist/map/engines.js.map +1 -0
- package/dist/map/events.d.ts +14 -0
- package/dist/map/events.js +46 -0
- package/dist/map/events.js.map +1 -0
- package/dist/map/frame-loop.d.ts +61 -0
- package/dist/map/frame-loop.js +139 -0
- package/dist/map/frame-loop.js.map +1 -0
- package/dist/map/hover-pick.d.ts +30 -0
- package/dist/map/hover-pick.js +56 -0
- package/dist/map/hover-pick.js.map +1 -0
- package/dist/map/layer-spec.d.ts +42 -0
- package/dist/map/layer-spec.js +34 -0
- package/dist/map/layer-spec.js.map +1 -0
- package/dist/map/layer-stack.d.ts +36 -0
- package/dist/map/layer-stack.js +101 -0
- package/dist/map/layer-stack.js.map +1 -0
- package/dist/map/overlay-host.d.ts +36 -0
- package/dist/map/overlay-host.js +101 -0
- package/dist/map/overlay-host.js.map +1 -0
- package/dist/map/panorama-host.d.ts +5 -0
- package/dist/map/panorama-host.js +32 -0
- package/dist/map/panorama-host.js.map +1 -0
- package/dist/map/raster-source.d.ts +11 -0
- package/dist/map/raster-source.js +26 -0
- package/dist/map/raster-source.js.map +1 -0
- package/dist/map/symbol-atlases.d.ts +26 -0
- package/dist/map/symbol-atlases.js +59 -0
- package/dist/map/symbol-atlases.js.map +1 -0
- package/dist/map/viewshed.d.ts +5 -0
- package/dist/map/viewshed.js +28 -0
- package/dist/map/viewshed.js.map +1 -0
- package/dist/map/workers.d.ts +46 -0
- package/dist/map/workers.js +73 -0
- package/dist/map/workers.js.map +1 -0
- package/dist/map.d.ts +46 -127
- package/dist/map.js +183 -698
- package/dist/map.js.map +1 -1
- package/dist/projections.d.ts +3 -3
- package/dist/projections.js +2 -2
- package/dist/projections.js.map +1 -1
- package/dist/react/Control.d.ts +11 -0
- package/dist/react/Control.js +18 -0
- package/dist/react/Control.js.map +1 -0
- package/dist/react/CustomLayer.d.ts +11 -0
- package/dist/react/CustomLayer.js +30 -0
- package/dist/react/CustomLayer.js.map +1 -0
- package/dist/react/IsardMap.d.ts +43 -0
- package/dist/react/IsardMap.js +146 -0
- package/dist/react/IsardMap.js.map +1 -0
- package/dist/react/Layer.d.ts +42 -0
- package/dist/react/Layer.js +74 -0
- package/dist/react/Layer.js.map +1 -0
- package/dist/react/Marker.d.ts +24 -0
- package/dist/react/Marker.js +53 -0
- package/dist/react/Marker.js.map +1 -0
- package/dist/react/Panel.d.ts +11 -0
- package/dist/react/Panel.js +37 -0
- package/dist/react/Panel.js.map +1 -0
- package/dist/react/Popup.d.ts +18 -0
- package/dist/react/Popup.js +60 -0
- package/dist/react/Popup.js.map +1 -0
- package/dist/react/Swipe.d.ts +9 -0
- package/dist/react/Swipe.js +41 -0
- package/dist/react/Swipe.js.map +1 -0
- package/dist/react/Viewshed.d.ts +5 -0
- package/dist/react/Viewshed.js +28 -0
- package/dist/react/Viewshed.js.map +1 -0
- package/dist/react/context.d.ts +32 -0
- package/dist/react/context.js +20 -0
- package/dist/react/context.js.map +1 -0
- package/dist/react/index.d.ts +26 -0
- package/dist/react/index.js +22 -0
- package/dist/react/index.js.map +1 -0
- package/dist/settings.d.ts +6 -10
- package/dist/settings.js +19 -17
- package/dist/settings.js.map +1 -1
- package/dist/types.d.ts +8 -8
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -1
- package/dist/{controls.d.ts → ui/controls.d.ts} +1 -1
- package/dist/{controls.js → ui/controls.js} +6 -4
- package/dist/ui/controls.js.map +1 -0
- package/dist/{interaction.d.ts → ui/interaction.d.ts} +9 -5
- package/dist/{interaction.js → ui/interaction.js} +9 -8
- package/dist/ui/interaction.js.map +1 -0
- package/dist/{overlay.d.ts → ui/overlay.d.ts} +2 -2
- package/dist/{overlay.js → ui/overlay.js} +18 -20
- package/dist/ui/overlay.js.map +1 -0
- package/dist/{style.d.ts → ui/style.d.ts} +1 -1
- package/dist/{style.js → ui/style.js} +2 -2
- package/dist/ui/style.js.map +1 -0
- package/dist/{animation.d.ts → util/animation.d.ts} +9 -5
- package/dist/{animation.js → util/animation.js} +6 -6
- package/dist/util/animation.js.map +1 -0
- package/dist/{color.d.ts → util/color.d.ts} +1 -1
- package/dist/{color.js → util/color.js} +14 -16
- package/dist/util/color.js.map +1 -0
- package/dist/{geo.d.ts → util/geo.d.ts} +6 -6
- package/dist/{geo.js → util/geo.js} +12 -12
- package/dist/util/geo.js.map +1 -0
- package/dist/util/guards.d.ts +7 -0
- package/dist/util/guards.js +8 -0
- package/dist/util/guards.js.map +1 -0
- package/dist/util/lru.js.map +1 -0
- package/dist/wasm/isard.d.ts +168 -0
- package/dist/wasm/isard.js +146 -0
- package/dist/wasm/isard_core.d.ts +144 -0
- package/dist/wasm/isard_core.js +122 -0
- package/dist/{basemap.worker.d.ts → workers/basemap.worker.d.ts} +17 -7
- package/dist/workers/basemap.worker.js +658 -0
- package/dist/workers/basemap.worker.js.map +1 -0
- package/package.json +24 -1
- package/vite.js +1 -1
- package/dist/animation.js.map +0 -1
- package/dist/basemaps.js.map +0 -1
- package/dist/color.js.map +0 -1
- package/dist/controls.js.map +0 -1
- package/dist/crs.js.map +0 -1
- package/dist/decoders.js.map +0 -1
- package/dist/extrusions.js.map +0 -1
- package/dist/features.js.map +0 -1
- package/dist/geo.js.map +0 -1
- package/dist/glyphs.js.map +0 -1
- package/dist/gpx.js.map +0 -1
- package/dist/grid.js.map +0 -1
- package/dist/icons.js.map +0 -1
- package/dist/interaction.js.map +0 -1
- package/dist/kml.js.map +0 -1
- package/dist/layers.js.map +0 -1
- package/dist/loader.js.map +0 -1
- package/dist/lru.js.map +0 -1
- package/dist/mvt.js.map +0 -1
- package/dist/overlay.js.map +0 -1
- package/dist/panoramas.js.map +0 -1
- package/dist/pmtiles.js.map +0 -1
- package/dist/pointclouds.js.map +0 -1
- package/dist/protocol.js +0 -2
- package/dist/protocol.js.map +0 -1
- package/dist/requests.js.map +0 -1
- package/dist/resample.js.map +0 -1
- package/dist/style.js.map +0 -1
- package/dist/symbols.js.map +0 -1
- package/dist/terrain.js.map +0 -1
- package/dist/topojson.js.map +0 -1
- package/dist/vectorstyle.js.map +0 -1
- package/dist/vectortiles.js.map +0 -1
- package/dist/wmts.js.map +0 -1
- package/dist/xml.js.map +0 -1
- /package/dist/{lru.d.ts → util/lru.d.ts} +0 -0
- /package/dist/{lru.js → util/lru.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overlay-host.js","sourceRoot":"","sources":["../../src/map/overlay-host.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,MAAM,OAAO,GAA+B,CAAC,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,cAAc,CAAC,CAAC;AAErG,kHAAkH;AAClH,MAAM,OAAO,WAAW;IACtB,2FAA2F;IAC3F,IAAI,GAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACJ,SAAS,CAAc;IACvB,MAAM,CAAoB;IAC3C,wCAAwC;IACvB,GAAG,CAAS;IAC7B,0CAA0C;IACzB,OAAO,CAAiB;IACxB,OAAO,CAA0C;IACjD,QAAQ,GAAG,IAAI,GAAG,EAAwB,CAAC;IAC3C,UAAU,GAAG,IAAI,GAAG,EAAc,CAAC;IAEpD,kEAAkE;IAClE,YAAY,SAAsB,EAAE,MAAyB,EAAE,GAAW;QACxE,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,6DAA6D;QAC7D,WAAW,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;QACrC,IAAI,gBAAgB,CAAC,SAAS,CAAC,CAAC,QAAQ,KAAK,QAAQ;YAAE,SAAS,CAAC,KAAK,CAAC,QAAQ,GAAG,UAAU,CAAC;QAC7F,SAAS,CAAC,SAAS,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QACrC,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC,aAAa,C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AC,OAAO,EAAE,EAAE;YAC5C,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAC9B,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;QACxB,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QACrB,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;QACtB,OAAO,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;YAC3B,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,EAAE,CAAC;QAClC,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAC/C,CAAC;CACF","sourcesContent":["/**\n * What the map shows over its canvas, in its container: the markers and popups (placed after every frame) and the\n * controls in the four corners.\n */\n\nimport type { GeoMap } from '../map.ts';\nimport type { Point } from '../types.ts';\nimport type { Control, ControlPosition } from '../ui/controls.ts';\nimport type { Positioned } from '../ui/overlay.ts';\nimport { injectStyle } from '../ui/style.ts';\n\nconst CORNERS: readonly ControlPosition[] = ['top-left', 'top-right', 'bottom-left', 'bottom-right'];\n\n/** The map's container: its canvas, the element of the markers and popups over it, the corners of the controls */\nexport class OverlayHost {\n /** Canvas size in CSS pixels, kept on resize so placing overlays never reads the layout */\n size: Point = [0, 0];\n private readonly container: HTMLElement;\n private readonly canvas: HTMLCanvasElement;\n /** The map the controls are added to */\n private readonly map: GeoMap;\n /** Markers and popups, over the canvas */\n private readonly overlay: HTMLDivElement;\n private readonly corners: Record<ControlPosition, HTMLDivElement>;\n private readonly controls = new Map<Control, HTMLElement>();\n private readonly positioned = new Set<Positioned>();\n\n /** Puts the canvas, the overlay and the corners in `container` */\n constructor(container: HTMLElement, canvas: HTMLCanvasElement, map: GeoMap) {\n this.container = container;\n this.canvas = canvas;\n this.map = map;\n // Overlays and controls are positioned against the container\n injectStyle(container.ownerDocument);\n if (getComputedStyle(container).position === 'static') container.style.position = 'relative';\n container.classList.add('isard-map');\n this.overlay = document.createElement('div');\n this.overlay.className = 'isard-overlay';\n\n const corner = (position: ControlPosition) => {\n const element = document.createElement('div');\n\n element.className = `isard-ctrl-${position}`;\n\n return element;\n };\n\n this.corners = {\n 'top-left': corner('top-left'),\n 'top-right': corner('top-right'),\n 'bottom-left': corner('bottom-left'),\n 'bottom-right': corner('bottom-right'),\n };\n container.append(canvas, this.overlay, ...CORNERS.map((position) => this.corners[position]));\n }\n\n /** Adds a control in a corner; controls stack from the corner inward */\n addControl(control: Control, position: ControlPosition): void {\n if (this.controls.has(control)) return;\n\n const element = control.onAdd(this.map);\n\n element.classList.add('isard-ctrl');\n // In the bottom corners the first control added stays lowest, as in MapLibre\n if (position.startsWith('bottom')) this.corners[position].prepend(element);\n else this.corners[position].append(element);\n this.controls.set(control, element);\n }\n\n removeControl(control: Control): void {\n const element = this.controls.get(control);\n\n if (!element) return;\n this.controls.delete(control);\n control.onRemove(this.map);\n element.remove();\n }\n\n /** Shows a marker or popup, placed after every frame from now on */\n attach(item: Positioned, element: HTMLElement): void {\n this.overlay.append(element);\n this.positioned.add(item);\n item.position(this.size);\n }\n\n detach(item: Positioned, element: HTMLElement): void {\n this.positioned.delete(item);\n element.remove();\n }\n\n /** Places one overlay now (it moved) */\n position(item: Positioned): void {\n if (this.positioned.has(item)) item.position(this.size);\n }\n\n /** Places every overlay for the frame just drawn (camera, relief altitudes): all in one pass, transforms only */\n positionAll(): void {\n this.positioned.forEach((item) => {\n item.position(this.size);\n });\n }\n\n /** Removes the controls, then the canvas, the overlay and the corners from the container */\n destroy(): void {\n [...this.controls.keys()].forEach((control) => {\n this.removeControl(control);\n });\n this.positioned.clear();\n this.canvas.remove();\n this.overlay.remove();\n CORNERS.forEach((position) => {\n this.corners[position].remove();\n });\n this.container.classList.remove('isard-map');\n }\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** What the street-level panoramas need of the map: its engine, its street-level eye, its clicks, keys and wheel. */
|
|
2
|
+
import type { PanoramaHost } from '../layers/panoramas.ts';
|
|
3
|
+
import type { GeoMap } from '../map.ts';
|
|
4
|
+
/** The panoramas' host on a map; `geoidHeight` from the class of the map's engine */
|
|
5
|
+
export declare const panoramaHost: (map: GeoMap, geoidHeight: (lon: number, lat: number) => number) => PanoramaHost;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** What the street-level panoramas need of the map: its engine, its street-level eye, its clicks, keys and wheel. */
|
|
2
|
+
/** The panoramas' host on a map; `geoidHeight` from the class of the map's engine */
|
|
3
|
+
export const panoramaHost = (map, geoidHeight) => ({
|
|
4
|
+
setPanorama: (...args) => {
|
|
5
|
+
map.engine.setPanorama(...args);
|
|
6
|
+
map.requestRender();
|
|
7
|
+
},
|
|
8
|
+
setPanoramaImage: (index, image) => map.engine.setPanoramaImage(index, image),
|
|
9
|
+
clearPanorama: () => map.engine.clearPanorama(),
|
|
10
|
+
geoidHeight,
|
|
11
|
+
firstPerson: () => map.firstPerson,
|
|
12
|
+
setFirstPerson: (view) => map.setFirstPerson(view),
|
|
13
|
+
elevationAt: (lonLat) => map.elevationAt(lonLat),
|
|
14
|
+
listen: (click, key, wheel) => {
|
|
15
|
+
const off = map.on('click', ({ lonLat }) => click(lonLat));
|
|
16
|
+
const container = map.getContainer();
|
|
17
|
+
// Before the map's own wheel (its zoom, the eye's field of view)
|
|
18
|
+
const onWheel = (e) => {
|
|
19
|
+
e.preventDefault();
|
|
20
|
+
e.stopImmediatePropagation();
|
|
21
|
+
wheel(e);
|
|
22
|
+
};
|
|
23
|
+
container.addEventListener('keydown', key);
|
|
24
|
+
container.addEventListener('wheel', onWheel, { capture: true, passive: false });
|
|
25
|
+
return () => {
|
|
26
|
+
off();
|
|
27
|
+
container.removeEventListener('keydown', key);
|
|
28
|
+
container.removeEventListener('wheel', onWheel, { capture: true });
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
//# sourceMapp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;YAC7B,KAAK,CAAC,CAAC,CAAC,CAAC;QACX,CAAC,CAAC;QAEF,SAAS,CAAC,gBAAgB,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;QAC3C,SAAS,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;QAEhF,OAAO,GAAG,EAAE;YACV,GAAG,EAAE,CAAC;YACN,SAAS,CAAC,mBAAmB,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;YAC9C,SAAS,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QACrE,CAAC,CAAC;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["/** What the street-level panoramas need of the map: its engine, its street-level eye, its clicks, keys and wheel. */\n\nimport type { PanoramaHost } from '../layers/panoramas.ts';\nimport type { GeoMap } from '../map.ts';\n\n/** The panoramas' host on a map; `geoidHeight` from the class of the map's engine */\nexport const panoramaHost = (map: GeoMap, geoidHeight: (lon: number, lat: number) => number): PanoramaHost => ({\n setPanorama: (...args) => {\n map.engine.setPanorama(...args);\n map.requestRender();\n },\n setPanoramaImage: (index, image) => map.engine.setPanoramaImage(index, image),\n clearPanorama: () => map.engine.clearPanorama(),\n geoidHeight,\n firstPerson: () => map.firstPerson,\n setFirstPerson: (view) => map.setFirstPerson(view),\n elevationAt: (lonLat) => map.elevationAt(lonLat),\n listen: (click, key, wheel) => {\n const off = map.on('click', ({ lonLat }) => click(lonLat));\n const container = map.getContainer();\n // Before the map's own wheel (its zoom, the eye's field of view)\n const onWheel = (e: WheelEvent) => {\n e.preventDefault();\n e.stopImmediatePropagation();\n wheel(e);\n };\n\n container.addEventListener('keydown', key);\n container.addEventListener('wheel', onWheel, { capture: true, passive: false });\n\n return () => {\n off();\n container.removeEventListener('keydown', key);\n container.removeEventListener('wheel', onWheel, { capture: true });\n };\n },\n});\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Where a raster layer's tiles come from: a PMTiles archive, Web Mercator tiles, or tiles reprojected from a grid. */
|
|
2
|
+
import { type RemoteReprojection } from '../basemap/grid.ts';
|
|
3
|
+
import type { RasterOptions } from '../types.ts';
|
|
4
|
+
/** The loader of a raster layer's tiles (none: the engine fetches them) and its zooms, in Web Mercator levels */
|
|
5
|
+
export interface RasterSource {
|
|
6
|
+
loader: RasterOptions['loader'];
|
|
7
|
+
minZoom: number;
|
|
8
|
+
maxZoom: number;
|
|
9
|
+
}
|
|
10
|
+
/** The loader of a raster layer's tiles and its zooms; `remote` reprojects in the workers */
|
|
11
|
+
export declare const rasterSource: (options: RasterOptions, remote: RemoteReprojection) => RasterSource;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** Where a raster layer's tiles come from: a PMTiles archive, Web Mercator tiles, or tiles reprojected from a grid. */
|
|
2
|
+
import { equirectangularGrid, gridLoader, gridZooms, resolveGrid } from "../basemap/grid.js";
|
|
3
|
+
import { pmtilesRasterLoader } from "../basemap/vectortiles.js";
|
|
4
|
+
/** The loader of a raster layer's tiles and its zooms; `remote` reprojects in the workers */
|
|
5
|
+
export const rasterSource = (options, remote) => {
|
|
6
|
+
const { url, grid = 'mercator', size } = options;
|
|
7
|
+
const { minZoom = 0, maxZoom = 19 } = options;
|
|
8
|
+
// A PMTiles archive (`pmtiles://…`): its tiles read by range requests
|
|
9
|
+
const loader = options.loader ?? pmtilesRasterLoader(url, size ?? 256);
|
|
10
|
+
if (grid === 'mercator' || loader)
|
|
11
|
+
return { loader, minZoom, maxZoom };
|
|
12
|
+
if (grid === 'equirectangular') {
|
|
13
|
+
// `minZoom` and `maxZoom` are levels of the source: its level n has the pixel size of Mercator level n + 1 at the
|
|
14
|
+
// equator
|
|
15
|
+
const reprojected = gridLoader(url, resolveGrid(equirectangularGrid(minZoom, maxZoom)), size ?? 256, remote);
|
|
16
|
+
return { loader: reprojected, minZoom: minZoom + 1, maxZoom: maxZoom + 1 };
|
|
17
|
+
}
|
|
18
|
+
const resolved = resolveGrid(grid);
|
|
19
|
+
const zooms = gridZooms(resolved);
|
|
20
|
+
return {
|
|
21
|
+
loader: gridLoader(url, resolved, size ?? 256, remote),
|
|
22
|
+
minZoom: options.minZoom ?? zooms.minZoom,
|
|
23
|
+
maxZoom: options.maxZoom ?? zooms.maxZoom,
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=raster-source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"raster-source.js","sourceRoot":"","sources":["../../src/map/raster-source.ts"],"names":[],"mappings":"AAAA,uHAAuH;AAEvH,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,SAAS,EAA2B,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtH,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAUhE,6FAA6F;AAC7F,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAsB,EAAE,MAA0B,EAAgB,EAAE;IAC/F,MAAM,EAAE,GAAG,EAAE,IAAI,GAAG,UAAU,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;IACjD,MAAM,EAAE,OAAO,GAAG,CAAC,EAAE,OAAO,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC;IAC9C,sEAAsE;IACtE,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,mBAAmB,CAAC,GAAG,EAAE,IAAI,IAAI,GAAG,CAAC,CAAC;IAEvE,IAAI,IAAI,KAAK,UAAU,IAAI,MAAM;QAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;IACvE,IAAI,IAAI,KAAK,iBAAiB,EAAE,CAAC;QAC/B,kHAAkH;QAClH,UAAU;QACV,MAAM,WAAW,GAAG,UAAU,CAAC,GAAG,EAAE,WAAW,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,EAAE,IAAI,IAAI,GAAG,EAAE,MAAM,CAAC,CAAC;QAE7G,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,GAAG,CAAC,EAAE,OAAO,EAAE,OAAO,GAAG,CAAC,EAAE,CAAC;IAC7E,CAAC;IAED,MAAM,QAAQ,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IACnC,MAAM,KAAK,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;IAElC,OAAO;QACL,MAAM,EAAE,UAAU,CAAC,GAAG,EAAE,QAAQ,EAAE,IAAI,IAAI,GAAG,EAAE,MAAM,CAAC;QACtD,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO;QACzC,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO;KAC1C,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/** Where a raster layer's tiles come from: a PMTiles archive, Web Mercator tiles, or tiles reprojected from a grid. */\n\nimport { equirectangularGrid, gridLoader, gridZooms, type RemoteReprojection, resolveGrid } from '../basemap/grid.ts';\nimport { pmtilesRasterLoader } from '../basemap/vectortiles.ts';\nimport type { RasterOptions } from '../types.ts';\n\n/** The loader of a raster layer's tiles (none: the engine fetches them) and its zooms, in Web Mercator levels */\nexport interface RasterSource {\n loader: RasterOptions['loader'];\n minZoom: number;\n maxZoom: number;\n}\n\n/** The loader of a raster layer's tiles and its zooms; `remote` reprojects in the workers */\nexport const rasterSource = (options: RasterOptions, remote: RemoteReprojection): RasterSource => {\n const { url, grid = 'mercator', size } = options;\n const { minZoom = 0, maxZoom = 19 } = options;\n // A PMTiles archive (`pmtiles://…`): its tiles read by range requests\n const loader = options.loader ?? pmtilesRasterLoader(url, size ?? 256);\n\n if (grid === 'mercator' || loader) return { loader, minZoom, maxZoom };\n if (grid === 'equirectangular') {\n // `minZoom` and `maxZoom` are levels of the source: its level n has the pixel size of Mercator level n + 1 at the\n // equator\n const reprojected = gridLoader(url, resolveGrid(equirectangularGrid(minZoom, maxZoom)), size ?? 256, remote);\n\n return { loader: reprojected, minZoom: minZoom + 1, maxZoom: maxZoom + 1 };\n }\n\n const resolved = resolveGrid(grid);\n const zooms = gridZooms(resolved);\n\n return {\n loader: gridLoader(url, resolved, size ?? 256, remote),\n minZoom: options.minZoom ?? zooms.minZoom,\n maxZoom: options.maxZoom ?? zooms.maxZoom,\n };\n};\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** The atlases of a map's symbol layers, the glyphs and the icons: created on first use, moved to each new engine. */
|
|
2
|
+
import { Glyphs } from '../layers/glyphs.ts';
|
|
3
|
+
import { Icons, type ImageOptions, type Pixels } from '../layers/icons.ts';
|
|
4
|
+
import type { Engine } from '../wasm/isard.js';
|
|
5
|
+
/** The glyphs and icons of a map */
|
|
6
|
+
export declare class SymbolAtlases {
|
|
7
|
+
#private;
|
|
8
|
+
private readonly canvas;
|
|
9
|
+
private readonly glyphsUrl;
|
|
10
|
+
private readonly engine;
|
|
11
|
+
/** `canvas`: the engine's; `glyphsUrl`: the map's option; `engine`: the map's engine of the moment */
|
|
12
|
+
constructor(canvas: HTMLCanvasElement, glyphsUrl: string | undefined, engine: () => Engine);
|
|
13
|
+
/** The glyphs of the symbol layers, loaded on first use */
|
|
14
|
+
get glyphs(): Glyphs;
|
|
15
|
+
/** The icons of the symbol layers: the application's images and the vector basemaps' sprites */
|
|
16
|
+
get icons(): Icons;
|
|
17
|
+
/** An image for the icons, from its pixels or from an image; one without pixels throws */
|
|
18
|
+
addImage(name: string, image: Pixels | (CanvasImageSource & {
|
|
19
|
+
width: number;
|
|
20
|
+
height: number;
|
|
21
|
+
}), options: ImageOptions): void;
|
|
22
|
+
hasImage(name: string): boolean;
|
|
23
|
+
removeImage(name: string): void;
|
|
24
|
+
/** Uploads the atlases made so far to a new engine (after a context loss, or the one left once the map is gone) */
|
|
25
|
+
attach(engine: Engine): void;
|
|
26
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/** The atlases of a map's symbol layers, the glyphs and the icons: created on first use, moved to each new engine. */
|
|
2
|
+
import { Glyphs } from "../layers/glyphs.js";
|
|
3
|
+
import { Icons, readPixels } from "../layers/icons.js";
|
|
4
|
+
/** The largest texture the canvas's WebGL context takes, undefined if unknown: the atlases stay within it */
|
|
5
|
+
const maxTextureSize = (canvas) => {
|
|
6
|
+
const gl = canvas.getContext('webgl2');
|
|
7
|
+
const max = gl?.getParameter(gl.MAX_TEXTURE_SIZE);
|
|
8
|
+
return typeof max === 'number' ? max : undefined;
|
|
9
|
+
};
|
|
10
|
+
/** The glyphs and icons of a map */
|
|
11
|
+
export class SymbolAtlases {
|
|
12
|
+
canvas;
|
|
13
|
+
glyphsUrl;
|
|
14
|
+
engine;
|
|
15
|
+
#glyphs;
|
|
16
|
+
#icons;
|
|
17
|
+
/** `canvas`: the engine's; `glyphsUrl`: the map's option; `engine`: the map's engine of the moment */
|
|
18
|
+
constructor(canvas, glyphsUrl, engine) {
|
|
19
|
+
this.canvas = canvas;
|
|
20
|
+
this.glyphsUrl = glyphsUrl;
|
|
21
|
+
this.engine = engine;
|
|
22
|
+
}
|
|
23
|
+
/** The glyphs of the symbol layers, loaded on first use */
|
|
24
|
+
get glyphs() {
|
|
25
|
+
if (!this.#glyphs) {
|
|
26
|
+
// The engine's context: the atlas stays within its texture size limit
|
|
27
|
+
this.#glyphs = new Glyphs(this.glyphsUrl, maxTextureSize(this.canvas));
|
|
28
|
+
this.#glyphs.attach(this.engine());
|
|
29
|
+
}
|
|
30
|
+
return this.#glyphs;
|
|
31
|
+
}
|
|
32
|
+
/** The icons of the symbol layers: the application's images and the vector basemaps' sprites */
|
|
33
|
+
get icons() {
|
|
34
|
+
if (!this.#icons) {
|
|
35
|
+
this.#icons = new Icons(maxTextureSize(this.canvas));
|
|
36
|
+
this.#icons.attach(this.engine());
|
|
37
|
+
}
|
|
38
|
+
return this.#icons;
|
|
39
|
+
}
|
|
40
|
+
/** An image for the icons, from its pixels or from an image; one without pixels throws */
|
|
41
|
+
addImage(name, image, options) {
|
|
42
|
+
const pixels = 'data' in image ? image : readPixels(image);
|
|
43
|
+
if (!pixels)
|
|
44
|
+
throw new Error(`isard: the image ${name} has no pixels`);
|
|
45
|
+
this.icons.add(name, pixels, options);
|
|
46
|
+
}
|
|
47
|
+
hasImage(name) {
|
|
48
|
+
return this.#icons?.has(name) ?? false;
|
|
49
|
+
}
|
|
50
|
+
removeImage(name) {
|
|
51
|
+
this.#icons?.remove(name);
|
|
52
|
+
}
|
|
53
|
+
/** Uploads the atlases made so far to a new engine (after a context loss, or the one left once the map is gone) */
|
|
54
|
+
attach(engine) {
|
|
55
|
+
this.#glyphs?.attach(engine);
|
|
56
|
+
this.#icons?.attach(engine);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=symbol-atlases.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"symbol-atlases.js","sourceRoot":"","sources":["../../src/map/symbol-atlases.ts"],"names":[],"mappings":"AAAA,sHAAsH;AAEtH,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAkC,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGvF,6GAA6G;AAC7G,MAAM,cAAc,GAAG,CAAC,MAAyB,EAAsB,EAAE;IACvE,MAAM,EAAE,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IACvC,MAAM,GAAG,GAAG,EAAE,EAAE,YAAY,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC;IAElD,OAAO,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC;AACnD,CAAC,CAAC;AAEF,oCAAoC;AACpC,MAAM,OAAO,aAAa;IACP,MAAM,CAAoB;IAC1B,SAAS,CAAqB;IAC9B,MAAM,CAAe;IACtC,OAAO,C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CAAC,CAAC;IACxC,CAAC;IAED,QAAQ,CAAC,IAAY;QACnB,OAAO,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC;IACzC,CAAC;IAED,WAAW,CAAC,IAAY;QACtB,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IAED,mHAAmH;IACnH,MAAM,CAAC,MAAc;QACnB,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;QAC7B,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC;CACF","sourcesContent":["/** The atlases of a map's symbol layers, the glyphs and the icons: created on first use, moved to each new engine. */\n\nimport { Glyphs } from '../layers/glyphs.ts';\nimport { Icons, type ImageOptions, type Pixels, readPixels } from '../layers/icons.ts';\nimport type { Engine } from '../wasm/isard.js';\n\n/** The largest texture the canvas's WebGL context takes, undefined if unknown: the atlases stay within it */\nconst maxTextureSize = (canvas: HTMLCanvasElement): number | undefined => {\n const gl = canvas.getContext('webgl2');\n const max = gl?.getParameter(gl.MAX_TEXTURE_SIZE);\n\n return typeof max === 'number' ? max : undefined;\n};\n\n/** The glyphs and icons of a map */\nexport class SymbolAtlases {\n private readonly canvas: HTMLCanvasElement;\n private readonly glyphsUrl: string | undefined;\n private readonly engine: () => Engine;\n #glyphs: Glyphs | undefined;\n #icons: Icons | undefined;\n\n /** `canvas`: the engine's; `glyphsUrl`: the map's option; `engine`: the map's engine of the moment */\n constructor(canvas: HTMLCanvasElement, glyphsUrl: string | undefined, engine: () => Engine) {\n this.canvas = canvas;\n this.glyphsUrl = glyphsUrl;\n this.engine = engine;\n }\n\n /** The glyphs of the symbol layers, loaded on first use */\n get glyphs(): Glyphs {\n if (!this.#glyphs) {\n // The engine's context: the atlas stays within its texture size limit\n this.#glyphs = new Glyphs(this.glyphsUrl, maxTextureSize(this.canvas));\n this.#glyphs.attach(this.engine());\n }\n\n return this.#glyphs;\n }\n\n /** The icons of the symbol layers: the application's images and the vector basemaps' sprites */\n get icons(): Icons {\n if (!this.#icons) {\n this.#icons = new Icons(maxTextureSize(this.canvas));\n this.#icons.attach(this.engine());\n }\n\n return this.#icons;\n }\n\n /** An image for the icons, from its pixels or from an image; one without pixels throws */\n addImage(\n name: string,\n image: Pixels | (CanvasImageSource & { width: number; height: number }),\n options: ImageOptions,\n ): void {\n const pixels = 'data' in image ? image : readPixels(image);\n\n if (!pixels) throw new Error(`isard: the image ${name} has no pixels`);\n this.icons.add(name, pixels, options);\n }\n\n hasImage(name: string): boolean {\n return this.#icons?.has(name) ?? false;\n }\n\n removeImage(name: string): void {\n this.#icons?.remove(name);\n }\n\n /** Uploads the atlases made so far to a new engine (after a context loss, or the one left once the map is gone) */\n attach(engine: Engine): void {\n this.#glyphs?.attach(engine);\n this.#icons?.attach(engine);\n }\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** The viewshed's observers given to the engine, in the arrays it reads. */
|
|
2
|
+
import type { ViewshedOptions } from '../types.ts';
|
|
3
|
+
import type { Engine } from '../wasm/isard.js';
|
|
4
|
+
/** Sets the viewshed of the engine, or clears it without observers; true if one is set (a frame to draw) */
|
|
5
|
+
export declare const applyViewshed: (engine: Engine, options: ViewshedOptions | readonly ViewshedOptions[] | undefined) => boolean;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** The viewshed's observers given to the engine, in the arrays it reads. */
|
|
2
|
+
import { rgb } from "../settings.js";
|
|
3
|
+
/** The observers of a viewshed option: none, one, or several */
|
|
4
|
+
const observersOf = (options) => {
|
|
5
|
+
if (!options)
|
|
6
|
+
return [];
|
|
7
|
+
return 'position' in options ? [options] : options;
|
|
8
|
+
};
|
|
9
|
+
/** Sets the viewshed of the engine, or clears it without observers; true if one is set (a frame to draw) */
|
|
10
|
+
export const applyViewshed = (engine, options) => {
|
|
11
|
+
const observers = observersOf(options);
|
|
12
|
+
const [first] = observers;
|
|
13
|
+
if (!first) {
|
|
14
|
+
engine.clearViewshed();
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
engine.setViewshed(new Float64Array(observers.flatMap((o) => [
|
|
18
|
+
o.position[0],
|
|
19
|
+
o.position[1],
|
|
20
|
+
o.height ?? 1.7,
|
|
21
|
+
o.range ?? 1000,
|
|
22
|
+
...(o.direction === undefined
|
|
23
|
+
? [Number.NaN, 0, 0, 0]
|
|
24
|
+
: [o.direction, o.tilt ?? 0, o.fov ?? 60, o.verticalFov ?? 40]),
|
|
25
|
+
])), new Float32Array(rgb(first.visibleColor ?? '#2f9e44')), new Float32Array(rgb(first.hiddenColor ?? '#e03131')), first.opacity ?? 0.7, new Float32Array(first.coneColor ? rgb(first.coneColor) : []));
|
|
26
|
+
return true;
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=viewshed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewshed.js","sourceRoot":"","sources":["../../src/map/viewshed.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAE5E,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAIrC,gEAAgE;AAChE,MAAM,WAAW,GAAG,CAAC,OAAiE,EAA8B,EAAE;IACpH,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,CAAC;IAExB,OAAO,UAAU,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;AACrD,CAAC,CAAC;AAEF,4GAA4G;AAC5G,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,MAAc,EACd,OAAiE,EACxD,EAAE;IACX,MAAM,SAAS,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;IACvC,MAAM,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC;IAE1B,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,CAAC,aAAa,EAAE,CAAC;QAEvB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,CAAC,WAAW,CAChB,IAAI,YAAY,CACd,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QACvB,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;QACb,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;QACb,CAAC,CAAC,MAAM,IAAI,GAAG;QACf,CAAC,CAAC,KAAK,IAAI,IAAI;QACf,GAAG,CAAC,CAAC,CAAC,SAAS,KAAK,SAAS;YAC3B,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;YACvB,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC;KAClE,CAAC,CACH,EACD,IAAI,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,YAAY,IAAI,SAAS,CAAC,CAAC,EACtD,IAAI,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,WAAW,IAAI,SAAS,CAAC,CAAC,EACrD,KAAK,CAAC,OAAO,IAAI,GAAG,EACpB,IAAI,YAAY,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAC9D,CAAC;IAEF,OAAO,IAAI,CAAC;AACd,CAAC,CAAC","sourcesContent":["/** The viewshed's observers given to the engine, in the arrays it reads. */\n\nimport { rgb } from '../settings.ts';\nimport type { ViewshedOptions } from '../types.ts';\nimport type { Engine } from '../wasm/isard.js';\n\n/** The observers of a viewshed option: none, one, or several */\nconst observersOf = (options: ViewshedOptions | readonly ViewshedOptions[] | undefined): readonly ViewshedOptions[] => {\n if (!options) return [];\n\n return 'position' in options ? [options] : options;\n};\n\n/** Sets the viewshed of the engine, or clears it without observers; true if one is set (a frame to draw) */\nexport const applyViewshed = (\n engine: Engine,\n options: ViewshedOptions | readonly ViewshedOptions[] | undefined,\n): boolean => {\n const observers = observersOf(options);\n const [first] = observers;\n\n if (!first) {\n engine.clearViewshed();\n\n return false;\n }\n engine.setViewshed(\n new Float64Array(\n observers.flatMap((o) => [\n o.position[0],\n o.position[1],\n o.height ?? 1.7,\n o.range ?? 1000,\n ...(o.direction === undefined\n ? [Number.NaN, 0, 0, 0]\n : [o.direction, o.tilt ?? 0, o.fov ?? 60, o.verticalFov ?? 40]),\n ]),\n ),\n new Float32Array(rgb(first.visibleColor ?? '#2f9e44')),\n new Float32Array(rgb(first.hiddenColor ?? '#e03131')),\n first.opacity ?? 0.7,\n new Float32Array(first.coneColor ? rgb(first.coneColor) : []),\n );\n\n return true;\n};\n"]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A map's workers: the pool drawing vector tiles, shared by the map's `VectorTiles`, which also decodes the relief and
|
|
3
|
+
* reprojects rasters off the page; and the loaders of the relief, one per tile source.
|
|
4
|
+
*/
|
|
5
|
+
import type { RemoteReprojection } from '../basemap/grid.ts';
|
|
6
|
+
import { type PngEncoding } from '../basemap/terrain.ts';
|
|
7
|
+
import { BasemapWorkers } from '../basemap/vectortiles.ts';
|
|
8
|
+
import type { TerrainLoader } from '../settings.ts';
|
|
9
|
+
import type { GeoMapOptions } from '../types.ts';
|
|
10
|
+
/** The workers of a map, created on first use */
|
|
11
|
+
export declare class MapWorkers {
|
|
12
|
+
/** URL of the workers' script */
|
|
13
|
+
readonly url: string | URL;
|
|
14
|
+
private readonly workers;
|
|
15
|
+
/** The map is destroyed: nothing more is sent to the workers */
|
|
16
|
+
private readonly gone;
|
|
17
|
+
/** Whose requests the workers' answer (cancelled together) */
|
|
18
|
+
private readonly owner;
|
|
19
|
+
/** The shared pool, created on first use */
|
|
20
|
+
private shared;
|
|
21
|
+
/** The loaders of the relief by encoding, URL and floor: the same loader for the same tiles (the engine keeps its
|
|
22
|
+
* tiles when only the exaggeration changes) */
|
|
23
|
+
private readonly terrainLoaders;
|
|
24
|
+
/** `workers`: the map's option (false or 0, no worker); `owner`: the map */
|
|
25
|
+
constructor(url: string | URL, workers: GeoMapOptions['workers'], gone: () => boolean, owner: object);
|
|
26
|
+
/**
|
|
27
|
+
* The workers for a `VectorTiles`: the shared pool, or a pool of its own (`own`, to stop with it) when it asks for
|
|
28
|
+
* another count or URL
|
|
29
|
+
*/
|
|
30
|
+
pool(count?: number, url?: string | URL): {
|
|
31
|
+
pool: BasemapWorkers;
|
|
32
|
+
own: boolean;
|
|
33
|
+
};
|
|
34
|
+
/** Stops the shared pool */
|
|
35
|
+
terminate(): void;
|
|
36
|
+
/** Rasters reprojected by the workers (in the page without them) */
|
|
37
|
+
readonly remoteReprojection: RemoteReprojection;
|
|
38
|
+
/** The loader of the relief tiles of `url` in a PNG encoding (one per URL, encoding and floor) */
|
|
39
|
+
readonly terrainLoader: (url: string, encoding: PngEncoding, floor?: number) => TerrainLoader;
|
|
40
|
+
private readonly remoteHeights;
|
|
41
|
+
/**
|
|
42
|
+
* The workers decoding the relief and reprojecting rasters: the shared pool, unless the map has no workers
|
|
43
|
+
* (`workers: false` or 0, or none in this browser): that is done in the page then
|
|
44
|
+
*/
|
|
45
|
+
private decodingPool;
|
|
46
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A map's workers: the pool drawing vector tiles, shared by the map's `VectorTiles`, which also decodes the relief and
|
|
3
|
+
* reprojects rasters off the page; and the loaders of the relief, one per tile source.
|
|
4
|
+
*/
|
|
5
|
+
import { encodedTerrainLoader } from "../basemap/terrain.js";
|
|
6
|
+
import { BasemapWorkers, defaultWorkerCount } from "../basemap/vectortiles.js";
|
|
7
|
+
/** The workers of a map, created on first use */
|
|
8
|
+
export class MapWorkers {
|
|
9
|
+
/** URL of the workers' script */
|
|
10
|
+
url;
|
|
11
|
+
workers;
|
|
12
|
+
/** The map is destroyed: nothing more is sent to the workers */
|
|
13
|
+
gone;
|
|
14
|
+
/** Whose requests the workers' answer (cancelled together) */
|
|
15
|
+
owner;
|
|
16
|
+
/** The shared pool, created on first use */
|
|
17
|
+
shared;
|
|
18
|
+
/** The loaders of the relief by encoding, URL and floor: the same loader for the same tiles (the engine keeps its
|
|
19
|
+
* tiles when only the exaggeration changes) */
|
|
20
|
+
terrainLoaders = new Map();
|
|
21
|
+
/** `workers`: the map's option (false or 0, no worker); `owner`: the map */
|
|
22
|
+
constructor(url, workers, gone, owner) {
|
|
23
|
+
this.url = url;
|
|
24
|
+
this.workers = workers;
|
|
25
|
+
this.gone = gone;
|
|
26
|
+
this.owner = owner;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The workers for a `VectorTiles`: the shared pool, or a pool of its own (`own`, to stop with it) when it asks for
|
|
30
|
+
* another count or URL
|
|
31
|
+
*/
|
|
32
|
+
pool(count, url) {
|
|
33
|
+
const shared = defaultWorkerCount();
|
|
34
|
+
const workers = Math.max(1, count ?? shared);
|
|
35
|
+
const workerUrl = url ?? this.url;
|
|
36
|
+
if (workers === shared && String(workerUrl) === String(this.url)) {
|
|
37
|
+
this.shared ??= new BasemapWorkers(shared, this.url);
|
|
38
|
+
return { pool: this.shared, own: false };
|
|
39
|
+
}
|
|
40
|
+
return { pool: new BasemapWorkers(workers, workerUrl), own: true };
|
|
41
|
+
}
|
|
42
|
+
/** Stops the shared pool */
|
|
43
|
+
terminate() {
|
|
44
|
+
this.shared?.terminate();
|
|
45
|
+
this.shared = undefined;
|
|
46
|
+
}
|
|
47
|
+
/** Rasters reprojected by the workers (in the page without them) */
|
|
48
|
+
remoteReprojection = (job, tile, signal) => this.decodingPool()?.reproject(job, tile, signal, this.owner);
|
|
49
|
+
/** The loader of the relief tiles of `url` in a PNG encoding (one per URL, encoding and floor) */
|
|
50
|
+
terrainLoader = (url, encoding, floor) => {
|
|
51
|
+
const key = `${encoding} ${floor ?? ''} ${url}`;
|
|
52
|
+
const cached = this.terrainLoaders.get(key);
|
|
53
|
+
if (cached)
|
|
54
|
+
return cached;
|
|
55
|
+
const loader = encodedTerrainLoader(url, encoding, floor, this.remoteHeights);
|
|
56
|
+
this.terrainLoaders.set(key, loader);
|
|
57
|
+
return loader;
|
|
58
|
+
};
|
|
59
|
+
remoteHeights = (url, encoding, floor, tile, signal) => this.decodingPool()?.heights(url, encoding, floor, tile, signal, this.owner);
|
|
60
|
+
/**
|
|
61
|
+
* The workers decoding the relief and reprojecting rasters: the shared pool, unless the map has no workers
|
|
62
|
+
* (`workers: false` or 0, or none in this browser): that is done in the page then
|
|
63
|
+
*/
|
|
64
|
+
decodingPool() {
|
|
65
|
+
const workers = this.workers;
|
|
66
|
+
if (this.gone() || workers === false || (workers !== undefined && workers <= 0))
|
|
67
|
+
return undefined;
|
|
68
|
+
if (typeof Worker === 'undefined' || typeof OffscreenCanvas === 'undefined')
|
|
69
|
+
return undefined;
|
|
70
|
+
return this.pool().pool;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=workers.js.map
|
|
@@ -0,0 +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,2BAA2B,CAAC;AAI/E,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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QAAqB,EAAE,KAAc,EAAiB,EAAE;QAC7F,MAAM,GAAG,GAAG,GAAG,QAAQ,IAAI,KAAK,IAAI,EAAE,IAAI,GAAG,EAAE,CAAC;QAChD,MAAM,MAAM,GAAG,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAE5C,IAAI,MAAM;YAAE,OAAO,MAAM,CAAC;QAE1B,MAAM,MAAM,GAAG,oBAAoB,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;QAE9E,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QAErC,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;IAEe,aAAa,GAAkB,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,CACrF,IAAI,CAAC,YAAY,EAAE,EAAE,OAAO,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IAE/E;;;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/vectortiles.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 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 /**\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"]}
|