isard 1.4.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/CHANGELOG.md +55 -1
  2. package/README.md +22 -7
  3. package/dist/basemap/vectortiles/context.d.ts +43 -0
  4. package/dist/basemap/vectortiles/context.js +6 -0
  5. package/dist/basemap/vectortiles/context.js.map +1 -0
  6. package/dist/basemap/vectortiles/extrusions.d.ts +11 -0
  7. package/dist/basemap/vectortiles/extrusions.js +46 -0
  8. package/dist/basemap/vectortiles/extrusions.js.map +1 -0
  9. package/dist/basemap/vectortiles/labels.d.ts +22 -0
  10. package/dist/basemap/vectortiles/labels.js +225 -0
  11. package/dist/basemap/vectortiles/labels.js.map +1 -0
  12. package/dist/basemap/vectortiles/requests.d.ts +24 -0
  13. package/dist/basemap/vectortiles/requests.js +61 -0
  14. package/dist/basemap/vectortiles/requests.js.map +1 -0
  15. package/dist/basemap/vectortiles/street-wind.d.ts +19 -0
  16. package/dist/basemap/vectortiles/street-wind.js +133 -0
  17. package/dist/basemap/vectortiles/street-wind.js.map +1 -0
  18. package/dist/basemap/vectortiles/style.d.ts +47 -0
  19. package/dist/basemap/vectortiles/style.js +141 -0
  20. package/dist/basemap/vectortiles/style.js.map +1 -0
  21. package/dist/basemap/vectortiles/tiles.d.ts +34 -0
  22. package/dist/basemap/vectortiles/tiles.js +62 -0
  23. package/dist/basemap/vectortiles/tiles.js.map +1 -0
  24. package/dist/basemap/vectortiles/trees.d.ts +19 -0
  25. package/dist/basemap/vectortiles/trees.js +93 -0
  26. package/dist/basemap/vectortiles/trees.js.map +1 -0
  27. package/dist/basemap/vectortiles/vectors.d.ts +20 -0
  28. package/dist/basemap/vectortiles/vectors.js +167 -0
  29. package/dist/basemap/vectortiles/vectors.js.map +1 -0
  30. package/dist/basemap/vectortiles.d.ts +23 -90
  31. package/dist/basemap/vectortiles.js +57 -765
  32. package/dist/basemap/vectortiles.js.map +1 -1
  33. package/dist/basemap/workerpool.js +25 -6
  34. package/dist/basemap/workerpool.js.map +1 -1
  35. package/dist/basemap.worker.js +2 -2
  36. package/dist/basemap.worker.js.map +4 -4
  37. package/dist/decoder.worker.js +5 -4
  38. package/dist/decoder.worker.js.map +8 -6
  39. package/dist/engine/decoders.d.ts +4 -8
  40. package/dist/engine/decoders.js +29 -2
  41. package/dist/engine/decoders.js.map +1 -1
  42. package/dist/index.d.ts +7 -1
  43. package/dist/index.js +1 -1
  44. package/dist/index.js.map +1 -1
  45. package/dist/isard_bg.wasm +0 -0
  46. package/dist/isard_core_bg.wasm +0 -0
  47. package/dist/layers/flow.d.ts +9 -2
  48. package/dist/layers/flow.js +51 -10
  49. package/dist/layers/flow.js.map +1 -1
  50. package/dist/layers/panoramas.d.ts +2 -0
  51. package/dist/layers/panoramas.js +27 -6
  52. package/dist/layers/panoramas.js.map +1 -1
  53. package/dist/map/workers.js +3 -0
  54. package/dist/map/workers.js.map +1 -1
  55. package/dist/util/read.d.ts +4 -0
  56. package/dist/util/read.js +28 -0
  57. package/dist/util/read.js.map +1 -0
  58. package/dist/wasm/isard.d.ts +18 -5
  59. package/dist/wasm/isard.js +25 -4
  60. package/dist/wasm/isard_core.d.ts +18 -5
  61. package/dist/wasm/isard_core.js +25 -4
  62. package/dist/workers/basemap/street.d.ts +1 -1
  63. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"panoramas.js","sourceRoot":"","sources":["../../src/layers/panoramas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAwExD,MAAM,aAAa,GAAG,CAAC,KAAc,EAA6C,EAAE,CAClF,QAAQ,CAAC,KAAK,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC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,CAAC,OAAO,IAAI,CAAC;KAC9B,EACD,IAAI,EACJ,SAAS,EACT,OAAO,EACP,SAAS,CACV,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/**\n * Street-level panoramas: the oriented images of a vehicle's cameras around each of its positions (Stereopolis, the\n * iTowns immersive examples), projected onto the scene around the panorama shown. Their positions and attitudes come\n * as GeoJSON points (Lambert-93 by default, altitudes NGF-IGN69 raised by the RAF20 geoid onto the IGN relief), the\n * calibration of the cameras as JSON (rotation and position in the panorama frame, intrinsics, MicMac's radial\n * distortion), the images from a URL template with `{cameraId}` and `{panoId}`.\n *\n * ```ts\n * const panoramas = await map.addPanoramas({ url, orientationsUrl, calibrationUrl });\n * await panoramas.show(panoramas.nearest([2.3345, 48.8505]).index);\n * ```\n */\nimport { getCrs } from '../data/crs.ts';\nimport { withHeaders } from '../engine/requests.ts';\nimport type { FirstPersonView, LonLat } from '../types.ts';\nimport { isNumbers, isRecord } from '../util/guards.ts';\n\nexport interface PanoramaOptions {\n /** URL of an image: `{cameraId}` and `{panoId}` replaced by a camera's id and a panorama's */\n url: string;\n /** GeoJSON points: each panorama's position, and its `id`, `heading`, `pitch`, `roll` (degrees) in properties */\n orientationsUrl: string;\n /** JSON array of the cameras: `id`, `rotation` (row-major), `position`, `projection`, `size`, `distortion` */\n calibrationUrl: string;\n /** CRS of the positions (default the GeoJSON's `crs` member, else `EPSG:2154`) */\n crs?: string;\n /** Altitudes above the geoid (NGF-IGN69), raised by the RAF20 geoid onto the IGN relief (default true in\n * Lambert-93) */\n geoid?: boolean;\n /** Radius of the sphere around the panorama its images are a backdrop on, metres (default 1000) */\n backgroundDistance?: number;\n /** 0-1 (default 1) */\n opacity?: number;\n}\n\n/** A panorama: where it is and which way the vehicle faced */\nexport interface Panorama {\n index: number;\n id: number | string;\n lonLat: LonLat;\n /** Metres above the ellipsoid */\n height: number;\n /** Degrees clockwise from north */\n heading: number;\n}\n\n/** What the map gives the panoramas */\nexport interface PanoramaHost {\n setPanorama(\n lon: number,\n lat: number,\n height: number,\n rotation: Float64Array,\n cameras: Float64Array,\n radius: number,\n opacity: number,\n ): void;\n setPanoramaImage(index: number, image: ImageBitmap): void;\n clearPanorama(): void;\n geoidHeight(lon: number, lat: number): number;\n /** The street-level eye, and setting it (undefined: back to the camera turning around a point) */\n firstPerson(): Readonly<Required<FirstPersonView>> | undefined;\n setFirstPerson(view: FirstPersonView | undefined): void;\n elevationAt(lonLat: LonLat): number | undefined;\n /** Follows the clicks on the map (with the ground clicked), the keys typed on it and its wheel (taken from the\n * map's own); returns what stops */\n listen(\n click: (lonLat: LonLat | undefined) => void,\n key: (e: KeyboardEvent) => void,\n wheel: (e: WheelEvent) => void,\n ): () => void;\n}\n\ninterface Calibration {\n id: number | string;\n rotation: number[];\n position: number[];\n projection: number[];\n size: number[];\n distortion?: { pps: number[]; poly357: number[]; limit?: number };\n}\n\ninterface Orientations {\n crs?: { properties?: { name?: string } };\n features: { geometry: { coordinates: number[] }; properties: Record<string, unknown> }[];\n}\n\nconst isOrientation = (value: unknown): value is Orientations['features'][number] =>\n isRecord(value) && isRecord(value.geometry) && isNumbers(value.geometry.coordinates) && isRecord(value.properties);\n\nconst isCrs = (value: unknown): value is Orientations['crs'] =>\n isRecord(value) &&\n (value.properties === undefined ||\n (isRecord(value.properties) && (value.properties.name === undefined || typeof value.properties.name === 'string')));\n\nconst isOrientations = (value: unknown): value is Orientations =>\n isRecord(value) &&\n (value.crs === undefined || isCrs(value.crs)) &&\n Array.isArray(value.features) &&\n value.features.every(isOrientation);\n\nconst isCalibration = (value: unknown): value is Calibration =>\n isRecord(value) &&\n (typeof value.id === 'number' || typeof value.id === 'string') &&\n isNumbers(value.rotation) &&\n isNumbers(value.position) &&\n isNumbers(value.projection) &&\n isNumbers(value.size) &&\n (value.distortion === undefined ||\n (isRecord(value.distortion) &&\n isNumbers(value.distortion.pps) &&\n isNumbers(value.distortion.poly357) &&\n (value.distortion.limit === undefined || typeof value.distortion.limit === 'number')));\n\nconst isCalibrations = (value: unknown): value is Calibration[] => Array.isArray(value) && value.every(isCalibration);\n\ninterface Attitude {\n heading: number;\n pitch: number;\n roll: number;\n}\n\nconst RAD = Math.PI / 180;\n\n/** 3 × 3 product, row-major */\nconst times = (a: number[], b: number[]): number[] =>\n Array.from({ length: 9 }, (_, i) => {\n const [r, c] = [Math.floor(i / 3), i % 3];\n\n return [0, 1, 2].reduce((sum, k) => sum + (a[r * 3 + k] ?? 0) * (b[k * 3 + c] ?? 0), 0);\n });\n\nconst rotX = (t: number) => [1, 0, 0, 0, Math.cos(t), -Math.sin(t), 0, Math.sin(t), Math.cos(t)];\nconst rotY = (t: number) => [Math.cos(t), 0, Math.sin(t), 0, 1, 0, -Math.sin(t), 0, Math.cos(t)];\nconst rotZ = (t: number) => [Math.cos(t), -Math.sin(t), 0, Math.sin(t), Math.cos(t), 0, 0, 0, 1];\n\n/**\n * The panorama frame to east, north, up (row-major): the vehicle's attitude in the CRS's grid (iTowns'\n * `quaternionFromRollPitchHeading`: Ry(-roll) · Rx(-pitch) · Rz(-heading)), turned by the meridian convergence of the\n * projection (Lambert-93: sin(46.5°) · (3° - longitude))\n */\nexport const panoramaRotation = (attitude: Attitude, lon: number, lambert93: boolean): number[] => {\n const vehicle = times(times(rotY(-attitude.roll * RAD), rotX(-attitude.pitch * RAD)), rotZ(-attitude.heading * RAD));\n const convergence = lambert93 ? Math.sin(46.5 * RAD) * (3 - lon) * RAD : 0;\n\n return times(rotZ(convergence), vehicle);\n};\n\n/** The 25 numbers of a camera for `setPanorama` */\nconst cameraNumbers = (c: Calibration): number[] => {\n const p = c.projection;\n const d = c.distortion;\n\n return [\n ...c.rotation.slice(0, 9),\n ...c.position.slice(0, 3),\n p[0] ?? 1,\n p[4] ?? 1,\n p[2] ?? 0,\n p[5] ?? 0,\n p[1] ?? 0,\n c.size[0] ?? 1,\n c.size[1] ?? 1,\n d?.pps[0] ?? 0,\n d?.pps[1] ?? 0,\n d?.poly357[0] ?? 0,\n d?.poly357[1] ?? 0,\n d?.poly357[2] ?? 0,\n d?.limit ?? 0,\n ];\n};\n\n/** The panoramas of a set, one shown at a time */\nexport class Panoramas {\n /** The panorama shown, if any */\n current: Panorama | undefined;\n private shown = 0;\n\n /** @internal */\n constructor(\n private readonly host: PanoramaHost,\n private readonly options: Required<Pick<PanoramaOptions, 'url' | 'backgroundDistance' | 'opacity'>>,\n readonly list: readonly Panorama[],\n private readonly attitudes: readonly Attitude[],\n private readonly cameras: readonly Calibration[],\n private readonly lambert93: boolean,\n ) {}\n\n /** The panorama nearest to a position */\n nearest(lonLat: LonLat): Panorama | undefined {\n const cos = Math.cos(lonLat[1] * RAD);\n\n return this.list.reduce<{ best?: Panorama; distance: number }>(\n (nearest, p) => {\n const d = ((p.lonLat[0] - lonLat[0]) * cos) ** 2 + (p.lonLat[1] - lonLat[1]) ** 2;\n\n return d < nearest.distance ? { best: p, distance: d } : nearest;\n },\n { distance: Number.POSITIVE_INFINITY },\n ).best;\n }\n\n /** Shows a panorama (its index in `list`): projected as soon as its first image arrives, the others after */\n async show(index: number): Promise<void> {\n const pano = this.list[index];\n const attitude = this.attitudes[index];\n\n if (!pano || !attitude) return;\n\n const shown = ++this.shown;\n\n this.current = pano;\n\n const rotation = panoramaRotation(attitude, pano.lonLat[0], this.lambert93);\n const { url, backgroundDistance, opacity } = this.options;\n\n this.host.setPanorama(\n pano.lonLat[0],\n pano.lonLat[1],\n pano.height,\n Float64Array.from(rotation),\n Float64Array.from(this.cameras.flatMap(cameraNumbers)),\n backgroundDistance,\n opacity,\n );\n await Promise.all(\n this.cameras.map(async (camera, k) => {\n const src = url.replaceAll('{cameraId}', String(camera.id)).replaceAll('{panoId}', String(pano.id));\n const response = await fetch(src, withHeaders(src));\n\n if (!response.ok) throw new Error(`isard: panorama image ${src}: ${response.status}`);\n\n const image = await createImageBitmap(await response.blob(), { premultiplyAlpha: 'none' });\n\n // Another panorama shown since: this image is not its\n if (shown === this.shown) this.host.setPanoramaImage(k, image);\n image.close();\n }),\n );\n }\n\n /** Hides the panorama shown */\n hide(): void {\n this.shown++;\n this.current = undefined;\n this.host.clearPanorama();\n }\n\n /** Stops the walk (`enter`) */\n private stopWalking: (() => void) | undefined;\n\n /**\n * Street-level walk from panorama to panorama (the iTowns immersive view): the eye on a panorama, the drag\n * turning it; a click goes to the panorama nearest to the clicked point, the wheel to the nearest one ahead (or\n * behind), Z and S (or Page Up and Page Down) to the next and the previous ones. Starts on the panorama `index`,\n * else the one nearest to `near`\n */\n async enter(start: { index?: number; near?: LonLat } = {}): Promise<void> {\n const first = start.index ?? (start.near && this.nearest(start.near)?.index) ?? 0;\n\n this.stopWalking?.();\n this.stopWalking = this.host.listen(\n (lonLat) => {\n const target = lonLat && this.nearest(lonLat);\n\n if (target && target !== this.current) void this.go(target.index);\n },\n (e) => {\n const step = { z: 1, Z: 1, PageUp: 1, s: -1, S: -1, PageDown: -1 }[e.key];\n\n if (!step || !this.current) return;\n e.preventDefault();\n void this.go((this.current.index + step + this.list.length) % this.list.length);\n },\n (e) => {\n // One step per notch, the next ones once it is shown\n if (this.moving || e.deltaY === 0) return;\n\n const target = this.ahead(e.deltaY < 0);\n\n if (target) {\n this.moving = true;\n void this.go(target.index).finally(() => {\n this.moving = false;\n });\n }\n },\n );\n await this.go(first, this.list[first]?.heading);\n }\n\n /** A step of the wheel under way */\n private moving = false;\n\n /** The nearest panorama ahead of the eye (within 60° of where it looks), or behind it */\n ahead(forward = true): Panorama | undefined {\n const eye = this.host.firstPerson();\n const here = this.current;\n\n if (!eye || !here) return undefined;\n\n const cos = Math.cos(here.lonLat[1] * RAD);\n const look = (eye.bearing + (forward ? 0 : 180)) * RAD;\n\n return this.list.reduce<{ best?: Panorama; distance: number }>(\n (nearest, p) => {\n if (p === here) return nearest;\n\n const [east, north] = [(p.lonLat[0] - here.lonLat[0]) * cos, p.lonLat[1] - here.lonLat[1]];\n const d = Math.hypot(east, north);\n const off = Math.acos(Math.max(-1, Math.min(1, (east * Math.sin(look) + north * Math.cos(look)) / (d || 1))));\n\n return off < 60 * RAD && d < nearest.distance ? { best: p, distance: d } : nearest;\n },\n { distance: Number.POSITIVE_INFINITY },\n ).best;\n }\n\n /** Goes to a panorama during the walk, the eye looking the same way (or `bearing`) */\n async go(index: number, bearing?: number): Promise<void> {\n const pano = this.list[index];\n\n if (!pano) return;\n\n const eye = this.host.firstPerson();\n // The eye at the panorama's cameras, above the ground there\n const ground = this.host.elevationAt(pano.lonLat);\n\n this.host.setFirstPerson({\n lonLat: pano.lonLat,\n height: ground === undefined ? 2.5 : Math.max(0.5, pano.height - ground),\n bearing: bearing ?? eye?.bearing ?? pano.heading,\n ...(eye ? { pitch: eye.pitch, fov: eye.fov } : {}),\n });\n await this.show(index);\n }\n\n /** Ends the walk: the panorama hidden, the camera turning around a point again, above where the eye stood */\n exit(): void {\n this.stopWalking?.();\n this.stopWalking = undefined;\n this.hide();\n this.host.setFirstPerson(undefined);\n }\n}\n\n/** Loads a set of panoramas: their positions and attitudes, the calibration of their cameras */\nexport const loadPanoramas = async (host: PanoramaHost, options: PanoramaOptions): Promise<Panoramas> => {\n const json = async <T>(src: string, is: (value: unknown) => value is T): Promise<T> => {\n const response = await fetch(src, withHeaders(src));\n\n if (!response.ok) throw new Error(`isard: ${src}: ${response.status}`);\n\n const value: unknown = await response.json();\n\n if (!is(value)) throw new Error(`isard: ${src}: unexpected content`);\n\n return value;\n };\n const [orientations, cameras] = await Promise.all([\n json(options.orientationsUrl, isOrientations),\n json(options.calibrationUrl, isCalibrations),\n ]);\n const crsName = options.crs ?? orientations.crs?.properties?.name ?? 'EPSG:2154';\n const lambert93 = /2154/.test(crsName);\n const crs = getCrs(crsName);\n const geoid = options.geoid ?? lambert93;\n const list: Panorama[] = [];\n const attitudes: Attitude[] = [];\n\n orientations.features.forEach((feature) => {\n const [x = 0, y = 0, z = 0] = feature.geometry.coordinates;\n const [lon = 0, lat = 0] = crs.inverse([x, y]);\n const p = feature.properties;\n const number = (key: string) => {\n const value = p[key];\n\n return typeof value === 'number' ? value : 0;\n };\n\n attitudes.push({ heading: number('heading'), pitch: number('pitch'), roll: number('roll') });\n list.push({\n index: list.length,\n id: typeof p.id === 'number' || typeof p.id === 'string' ? p.id : list.length,\n lonLat: [lon, lat],\n height: z + (geoid ? host.geoidHeight(lon, lat) : 0),\n heading: number('heading'),\n });\n });\n\n return new Panoramas(\n host,\n {\n url: options.url,\n backgroundDistance: options.backgroundDistance ?? 1000,\n opacity: options.opacity ?? 1,\n },\n list,\n attitudes,\n cameras,\n lambert93,\n );\n};\n"]}
1
+ {"version":3,"file":"panoramas.js","sourceRoot":"","sources":["../../src/layers/panoramas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAwExD,MAAM,aAAa,GAAG,CAAC,KAAc,EAA6C,EAAE,CAClF,QAAQ,CAAC,KAAK,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;AAErH,MAAM,KAAK,GAAG,CAAC,KAAc,EAAgC,EAAE,CAC7D,QAAQ,CAAC,KAAK,CAAC;IACf,CAAC,KAAK,CAAC,UAAU,KAAK,SAAS;QAC7B,CAAC,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,KAAK,SAAS,IAAI,OAAO,KAAK,CAAC,UAAU,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC;AAExH,MAAM,cAAc,GAAG,CAAC,KAAc,EAAyB,EAAE,CAC/D,QAAQ,CAAC,KAAK,CAAC;IACf,CAAC,KAAK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AI,EACJ;QACE,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,kBAAkB,EAAE,OAAO,CAAC,kBAAkB,IAAI,IAAI;QACtD,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,CAAC;KAC9B,EACD,IAAI,EACJ,SAAS,EACT,OAAO,EACP,SAAS,CACV,CAAC;AACJ,CAAC,CAAC;AAEF,mFAAmF;AACnF,MAAM,MAAM,GAAG,CAAC,KAAc,EAAQ,EAAE;IACtC,OAAO,CAAC,IAAI,CAAC,iBAAiB,EAAE,KAAK,CAAC,CAAC;AACzC,CAAC,CAAC","sourcesContent":["/**\n * Street-level panoramas: the oriented images of a vehicle's cameras around each of its positions (Stereopolis, the\n * iTowns immersive examples), projected onto the scene around the panorama shown. Their positions and attitudes come\n * as GeoJSON points (Lambert-93 by default, altitudes NGF-IGN69 raised by the RAF20 geoid onto the IGN relief), the\n * calibration of the cameras as JSON (rotation and position in the panorama frame, intrinsics, MicMac's radial\n * distortion), the images from a URL template with `{cameraId}` and `{panoId}`.\n *\n * ```ts\n * const panoramas = await map.addPanoramas({ url, orientationsUrl, calibrationUrl });\n * await panoramas.show(panoramas.nearest([2.3345, 48.8505]).index);\n * ```\n */\nimport { getCrs } from '../data/crs.ts';\nimport { withHeaders } from '../engine/requests.ts';\nimport type { FirstPersonView, LonLat } from '../types.ts';\nimport { isNumbers, isRecord } from '../util/guards.ts';\n\nexport interface PanoramaOptions {\n /** URL of an image: `{cameraId}` and `{panoId}` replaced by a camera's id and a panorama's */\n url: string;\n /** GeoJSON points: each panorama's position, and its `id`, `heading`, `pitch`, `roll` (degrees) in properties */\n orientationsUrl: string;\n /** JSON array of the cameras: `id`, `rotation` (row-major), `position`, `projection`, `size`, `distortion` */\n calibrationUrl: string;\n /** CRS of the positions (default the GeoJSON's `crs` member, else `EPSG:2154`) */\n crs?: string;\n /** Altitudes above the geoid (NGF-IGN69), raised by the RAF20 geoid onto the IGN relief (default true in\n * Lambert-93) */\n geoid?: boolean;\n /** Radius of the sphere around the panorama its images are a backdrop on, metres (default 1000) */\n backgroundDistance?: number;\n /** 0-1 (default 1) */\n opacity?: number;\n}\n\n/** A panorama: where it is and which way the vehicle faced */\nexport interface Panorama {\n index: number;\n id: number | string;\n lonLat: LonLat;\n /** Metres above the ellipsoid */\n height: number;\n /** Degrees clockwise from north */\n heading: number;\n}\n\n/** What the map gives the panoramas */\nexport interface PanoramaHost {\n setPanorama(\n lon: number,\n lat: number,\n height: number,\n rotation: Float64Array,\n cameras: Float64Array,\n radius: number,\n opacity: number,\n ): void;\n setPanoramaImage(index: number, image: ImageBitmap): void;\n clearPanorama(): void;\n geoidHeight(lon: number, lat: number): number;\n /** The street-level eye, and setting it (undefined: back to the camera turning around a point) */\n firstPerson(): Readonly<Required<FirstPersonView>> | undefined;\n setFirstPerson(view: FirstPersonView | undefined): void;\n elevationAt(lonLat: LonLat): number | undefined;\n /** Follows the clicks on the map (with the ground clicked), the keys typed on it and its wheel (taken from the\n * map's own); returns what stops */\n listen(\n click: (lonLat: LonLat | undefined) => void,\n key: (e: KeyboardEvent) => void,\n wheel: (e: WheelEvent) => void,\n ): () => void;\n}\n\ninterface Calibration {\n id: number | string;\n rotation: number[];\n position: number[];\n projection: number[];\n size: number[];\n distortion?: { pps: number[]; poly357: number[]; limit?: number };\n}\n\ninterface Orientations {\n crs?: { properties?: { name?: string } };\n features: { geometry: { coordinates: number[] }; properties: Record<string, unknown> }[];\n}\n\nconst isOrientation = (value: unknown): value is Orientations['features'][number] =>\n isRecord(value) && isRecord(value.geometry) && isNumbers(value.geometry.coordinates) && isRecord(value.properties);\n\nconst isCrs = (value: unknown): value is Orientations['crs'] =>\n isRecord(value) &&\n (value.properties === undefined ||\n (isRecord(value.properties) && (value.properties.name === undefined || typeof value.properties.name === 'string')));\n\nconst isOrientations = (value: unknown): value is Orientations =>\n isRecord(value) &&\n (value.crs === undefined || isCrs(value.crs)) &&\n Array.isArray(value.features) &&\n value.features.every(isOrientation);\n\nconst isCalibration = (value: unknown): value is Calibration =>\n isRecord(value) &&\n (typeof value.id === 'number' || typeof value.id === 'string') &&\n isNumbers(value.rotation) &&\n isNumbers(value.position) &&\n isNumbers(value.projection) &&\n isNumbers(value.size) &&\n (value.distortion === undefined ||\n (isRecord(value.distortion) &&\n isNumbers(value.distortion.pps) &&\n isNumbers(value.distortion.poly357) &&\n (value.distortion.limit === undefined || typeof value.distortion.limit === 'number')));\n\nconst isCalibrations = (value: unknown): value is Calibration[] => Array.isArray(value) && value.every(isCalibration);\n\ninterface Attitude {\n heading: number;\n pitch: number;\n roll: number;\n}\n\nconst RAD = Math.PI / 180;\n\n/** 3 × 3 product, row-major */\nconst times = (a: number[], b: number[]): number[] =>\n Array.from({ length: 9 }, (_, i) => {\n const [r, c] = [Math.floor(i / 3), i % 3];\n\n return [0, 1, 2].reduce((sum, k) => sum + (a[r * 3 + k] ?? 0) * (b[k * 3 + c] ?? 0), 0);\n });\n\nconst rotX = (t: number) => [1, 0, 0, 0, Math.cos(t), -Math.sin(t), 0, Math.sin(t), Math.cos(t)];\nconst rotY = (t: number) => [Math.cos(t), 0, Math.sin(t), 0, 1, 0, -Math.sin(t), 0, Math.cos(t)];\nconst rotZ = (t: number) => [Math.cos(t), -Math.sin(t), 0, Math.sin(t), Math.cos(t), 0, 0, 0, 1];\n\n/**\n * The panorama frame to east, north, up (row-major): the vehicle's attitude in the CRS's grid (iTowns'\n * `quaternionFromRollPitchHeading`: Ry(-roll) · Rx(-pitch) · Rz(-heading)), turned by the meridian convergence of the\n * projection (Lambert-93: sin(46.5°) · (3° - longitude))\n */\nexport const panoramaRotation = (attitude: Attitude, lon: number, lambert93: boolean): number[] => {\n const vehicle = times(times(rotY(-attitude.roll * RAD), rotX(-attitude.pitch * RAD)), rotZ(-attitude.heading * RAD));\n const convergence = lambert93 ? Math.sin(46.5 * RAD) * (3 - lon) * RAD : 0;\n\n return times(rotZ(convergence), vehicle);\n};\n\n/** The 25 numbers of a camera for `setPanorama` */\nconst cameraNumbers = (c: Calibration): number[] => {\n const p = c.projection;\n const d = c.distortion;\n\n return [\n ...c.rotation.slice(0, 9),\n ...c.position.slice(0, 3),\n p[0] ?? 1,\n p[4] ?? 1,\n p[2] ?? 0,\n p[5] ?? 0,\n p[1] ?? 0,\n c.size[0] ?? 1,\n c.size[1] ?? 1,\n d?.pps[0] ?? 0,\n d?.pps[1] ?? 0,\n d?.poly357[0] ?? 0,\n d?.poly357[1] ?? 0,\n d?.poly357[2] ?? 0,\n d?.limit ?? 0,\n ];\n};\n\n/** The panoramas of a set, one shown at a time */\nexport class Panoramas {\n /** The panorama shown, if any */\n current: Panorama | undefined;\n private shown = 0;\n\n /** @internal */\n constructor(\n private readonly host: PanoramaHost,\n private readonly options: Required<Pick<PanoramaOptions, 'url' | 'backgroundDistance' | 'opacity'>>,\n readonly list: readonly Panorama[],\n private readonly attitudes: readonly Attitude[],\n private readonly cameras: readonly Calibration[],\n private readonly lambert93: boolean,\n ) {}\n\n /** The panorama nearest to a position */\n nearest(lonLat: LonLat): Panorama | undefined {\n const cos = Math.cos(lonLat[1] * RAD);\n\n return this.list.reduce<{ best?: Panorama; distance: number }>(\n (nearest, p) => {\n const d = ((p.lonLat[0] - lonLat[0]) * cos) ** 2 + (p.lonLat[1] - lonLat[1]) ** 2;\n\n return d < nearest.distance ? { best: p, distance: d } : nearest;\n },\n { distance: Number.POSITIVE_INFINITY },\n ).best;\n }\n\n /** Shows a panorama (its index in `list`): projected as soon as its first image arrives, the others after */\n async show(index: number): Promise<void> {\n const pano = this.list[index];\n const attitude = this.attitudes[index];\n\n if (!pano || !attitude) return;\n\n const shown = ++this.shown;\n // The images of the panorama shown before: no longer downloaded nor decoded\n const controller = new AbortController();\n\n this.loading?.abort();\n this.loading = controller;\n this.current = pano;\n\n const rotation = panoramaRotation(attitude, pano.lonLat[0], this.lambert93);\n const { url, backgroundDistance, opacity } = this.options;\n\n this.host.setPanorama(\n pano.lonLat[0],\n pano.lonLat[1],\n pano.height,\n Float64Array.from(rotation),\n Float64Array.from(this.cameras.flatMap(cameraNumbers)),\n backgroundDistance,\n opacity,\n );\n const images = Promise.all(\n this.cameras.map(async (camera, k) => {\n const src = url.replaceAll('{cameraId}', String(camera.id)).replaceAll('{panoId}', String(pano.id));\n const response = await fetch(src, withHeaders(src, { signal: controller.signal }));\n\n if (!response.ok) throw new Error(`isard: panorama image ${src}: ${response.status}`);\n\n const blob = await response.blob();\n\n if (controller.signal.aborted) return;\n\n const image = await createImageBitmap(blob, { premultiplyAlpha: 'none' });\n\n // Another panorama shown since: this image is not its\n if (shown === this.shown) this.host.setPanoramaImage(k, image);\n image.close();\n }),\n );\n\n // Another panorama shown, or this one hidden, meanwhile: not a failure\n await images.catch((error: unknown) => {\n if (!controller.signal.aborted) throw error;\n });\n }\n\n /** The downloads of the panorama shown, aborted by the next one shown or by `hide` */\n private loading: AbortController | undefined;\n\n /** Hides the panorama shown */\n hide(): void {\n this.shown++;\n this.loading?.abort();\n this.current = undefined;\n this.host.clearPanorama();\n }\n\n /** Stops the walk (`enter`) */\n private stopWalking: (() => void) | undefined;\n\n /**\n * Street-level walk from panorama to panorama (the iTowns immersive view): the eye on a panorama, the drag\n * turning it; a click goes to the panorama nearest to the clicked point, the wheel to the nearest one ahead (or\n * behind), Z and S (or Page Up and Page Down) to the next and the previous ones. Starts on the panorama `index`,\n * else the one nearest to `near`\n */\n async enter(start: { index?: number; near?: LonLat } = {}): Promise<void> {\n const first = start.index ?? (start.near && this.nearest(start.near)?.index) ?? 0;\n\n this.stopWalking?.();\n this.stopWalking = this.host.listen(\n (lonLat) => {\n const target = lonLat && this.nearest(lonLat);\n\n if (target && target !== this.current) this.go(target.index).catch(report);\n },\n (e) => {\n const step = { z: 1, Z: 1, PageUp: 1, s: -1, S: -1, PageDown: -1 }[e.key];\n\n if (!step || !this.current) return;\n e.preventDefault();\n this.go((this.current.index + step + this.list.length) % this.list.length).catch(report);\n },\n (e) => {\n // One step per notch, the next ones once it is shown\n if (this.moving || e.deltaY === 0) return;\n\n const target = this.ahead(e.deltaY < 0);\n\n if (target) {\n this.moving = true;\n this.go(target.index)\n .catch(report)\n .finally(() => {\n this.moving = false;\n });\n }\n },\n );\n await this.go(first, this.list[first]?.heading);\n }\n\n /** A step of the wheel under way */\n private moving = false;\n\n /** The nearest panorama ahead of the eye (within 60° of where it looks), or behind it */\n ahead(forward = true): Panorama | undefined {\n const eye = this.host.firstPerson();\n const here = this.current;\n\n if (!eye || !here) return undefined;\n\n const cos = Math.cos(here.lonLat[1] * RAD);\n const look = (eye.bearing + (forward ? 0 : 180)) * RAD;\n\n return this.list.reduce<{ best?: Panorama; distance: number }>(\n (nearest, p) => {\n if (p === here) return nearest;\n\n const [east, north] = [(p.lonLat[0] - here.lonLat[0]) * cos, p.lonLat[1] - here.lonLat[1]];\n const d = Math.hypot(east, north);\n const off = Math.acos(Math.max(-1, Math.min(1, (east * Math.sin(look) + north * Math.cos(look)) / (d || 1))));\n\n return off < 60 * RAD && d < nearest.distance ? { best: p, distance: d } : nearest;\n },\n { distance: Number.POSITIVE_INFINITY },\n ).best;\n }\n\n /** Goes to a panorama during the walk, the eye looking the same way (or `bearing`) */\n async go(index: number, bearing?: number): Promise<void> {\n const pano = this.list[index];\n\n if (!pano) return;\n\n const eye = this.host.firstPerson();\n // The eye at the panorama's cameras, above the ground there\n const ground = this.host.elevationAt(pano.lonLat);\n\n this.host.setFirstPerson({\n lonLat: pano.lonLat,\n height: ground === undefined ? 2.5 : Math.max(0.5, pano.height - ground),\n bearing: bearing ?? eye?.bearing ?? pano.heading,\n ...(eye ? { pitch: eye.pitch, fov: eye.fov } : {}),\n });\n await this.show(index);\n }\n\n /** Ends the walk: the panorama hidden, the camera turning around a point again, above where the eye stood */\n exit(): void {\n this.stopWalking?.();\n this.stopWalking = undefined;\n this.hide();\n this.host.setFirstPerson(undefined);\n }\n}\n\n/** Loads a set of panoramas: their positions and attitudes, the calibration of their cameras */\nexport const loadPanoramas = async (host: PanoramaHost, options: PanoramaOptions): Promise<Panoramas> => {\n const json = async <T>(src: string, is: (value: unknown) => value is T): Promise<T> => {\n const response = await fetch(src, withHeaders(src));\n\n if (!response.ok) throw new Error(`isard: ${src}: ${response.status}`);\n\n const value: unknown = await response.json();\n\n if (!is(value)) throw new Error(`isard: ${src}: unexpected content`);\n\n return value;\n };\n const [orientations, cameras] = await Promise.all([\n json(options.orientationsUrl, isOrientations),\n json(options.calibrationUrl, isCalibrations),\n ]);\n const crsName = options.crs ?? orientations.crs?.properties?.name ?? 'EPSG:2154';\n const lambert93 = /2154/.test(crsName);\n const crs = getCrs(crsName);\n const geoid = options.geoid ?? lambert93;\n const list: Panorama[] = [];\n const attitudes: Attitude[] = [];\n\n orientations.features.forEach((feature) => {\n const [x = 0, y = 0, z = 0] = feature.geometry.coordinates;\n const [lon = 0, lat = 0] = crs.inverse([x, y]);\n const p = feature.properties;\n const number = (key: string) => {\n const value = p[key];\n\n return typeof value === 'number' ? value : 0;\n };\n\n attitudes.push({ heading: number('heading'), pitch: number('pitch'), roll: number('roll') });\n list.push({\n index: list.length,\n id: typeof p.id === 'number' || typeof p.id === 'string' ? p.id : list.length,\n lonLat: [lon, lat],\n height: z + (geoid ? host.geoidHeight(lon, lat) : 0),\n heading: number('heading'),\n });\n });\n\n return new Panoramas(\n host,\n {\n url: options.url,\n backgroundDistance: options.backgroundDistance ?? 1000,\n opacity: options.opacity ?? 1,\n },\n list,\n attitudes,\n cameras,\n lambert93,\n );\n};\n\n/** A step of the walk that failed (an image not found): told, the walk going on */\nconst report = (error: unknown): void => {\n console.warn('isard: panorama', error);\n};\n"]}
@@ -33,6 +33,9 @@ export class MapWorkers {
33
33
  * another count or URL
34
34
  */
35
35
  pool(count, url) {
36
+ // Workers started after the map went would never be stopped
37
+ if (this.gone())
38
+ throw new Error('isard: the map was destroyed');
36
39
  const shared = defaultWorkerCount();
37
40
  const workers = Math.max(1, count ?? shared);
38
41
  const workerUrl = url ?? this.url;
@@ -1 +1 @@
1
- {"version":3,"file":"workers.js","sourceRoot":"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,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 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,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;Q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UAAU,KAAK,CAAC;oBAAE,MAAM,KAAK,CAAC;gBAE5D,OAAO,MAAM,EAAE,CAAC;YAClB,CAAC,CAAC,CAAC;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"]}
@@ -0,0 +1,4 @@
1
+ /** Reading a response's body within a limit */
2
+ /** A response's body if it holds no more than `limit` bytes, read no further than that; undefined past it (its
3
+ * reading stopped) */
4
+ export declare const readAtMost: (response: Response, limit: number) => Promise<Uint8Array | undefined>;
@@ -0,0 +1,28 @@
1
+ /** Reading a response's body within a limit */
2
+ /** A response's body if it holds no more than `limit` bytes, read no further than that; undefined past it (its
3
+ * reading stopped) */
4
+ export const readAtMost = async (response, limit) => {
5
+ const reader = response.body?.getReader();
6
+ if (!reader)
7
+ return new Uint8Array(await response.arrayBuffer());
8
+ const chunks = [];
9
+ let length = 0;
10
+ for (;;) {
11
+ const { done, value } = await reader.read();
12
+ if (done)
13
+ break;
14
+ length += value.length;
15
+ if (length > limit) {
16
+ await reader.cancel();
17
+ return undefined;
18
+ }
19
+ chunks.push(value);
20
+ }
21
+ const bytes = new Uint8Array(length);
22
+ chunks.reduce((at, chunk) => {
23
+ bytes.set(chunk, at);
24
+ return at + chunk.length;
25
+ }, 0);
26
+ return bytes;
27
+ };
28
+ //# sourceMappingURL=read.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read.js","sourceRoot":"","sources":["../../src/util/read.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAE/C;sBACsB;AACtB,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,EAAE,QAAkB,EAAE,KAAa,EAAmC,EAAE;IACrG,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC;IAE1C,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,UAAU,CAAC,MAAM,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC;IAEjE,MAAM,MAAM,GAAiB,EAAE,CAAC;IAChC,IAAI,MAAM,GAAG,CAAC,CAAC;IAEf,SAAS,CAAC;QACR,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;QAE5C,IAAI,IAAI;YAAE,MAAM;QAChB,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC;QACvB,IAAI,MAAM,GAAG,KAAK,EAAE,CAAC;YACnB,MAAM,MAAM,CAAC,MAAM,EAAE,CAAC;YAEtB,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;IAErC,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE;QAC1B,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAErB,OAAO,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC;IAC3B,CAAC,EAAE,CAAC,CAAC,CAAC;IAEN,OAAO,KAAK,CAAC;AACf,CAAC,CAAC","sourcesContent":["/** Reading a response's body within a limit */\n\n/** A response's body if it holds no more than `limit` bytes, read no further than that; undefined past it (its\n * reading stopped) */\nexport const readAtMost = async (response: Response, limit: number): Promise<Uint8Array | undefined> => {\n const reader = response.body?.getReader();\n\n if (!reader) return new Uint8Array(await response.arrayBuffer());\n\n const chunks: Uint8Array[] = [];\n let length = 0;\n\n for (;;) {\n const { done, value } = await reader.read();\n\n if (done) break;\n length += value.length;\n if (length > limit) {\n await reader.cancel();\n\n return undefined;\n }\n chunks.push(value);\n }\n\n const bytes = new Uint8Array(length);\n\n chunks.reduce((at, chunk) => {\n bytes.set(chunk, at);\n\n return at + chunk.length;\n }, 0);\n\n return bytes;\n};\n"]}
@@ -521,6 +521,11 @@ export class Engine {
521
521
  * Screen point (CSS pixels) of a ground position, or `height` metres above it, undefined behind the camera
522
522
  */
523
523
  project(lon: number, lat: number, height?: number | null): [x: number, y: number] | undefined;
524
+ /**
525
+ * A flow layer's second field becomes its field (the model's next hour reached): only the hour after it is then
526
+ * sent (`setFlowNext`)
527
+ */
528
+ promoteFlowNext(id: number): void;
524
529
  /**
525
530
  * Removes batch `key` of an extrusion layer (nothing if there is none)
526
531
  */
@@ -647,8 +652,8 @@ export class Engine {
647
652
  */
648
653
  setFlowField(id: number, width: number, height: number, u: Float32Array, v: Float32Array, bounds: Float64Array): void;
649
654
  /**
650
- * The field a flow layer's goes towards, on its grid (the model's next hour: east and north components, row after
651
- * row; empty: none), mixed in by `setFlowBlend`
655
+ * A flow layer's second field, on its grid (the model's next hour, or the flow of a wind towards the north: east
656
+ * and north components, row after row; empty: none), mixed in by `setFlowBlend` or `setFlowWeights`
652
657
  */
653
658
  setFlowNext(id: number, u: Float32Array, v: Float32Array): void;
654
659
  /**
@@ -657,6 +662,11 @@ export class Engine {
657
662
  * particles moving for each 100 × 100 CSS pixels of the view (at most the layer's)
658
663
  */
659
664
  setFlowStyle(id: number, speeds: Float32Array, colors: Float32Array, width: number, opacity: number, height: number, speed: number, density: number): void;
665
+ /**
666
+ * A flow layer's velocity as `a` times its field plus `b` times its second one (a wind of `a` m/s towards the east
667
+ * and `b` towards the north, from the flows of 1 m/s each way): nothing sent again but two numbers
668
+ */
669
+ setFlowWeights(id: number, a: number, b: number): void;
660
670
  /**
661
671
  * Color of the globe under the tiles (polar caps)
662
672
  */
@@ -928,9 +938,10 @@ export class Engine {
928
938
  */
929
939
  stats(): RasterLayerStats[];
930
940
  /**
931
- * Moves a flow layer's particles by `seconds` of the page's time (one animation frame), in the current view
941
+ * Moves a flow layer's particles by `seconds` of the page's time (one animation frame), in the current view;
942
+ * whether they moved (none in view, or no field: the map need not be drawn again)
932
943
  */
933
- stepFlow(id: number, seconds: number): void;
944
+ stepFlow(id: number, seconds: number): boolean;
934
945
  /**
935
946
  * The height above the relief (metres) of the top of what stands at a position (degrees): a roof, a mesh, 0 on
936
947
  * the bare ground; undefined where nothing of the last frame is there. The scene is drawn from above into a single
@@ -1052,6 +1063,7 @@ export interface InitOutput {
1052
1063
  readonly engine_pollPick: (a: number) => any;
1053
1064
  readonly engine_preload: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
1054
1065
  readonly engine_project: (a: number, b: number, c: number, d: number, e: number) => any;
1066
+ readonly engine_promoteFlowNext: (a: number, b: number) => void;
1055
1067
  readonly engine_removeExtrusionBatch: (a: number, b: number, c: number) => void;
1056
1068
  readonly engine_removeLayer: (a: number, b: number) => void;
1057
1069
  readonly engine_removeVectorTile: (a: number, b: number, c: number) => void;
@@ -1078,6 +1090,7 @@ export interface InitOutput {
1078
1090
  readonly engine_setFlowField: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => void;
1079
1091
  readonly engine_setFlowNext: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
1080
1092
  readonly engine_setFlowStyle: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => void;
1093
+ readonly engine_setFlowWeights: (a: number, b: number, c: number, d: number) => void;
1081
1094
  readonly engine_setGlobe: (a: number, b: number) => void;
1082
1095
  readonly engine_setGlobeColor: (a: number, b: number, c: number, d: number) => void;
1083
1096
  readonly engine_setGlyphAtlas: (a: number, b: number, c: number, d: number, e: number) => [number, number];
@@ -1116,7 +1129,7 @@ export interface InitOutput {
1116
1129
  readonly engine_setViewshed: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => [number, number];
1117
1130
  readonly engine_setZoomRange: (a: number, b: number, c: number) => void;
1118
1131
  readonly engine_stats: (a: number) => any;
1119
- readonly engine_stepFlow: (a: number, b: number, c: number) => void;
1132
+ readonly engine_stepFlow: (a: number, b: number, c: number) => number;
1120
1133
  readonly engine_surface: (a: number, b: number, c: number) => any;
1121
1134
  readonly engine_surfaceAt: (a: number, b: number, c: number) => any;
1122
1135
  readonly engine_textureFormats: (a: number) => any;
@@ -574,6 +574,14 @@ export class Engine {
574
574
  const ret = wasm.engine_project(this.__wbg_ptr, lon, lat, !isLikeNone(height), isLikeNone(height) ? 0 : height);
575
575
  return ret;
576
576
  }
577
+ /**
578
+ * A flow layer's second field becomes its field (the model's next hour reached): only the hour after it is then
579
+ * sent (`setFlowNext`)
580
+ * @param {number} id
581
+ */
582
+ promoteFlowNext(id) {
583
+ wasm.engine_promoteFlowNext(this.__wbg_ptr, id);
584
+ }
577
585
  /**
578
586
  * Removes batch `key` of an extrusion layer (nothing if there is none)
579
587
  * @param {number} id
@@ -882,8 +890,8 @@ export class Engine {
882
890
  wasm.engine_setFlowField(this.__wbg_ptr, id, width, height, ptr0, len0, ptr1, len1, ptr2, len2);
883
891
  }
884
892
  /**
885
- * The field a flow layer's goes towards, on its grid (the model's next hour: east and north components, row after
886
- * row; empty: none), mixed in by `setFlowBlend`
893
+ * A flow layer's second field, on its grid (the model's next hour, or the flow of a wind towards the north: east
894
+ * and north components, row after row; empty: none), mixed in by `setFlowBlend` or `setFlowWeights`
887
895
  * @param {number} id
888
896
  * @param {Float32Array} u
889
897
  * @param {Float32Array} v
@@ -915,6 +923,16 @@ export class Engine {
915
923
  const len1 = WASM_VECTOR_LEN;
916
924
  wasm.engine_setFlowStyle(this.__wbg_ptr, id, ptr0, len0, ptr1, len1, width, opacity, height, speed, density);
917
925
  }
926
+ /**
927
+ * A flow layer's velocity as `a` times its field plus `b` times its second one (a wind of `a` m/s towards the east
928
+ * and `b` towards the north, from the flows of 1 m/s each way): nothing sent again but two numbers
929
+ * @param {number} id
930
+ * @param {number} a
931
+ * @param {number} b
932
+ */
933
+ setFlowWeights(id, a, b) {
934
+ wasm.engine_setFlowWeights(this.__wbg_ptr, id, a, b);
935
+ }
918
936
  /**
919
937
  * Color of the globe under the tiles (polar caps)
920
938
  * @param {number} r
@@ -1593,12 +1611,15 @@ export class Engine {
1593
1611
  return ret;
1594
1612
  }
1595
1613
  /**
1596
- * Moves a flow layer's particles by `seconds` of the page's time (one animation frame), in the current view
1614
+ * Moves a flow layer's particles by `seconds` of the page's time (one animation frame), in the current view;
1615
+ * whether they moved (none in view, or no field: the map need not be drawn again)
1597
1616
  * @param {number} id
1598
1617
  * @param {number} seconds
1618
+ * @returns {boolean}
1599
1619
  */
1600
1620
  stepFlow(id, seconds) {
1601
- wasm.engine_stepFlow(this.__wbg_ptr, id, seconds);
1621
+ const ret = wasm.engine_stepFlow(this.__wbg_ptr, id, seconds);
1622
+ return ret !== 0;
1602
1623
  }
1603
1624
  /**
1604
1625
  * The height above the relief (metres) of the top of what stands at a position (degrees): a roof, a mesh, 0 on
@@ -267,6 +267,11 @@ export class Engine {
267
267
  * Screen point (CSS pixels) of a ground position, or `height` metres above it, undefined behind the camera
268
268
  */
269
269
  project(lon: number, lat: number, height?: number | null): [x: number, y: number] | undefined;
270
+ /**
271
+ * A flow layer's second field becomes its field (the model's next hour reached): only the hour after it is then
272
+ * sent (`setFlowNext`)
273
+ */
274
+ promoteFlowNext(id: number): void;
270
275
  /**
271
276
  * Removes batch `key` of an extrusion layer (nothing if there is none)
272
277
  */
@@ -393,8 +398,8 @@ export class Engine {
393
398
  */
394
399
  setFlowField(id: number, width: number, height: number, u: Float32Array, v: Float32Array, bounds: Float64Array): void;
395
400
  /**
396
- * The field a flow layer's goes towards, on its grid (the model's next hour: east and north components, row after
397
- * row; empty: none), mixed in by `setFlowBlend`
401
+ * A flow layer's second field, on its grid (the model's next hour, or the flow of a wind towards the north: east
402
+ * and north components, row after row; empty: none), mixed in by `setFlowBlend` or `setFlowWeights`
398
403
  */
399
404
  setFlowNext(id: number, u: Float32Array, v: Float32Array): void;
400
405
  /**
@@ -403,6 +408,11 @@ export class Engine {
403
408
  * particles moving for each 100 × 100 CSS pixels of the view (at most the layer's)
404
409
  */
405
410
  setFlowStyle(id: number, speeds: Float32Array, colors: Float32Array, width: number, opacity: number, height: number, speed: number, density: number): void;
411
+ /**
412
+ * A flow layer's velocity as `a` times its field plus `b` times its second one (a wind of `a` m/s towards the east
413
+ * and `b` towards the north, from the flows of 1 m/s each way): nothing sent again but two numbers
414
+ */
415
+ setFlowWeights(id: number, a: number, b: number): void;
406
416
  /**
407
417
  * Color of the globe under the tiles (polar caps)
408
418
  */
@@ -633,9 +643,10 @@ export class Engine {
633
643
  */
634
644
  stats(): RasterLayerStats[];
635
645
  /**
636
- * Moves a flow layer's particles by `seconds` of the page's time (one animation frame), in the current view
646
+ * Moves a flow layer's particles by `seconds` of the page's time (one animation frame), in the current view;
647
+ * whether they moved (none in view, or no field: the map need not be drawn again)
637
648
  */
638
- stepFlow(id: number, seconds: number): void;
649
+ stepFlow(id: number, seconds: number): boolean;
639
650
  /**
640
651
  * The height above the relief (metres) of the top of what stands at a position (degrees): a roof, a mesh, 0 on
641
652
  * the bare ground; undefined where nothing of the last frame is there. The scene is drawn from above into a single
@@ -720,6 +731,7 @@ export interface InitOutput {
720
731
  readonly engine_pollPick: (a: number) => any;
721
732
  readonly engine_preload: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
722
733
  readonly engine_project: (a: number, b: number, c: number, d: number, e: number) => any;
734
+ readonly engine_promoteFlowNext: (a: number, b: number) => void;
723
735
  readonly engine_removeExtrusionBatch: (a: number, b: number, c: number) => void;
724
736
  readonly engine_removeLayer: (a: number, b: number) => void;
725
737
  readonly engine_removeVectorTile: (a: number, b: number, c: number) => void;
@@ -746,6 +758,7 @@ export interface InitOutput {
746
758
  readonly engine_setFlowField: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => void;
747
759
  readonly engine_setFlowNext: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
748
760
  readonly engine_setFlowStyle: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => void;
761
+ readonly engine_setFlowWeights: (a: number, b: number, c: number, d: number) => void;
749
762
  readonly engine_setGlobe: (a: number, b: number) => void;
750
763
  readonly engine_setGlobeColor: (a: number, b: number, c: number, d: number) => void;
751
764
  readonly engine_setGlyphAtlas: (a: number, b: number, c: number, d: number, e: number) => [number, number];
@@ -778,7 +791,7 @@ export interface InitOutput {
778
791
  readonly engine_setViewshed: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => [number, number];
779
792
  readonly engine_setZoomRange: (a: number, b: number, c: number) => void;
780
793
  readonly engine_stats: (a: number) => any;
781
- readonly engine_stepFlow: (a: number, b: number, c: number) => void;
794
+ readonly engine_stepFlow: (a: number, b: number, c: number) => number;
782
795
  readonly engine_surface: (a: number, b: number, c: number) => any;
783
796
  readonly engine_surfaceAt: (a: number, b: number, c: number) => any;
784
797
  readonly engine_updateGlyphAtlas: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
@@ -469,6 +469,14 @@ export class Engine {
469
469
  const ret = wasm.engine_project(this.__wbg_ptr, lon, lat, !isLikeNone(height), isLikeNone(height) ? 0 : height);
470
470
  return ret;
471
471
  }
472
+ /**
473
+ * A flow layer's second field becomes its field (the model's next hour reached): only the hour after it is then
474
+ * sent (`setFlowNext`)
475
+ * @param {number} id
476
+ */
477
+ promoteFlowNext(id) {
478
+ wasm.engine_promoteFlowNext(this.__wbg_ptr, id);
479
+ }
472
480
  /**
473
481
  * Removes batch `key` of an extrusion layer (nothing if there is none)
474
482
  * @param {number} id
@@ -777,8 +785,8 @@ export class Engine {
777
785
  wasm.engine_setFlowField(this.__wbg_ptr, id, width, height, ptr0, len0, ptr1, len1, ptr2, len2);
778
786
  }
779
787
  /**
780
- * The field a flow layer's goes towards, on its grid (the model's next hour: east and north components, row after
781
- * row; empty: none), mixed in by `setFlowBlend`
788
+ * A flow layer's second field, on its grid (the model's next hour, or the flow of a wind towards the north: east
789
+ * and north components, row after row; empty: none), mixed in by `setFlowBlend` or `setFlowWeights`
782
790
  * @param {number} id
783
791
  * @param {Float32Array} u
784
792
  * @param {Float32Array} v
@@ -810,6 +818,16 @@ export class Engine {
810
818
  const len1 = WASM_VECTOR_LEN;
811
819
  wasm.engine_setFlowStyle(this.__wbg_ptr, id, ptr0, len0, ptr1, len1, width, opacity, height, speed, density);
812
820
  }
821
+ /**
822
+ * A flow layer's velocity as `a` times its field plus `b` times its second one (a wind of `a` m/s towards the east
823
+ * and `b` towards the north, from the flows of 1 m/s each way): nothing sent again but two numbers
824
+ * @param {number} id
825
+ * @param {number} a
826
+ * @param {number} b
827
+ */
828
+ setFlowWeights(id, a, b) {
829
+ wasm.engine_setFlowWeights(this.__wbg_ptr, id, a, b);
830
+ }
813
831
  /**
814
832
  * Color of the globe under the tiles (polar caps)
815
833
  * @param {number} r
@@ -1393,12 +1411,15 @@ export class Engine {
1393
1411
  return ret;
1394
1412
  }
1395
1413
  /**
1396
- * Moves a flow layer's particles by `seconds` of the page's time (one animation frame), in the current view
1414
+ * Moves a flow layer's particles by `seconds` of the page's time (one animation frame), in the current view;
1415
+ * whether they moved (none in view, or no field: the map need not be drawn again)
1397
1416
  * @param {number} id
1398
1417
  * @param {number} seconds
1418
+ * @returns {boolean}
1399
1419
  */
1400
1420
  stepFlow(id, seconds) {
1401
- wasm.engine_stepFlow(this.__wbg_ptr, id, seconds);
1421
+ const ret = wasm.engine_stepFlow(this.__wbg_ptr, id, seconds);
1422
+ return ret !== 0;
1402
1423
  }
1403
1424
  /**
1404
1425
  * The height above the relief (metres) of the top of what stands at a position (degrees): a roof, a mesh, 0 on
@@ -2,7 +2,7 @@
2
2
  * the flow round them for a wind towards the east and one towards the north (the grid module) */
3
3
  import { type StreetFlows } from '../../grid-module.ts';
4
4
  import type { Priority } from '../basemap.worker.ts';
5
- import type { Renderer } from './tiles.ts';
5
+ import { type Renderer } from './tiles.ts';
6
6
  /** What a street flow is asked with: its square (Mercator: west, north, east, south) and grid, the tiles of level `z`
7
7
  * over it (x, y pairs), the sweeps, the grid module's URL */
8
8
  export interface StreetWork {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isard",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "A WebGL2 map engine for large, interactive data layers, labels and 3D Tiles over raster or vector basemaps (Rust core in WebAssembly)",
5
5
  "license": "MIT",
6
6
  "author": "Kevin Graff",