isard 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/{basemaps.d.ts → basemap/basemaps.d.ts} +2 -2
  3. package/dist/{basemaps.js → basemap/basemaps.js} +1 -1
  4. package/dist/basemap/basemaps.js.map +1 -0
  5. package/dist/{grid.d.ts → basemap/grid.d.ts} +1 -1
  6. package/dist/{grid.js → basemap/grid.js} +2 -2
  7. package/dist/basemap/grid.js.map +1 -0
  8. package/dist/basemap/mvt.js.map +1 -0
  9. package/dist/{pmtiles.d.ts → basemap/pmtiles.d.ts} +6 -0
  10. package/dist/{pmtiles.js → basemap/pmtiles.js} +2 -2
  11. package/dist/basemap/pmtiles.js.map +1 -0
  12. package/dist/{resample.d.ts → basemap/resample.d.ts} +9 -0
  13. package/dist/{resample.js → basemap/resample.js} +2 -2
  14. package/dist/basemap/resample.js.map +1 -0
  15. package/dist/{terrain.js → basemap/terrain.js} +1 -1
  16. package/dist/basemap/terrain.js.map +1 -0
  17. package/dist/{vectorstyle.js → basemap/vectorstyle.js} +1 -1
  18. package/dist/basemap/vectorstyle.js.map +1 -0
  19. package/dist/{vectortiles.d.ts → basemap/vectortiles.d.ts} +7 -7
  20. package/dist/{vectortiles.js → basemap/vectortiles.js} +16 -6
  21. package/dist/basemap/vectortiles.js.map +1 -0
  22. package/dist/{wmts.js → basemap/wmts.js} +3 -3
  23. package/dist/basemap/wmts.js.map +1 -0
  24. package/dist/basemap.worker.js +2 -2
  25. package/dist/basemap.worker.js.map +10 -10
  26. package/dist/bind/layers.d.ts +37 -0
  27. package/dist/bind/layers.js +130 -0
  28. package/dist/bind/layers.js.map +1 -0
  29. package/dist/{crs.d.ts → data/crs.d.ts} +1 -1
  30. package/dist/data/crs.js.map +1 -0
  31. package/dist/{gpx.d.ts → data/gpx.d.ts} +1 -1
  32. package/dist/data/gpx.js.map +1 -0
  33. package/dist/{kml.d.ts → data/kml.d.ts} +1 -1
  34. package/dist/data/kml.js.map +1 -0
  35. package/dist/{topojson.d.ts → data/topojson.d.ts} +1 -1
  36. package/dist/data/topojson.js.map +1 -0
  37. package/dist/data/xml.js.map +1 -0
  38. package/dist/decoder.worker.js +1 -1
  39. package/dist/decoder.worker.js.map +4 -4
  40. package/dist/{decoders.d.ts → engine/decoders.d.ts} +1 -1
  41. package/dist/engine/decoders.js.map +1 -0
  42. package/dist/{loader.d.ts → engine/loader.d.ts} +1 -1
  43. package/dist/{loader.js → engine/loader.js} +4 -0
  44. package/dist/engine/loader.js.map +1 -0
  45. package/dist/{protocol.d.ts → engine/protocol.d.ts} +1 -1
  46. package/dist/engine/protocol.js +3 -0
  47. package/dist/engine/protocol.js.map +1 -0
  48. package/dist/engine/requests.js.map +1 -0
  49. package/dist/engine-loader.d.ts +5 -1
  50. package/dist/engine-loader.js +3 -3
  51. package/dist/engine-loader.js.map +1 -1
  52. package/dist/formats.d.ts +3 -3
  53. package/dist/formats.js +3 -3
  54. package/dist/formats.js.map +1 -1
  55. package/dist/geoplateforme.d.ts +3 -3
  56. package/dist/geoplateforme.js +1 -1
  57. package/dist/geoplateforme.js.map +1 -1
  58. package/dist/index.d.ts +29 -29
  59. package/dist/index.js +18 -18
  60. package/dist/index.js.map +1 -1
  61. package/dist/isard_bg.wasm +0 -0
  62. package/dist/isard_core_bg.wasm +0 -0
  63. package/dist/layers/extrusions.js.map +1 -0
  64. package/dist/{features.js → layers/features.js} +3 -3
  65. package/dist/layers/features.js.map +1 -0
  66. package/dist/{glyphs.d.ts → layers/glyphs.d.ts} +3 -3
  67. package/dist/{glyphs.js → layers/glyphs.js} +11 -1
  68. package/dist/layers/glyphs.js.map +1 -0
  69. package/dist/{icons.d.ts → layers/icons.d.ts} +2 -2
  70. package/dist/{icons.js → layers/icons.js} +8 -1
  71. package/dist/layers/icons.js.map +1 -0
  72. package/dist/{layers.d.ts → layers/layers.d.ts} +8 -3
  73. package/dist/{layers.js → layers/layers.js} +2 -2
  74. package/dist/layers/layers.js.map +1 -0
  75. package/dist/{panoramas.d.ts → layers/panoramas.d.ts} +1 -1
  76. package/dist/{panoramas.js → layers/panoramas.js} +2 -2
  77. package/dist/layers/panoramas.js.map +1 -0
  78. package/dist/{pointclouds.d.ts → layers/pointclouds.d.ts} +2 -2
  79. package/dist/{pointclouds.js → layers/pointclouds.js} +1 -1
  80. package/dist/layers/pointclouds.js.map +1 -0
  81. package/dist/{symbols.d.ts → layers/symbols.d.ts} +2 -2
  82. package/dist/{symbols.js → layers/symbols.js} +1 -1
  83. package/dist/layers/symbols.js.map +1 -0
  84. package/dist/map.d.ts +15 -9
  85. package/dist/map.js +27 -17
  86. package/dist/map.js.map +1 -1
  87. package/dist/projections.d.ts +3 -3
  88. package/dist/projections.js +2 -2
  89. package/dist/projections.js.map +1 -1
  90. package/dist/react/index.d.ts +119 -0
  91. package/dist/react/index.js +409 -0
  92. package/dist/react/index.js.map +1 -0
  93. package/dist/settings.d.ts +1 -1
  94. package/dist/settings.js +2 -2
  95. package/dist/settings.js.map +1 -1
  96. package/dist/types.d.ts +5 -5
  97. package/dist/types.js +1 -0
  98. package/dist/types.js.map +1 -1
  99. package/dist/{controls.d.ts → ui/controls.d.ts} +1 -1
  100. package/dist/ui/controls.js.map +1 -0
  101. package/dist/{interaction.d.ts → ui/interaction.d.ts} +7 -3
  102. package/dist/{interaction.js → ui/interaction.js} +1 -1
  103. package/dist/ui/interaction.js.map +1 -0
  104. package/dist/{overlay.d.ts → ui/overlay.d.ts} +2 -2
  105. package/dist/ui/overlay.js.map +1 -0
  106. package/dist/ui/style.js.map +1 -0
  107. package/dist/{animation.d.ts → util/animation.d.ts} +6 -2
  108. package/dist/util/animation.js.map +1 -0
  109. package/dist/util/color.js.map +1 -0
  110. package/dist/util/geo.js.map +1 -0
  111. package/dist/util/lru.js.map +1 -0
  112. package/dist/{basemap.worker.d.ts → workers/basemap.worker.d.ts} +14 -4
  113. package/dist/workers/basemap.worker.js +647 -0
  114. package/dist/workers/basemap.worker.js.map +1 -0
  115. package/package.json +24 -1
  116. package/vite.js +1 -1
  117. package/dist/animation.js.map +0 -1
  118. package/dist/basemaps.js.map +0 -1
  119. package/dist/color.js.map +0 -1
  120. package/dist/controls.js.map +0 -1
  121. package/dist/crs.js.map +0 -1
  122. package/dist/decoders.js.map +0 -1
  123. package/dist/extrusions.js.map +0 -1
  124. package/dist/features.js.map +0 -1
  125. package/dist/geo.js.map +0 -1
  126. package/dist/glyphs.js.map +0 -1
  127. package/dist/gpx.js.map +0 -1
  128. package/dist/grid.js.map +0 -1
  129. package/dist/icons.js.map +0 -1
  130. package/dist/interaction.js.map +0 -1
  131. package/dist/kml.js.map +0 -1
  132. package/dist/layers.js.map +0 -1
  133. package/dist/loader.js.map +0 -1
  134. package/dist/lru.js.map +0 -1
  135. package/dist/mvt.js.map +0 -1
  136. package/dist/overlay.js.map +0 -1
  137. package/dist/panoramas.js.map +0 -1
  138. package/dist/pmtiles.js.map +0 -1
  139. package/dist/pointclouds.js.map +0 -1
  140. package/dist/protocol.js +0 -2
  141. package/dist/protocol.js.map +0 -1
  142. package/dist/requests.js.map +0 -1
  143. package/dist/resample.js.map +0 -1
  144. package/dist/style.js.map +0 -1
  145. package/dist/symbols.js.map +0 -1
  146. package/dist/terrain.js.map +0 -1
  147. package/dist/topojson.js.map +0 -1
  148. package/dist/vectorstyle.js.map +0 -1
  149. package/dist/vectortiles.js.map +0 -1
  150. package/dist/wmts.js.map +0 -1
  151. package/dist/xml.js.map +0 -1
  152. /package/dist/{mvt.d.ts → basemap/mvt.d.ts} +0 -0
  153. /package/dist/{mvt.js → basemap/mvt.js} +0 -0
  154. /package/dist/{terrain.d.ts → basemap/terrain.d.ts} +0 -0
  155. /package/dist/{vectorstyle.d.ts → basemap/vectorstyle.d.ts} +0 -0
  156. /package/dist/{wmts.d.ts → basemap/wmts.d.ts} +0 -0
  157. /package/dist/{crs.js → data/crs.js} +0 -0
  158. /package/dist/{gpx.js → data/gpx.js} +0 -0
  159. /package/dist/{kml.js → data/kml.js} +0 -0
  160. /package/dist/{topojson.js → data/topojson.js} +0 -0
  161. /package/dist/{xml.d.ts → data/xml.d.ts} +0 -0
  162. /package/dist/{xml.js → data/xml.js} +0 -0
  163. /package/dist/{decoders.js → engine/decoders.js} +0 -0
  164. /package/dist/{requests.d.ts → engine/requests.d.ts} +0 -0
  165. /package/dist/{requests.js → engine/requests.js} +0 -0
  166. /package/dist/{extrusions.d.ts → layers/extrusions.d.ts} +0 -0
  167. /package/dist/{extrusions.js → layers/extrusions.js} +0 -0
  168. /package/dist/{features.d.ts → layers/features.d.ts} +0 -0
  169. /package/dist/{controls.js → ui/controls.js} +0 -0
  170. /package/dist/{overlay.js → ui/overlay.js} +0 -0
  171. /package/dist/{style.d.ts → ui/style.d.ts} +0 -0
  172. /package/dist/{style.js → ui/style.js} +0 -0
  173. /package/dist/{animation.js → util/animation.js} +0 -0
  174. /package/dist/{color.d.ts → util/color.d.ts} +0 -0
  175. /package/dist/{color.js → util/color.js} +0 -0
  176. /package/dist/{geo.d.ts → util/geo.d.ts} +0 -0
  177. /package/dist/{geo.js → util/geo.js} +0 -0
  178. /package/dist/{lru.d.ts → util/lru.d.ts} +0 -0
  179. /package/dist/{lru.js → util/lru.js} +0 -0
@@ -4,9 +4,9 @@
4
4
  * returning either, evaluated once per feature when the data or the style change: the engine keeps the result in
5
5
  * textures, and restyling, recoloring by values or filtering never touches the geometry.
6
6
  */
7
- import { parseCssColor } from "./color.js";
8
- import { crsOf, reproject } from "./crs.js";
9
- import { mercatorX, mercatorY } from "./geo.js";
7
+ import { crsOf, reproject } from "../data/crs.js";
8
+ import { parseCssColor } from "../util/color.js";
9
+ import { mercatorX, mercatorY } from "../util/geo.js";
10
10
  import { Layer } from "./layers.js";
11
11
  const BASE = {
12
12
  opacity: 1,
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features.js","sourceRoot":"","sources":["../../src/layers/features.ts"],"names":[],"m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AAC;AACJ,CAAC;AAED,MAAM,UAAU,SAAS,CAAI,OAAuB;IAClD,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IACjD,OAAO,EAAE,GAAI,IAA6B,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,CAAC;AACvE,CAAC","sourcesContent":["/**\n * Feature layers: lines, circles and fills from GeoJSON, styled per feature. A style value is a constant, zoom stops\n * (`[[zoom, value], …]`, linear in between, as MapLibre's `interpolate linear zoom`), or a function of the feature\n * returning either, evaluated once per feature when the data or the style change: the engine keeps the result in\n * textures, and restyling, recoloring by values or filtering never touches the geometry.\n */\n\nimport { crsOf, reproject } from '../data/crs.ts';\nimport type { LayerHost } from '../types.ts';\nimport { parseCssColor } from '../util/color.ts';\nimport { mercatorX, mercatorY } from '../util/geo.ts';\nimport type { Engine } from '../wasm/isard.js';\nimport { Layer } from './layers.ts';\n\n// ── GeoJSON (the parts used here) ──\n\nexport type Position = [lon: number, lat: number, ...rest: number[]];\nexport type Geometry =\n | { type: 'Point'; coordinates: Position }\n | { type: 'MultiPoint'; coordinates: Position[] }\n | { type: 'LineString'; coordinates: Position[] }\n | { type: 'MultiLineString'; coordinates: Position[][] }\n | { type: 'Polygon'; coordinates: Position[][] }\n | { type: 'MultiPolygon'; coordinates: Position[][][] }\n | { type: 'GeometryCollection'; geometries: Geometry[] };\nexport type Properties = Record<string, unknown>;\nexport interface Feature<P = Properties> {\n type: 'Feature';\n geometry: Geometry | null;\n properties: P;\n id?: string | number;\n}\nexport interface FeatureCollection<P = Properties> {\n type: 'FeatureCollection';\n features: Feature<P>[];\n /** The CRS of the coordinates, a legacy member (GeoJSON of 2008, the output of a WFS in another CRS): the feature\n * layers reproject a collection that names one (see `reproject`) */\n crs?: { type: 'name'; properties: { name: string } };\n}\n/** What a feature layer takes: a collection, its features, or one feature */\nexport type FeatureData<P = Properties> = FeatureCollection<P> | Feature<P>[] | Feature<P>;\n\n// ── Style values ──\n\n/** Zoom stops: `[[zoom, value], …]` in increasing zooms, up to four, linear in between, constant outside */\nexport type Stops = [zoom: number, value: number][];\n/** A size: CSS pixels, or zoom stops */\nexport type Size = number | Stops;\n/** A value for all features, or a function of each feature (its properties and its index in the data) */\nexport type Styled<T, P = Properties> = T | ((properties: P, index: number) => T);\n/** Colors of values: `[[value, color], …]` in increasing values, linear in between */\nexport type Ramp = [value: number, color: string][];\n\nexport interface FeatureLayerStyle<P = Properties> {\n /** Layer opacity, 0 to 1, or zoom stops (a layer fading in past a zoom) (default 1) */\n opacity: Size;\n /** Zooms the layer shows in: from `minZoom` (included) to `maxZoom` (excluded) */\n minZoom: number;\n maxZoom: number;\n visible: boolean;\n /** Features drawn; the others hidden (default all) */\n filter: ((properties: P, index: number) => boolean) | undefined;\n /** Colors of the values given by `setValues`: a feature with a value takes its color here, the others keep theirs */\n ramp: Ramp | undefined;\n}\n\nexport interface LineStyle<P = Properties> extends FeatureLayerStyle<P> {\n /** CSS color: `#rgb`, `#rrggbb`, `#rrggbbaa`, `rgb()`, `rgba()` (default `#000`) */\n color: Styled<string, P>;\n /** CSS pixels (default 1) */\n width: Styled<Size, P>;\n /** Dash and gap, in line widths (MapLibre's `line-dasharray`); undefined: solid */\n dash: [dash: number, gap: number] | undefined;\n}\n\nexport interface CircleStyle<P = Properties> extends FeatureLayerStyle<P> {\n color: Styled<string, P>;\n /** CSS pixels (default 5) */\n radius: Styled<Size, P>;\n strokeColor: Styled<string, P>;\n /** CSS pixels (default 0) */\n strokeWidth: Styled<Size, P>;\n /** `'viewport'` (default): discs facing the screen; `'map'`: lying on the ground (MapLibre's\n * `circle-pitch-alignment`) */\n alignment: 'viewport' | 'map';\n}\n\nexport interface FillStyle<P = Properties> extends FeatureLayerStyle<P> {\n color: Styled<string, P>;\n}\n\n/** Where a new layer goes: under `before`, or on top of the others */\nexport interface Placement {\n before?: Layer;\n}\n\nexport interface LineOptions<P = Properties> extends Partial<LineStyle<P>>, Placement {\n /** LineString and MultiLineString features; the rings of Polygon and MultiPolygon features are drawn as lines */\n data: FeatureData<P>;\n}\nexport interface CircleOptions<P = Properties> extends Partial<CircleStyle<P>>, Placement {\n /** Point and MultiPoint features */\n data: FeatureData<P>;\n}\nexport interface FillOptions<P = Properties> extends Partial<FillStyle<P>>, Placement {\n /** Polygon and MultiPolygon features */\n data: FeatureData<P>;\n}\n\nconst BASE: FeatureLayerStyle = {\n opacity: 1,\n minZoom: 0,\n maxZoom: 24,\n visible: true,\n filter: undefined,\n ramp: undefined,\n};\n\n// ── Colors ──\n\n/** A CSS color to RGBA 0-1 (see `parseCssColor`); black if unknown or missing */\nexport function parseColor(color: string): [r: number, g: number, b: number, a: number] {\n return parseCssColor(color) ?? [0, 0, 0, 1];\n}\n\n/** 256 RGBA texels of a ramp over its value range, and that range */\nexport function rampTexels(ramp: Ramp): { rgba: Uint8Array; min: number; max: number } {\n const stops = ramp.map(([v, c]) => [v, parseColor(c)] as const).sort((a, b) => a[0] - b[0]);\n const min = stops[0]?.[0] ?? 0;\n const max = stops.at(-1)?.[0] ?? 1;\n const rgba = new Uint8Array(256 * 4);\n for (let i = 0; i < 256; i += 1) {\n const v = min + ((max - min) * i) / 255;\n let k = 0;\n while (k + 1 < stops.length && (stops[k + 1]?.[0] ?? 0) < v) k += 1;\n const [v0, c0] = stops[k] ?? [min, [0, 0, 0, 1]];\n const [v1, c1] = stops[k + 1] ?? [v0, c0];\n const t = v1 > v0 ? Math.max(0, Math.min(1, (v - v0) / (v1 - v0))) : 0;\n for (let j = 0; j < 4; j += 1)\n rgba[i * 4 + j] = Math.round(((c0[j] ?? 0) + ((c1[j] ?? 0) - (c0[j] ?? 0)) * t) * 255);\n }\n return { rgba, min, max };\n}\n\n/** Up to four stops as zooms then values, constant if a number */\nexport function stops(size: Size): [number, number, number, number, number, number, number, number] {\n if (!Array.isArray(size)) {\n // A style function may return nothing for a feature without the property: 0\n const v = Number.isFinite(size) ? size : 0;\n return [0, 0, 0, 0, v, v, v, v];\n }\n // More than four: resampled at four zooms over their range\n let s = size;\n if (s.length > 4) {\n const z0 = s[0]?.[0] ?? 0;\n const z1 = s.at(-1)?.[0] ?? 0;\n s = [0, 1, 2, 3].map((k): [number, number] => {\n const z = z0 + ((z1 - z0) * k) / 3;\n return [z, interpolate(size, z)];\n });\n }\n const at = (k: number) => s[Math.min(k, s.length - 1)] ?? [0, 0];\n return [at(0)[0], at(1)[0], at(2)[0], at(3)[0], at(0)[1], at(1)[1], at(2)[1], at(3)[1]];\n}\n\n/** Value of zoom stops at a zoom */\nexport function interpolate(size: Size, zoom: number): number {\n if (typeof size === 'number') return size;\n const first = size[0];\n if (!first) return 0;\n if (zoom <= first[0]) return first[1];\n for (let k = 1; k < size.length; k += 1) {\n const [z0, v0] = size[k - 1] ?? first;\n const [z1, v1] = size[k] ?? first;\n if (zoom <= z1) return v0 + ((v1 - v0) * (zoom - z0)) / Math.max(z1 - z0, 1e-9);\n }\n return size.at(-1)?.[1] ?? 0;\n}\n\nexport function evaluate<T, P>(value: Styled<T, P>, properties: P, index: number): T {\n return typeof value === 'function' ? (value as (p: P, i: number) => T)(properties, index) : value;\n}\n\n// ── Geometry ──\n\n/** Collections in another CRS, reprojected once (the layers read their data again) */\nconst reprojected = new WeakMap<object, Feature<unknown>[]>();\n\nexport function featuresOf<P>(data: FeatureData<P>): Feature<P>[] {\n if (Array.isArray(data)) return data;\n if (data.type !== 'FeatureCollection') return [data];\n if (crsOf(data) === undefined) return data.features;\n let features = reprojected.get(data) as Feature<P>[] | undefined;\n if (!features) {\n features = reproject(data).features;\n reprojected.set(data, features);\n }\n return features;\n}\n\n/** Every geometry of a feature, collections flattened */\nfunction* geometries(geometry: Geometry | null): Generator<Geometry> {\n if (!geometry) return;\n if (geometry.type === 'GeometryCollection') for (const g of geometry.geometries) yield* geometries(g);\n else yield geometry;\n}\n\n/** A growable typed array */\nclass Grow<T extends Float64Array | Uint32Array> {\n length = 0;\n constructor(public data: T) {}\n push(...values: number[]): void {\n if (this.length + values.length > this.data.length) {\n const next = new (this.data.constructor as new (n: number) => T)(\n Math.max(16, this.data.length * 2, this.length + values.length),\n );\n next.set(this.data);\n this.data = next;\n }\n for (const v of values) this.data[this.length++] = v;\n }\n done(): T {\n return this.data.subarray(0, this.length) as T;\n }\n}\n\n/** Lines of the features: points (Mercator), first point of each line, feature of each line */\nfunction lineGeometry(features: Feature<unknown>[]) {\n const points = new Grow(new Float64Array(1024));\n const start = new Grow(new Uint32Array(64));\n const feature = new Grow(new Uint32Array(64));\n const line = (coords: Position[], f: number) => {\n start.push(points.length / 2);\n feature.push(f);\n for (const [lon, lat] of coords) points.push(mercatorX(lon), mercatorY(lat));\n };\n features.forEach((f, i) => {\n for (const g of geometries(f.geometry)) {\n if (g.type === 'LineString') line(g.coordinates, i);\n else if (g.type === 'MultiLineString') for (const l of g.coordinates) line(l, i);\n else if (g.type === 'Polygon') for (const r of g.coordinates) line(r, i);\n else if (g.type === 'MultiPolygon') for (const p of g.coordinates) for (const r of p) line(r, i);\n }\n });\n start.push(points.length / 2);\n return { points: points.done(), start: start.done(), feature: feature.done() };\n}\n\nfunction pointGeometry(features: Feature<unknown>[]) {\n const points = new Grow(new Float64Array(1024));\n const feature = new Grow(new Uint32Array(64));\n const point = ([lon, lat]: Position, f: number) => {\n points.push(mercatorX(lon), mercatorY(lat));\n feature.push(f);\n };\n features.forEach((f, i) => {\n for (const g of geometries(f.geometry)) {\n if (g.type === 'Point') point(g.coordinates, i);\n else if (g.type === 'MultiPoint') for (const p of g.coordinates) point(p, i);\n }\n });\n return { points: points.done(), feature: feature.done() };\n}\n\nexport function polygonGeometry(features: Feature<unknown>[]) {\n const points = new Grow(new Float64Array(1024));\n const ringStart = new Grow(new Uint32Array(64));\n const polygonStart = new Grow(new Uint32Array(64));\n const feature = new Grow(new Uint32Array(64));\n const polygon = (rings: Position[][], f: number) => {\n polygonStart.push(ringStart.length);\n feature.push(f);\n for (const ring of rings) {\n ringStart.push(points.length / 2);\n for (const [lon, lat] of ring) points.push(mercatorX(lon), mercatorY(lat));\n }\n };\n features.forEach((f, i) => {\n for (const g of geometries(f.geometry)) {\n if (g.type === 'Polygon') polygon(g.coordinates, i);\n else if (g.type === 'MultiPolygon') for (const p of g.coordinates) polygon(p, i);\n }\n });\n ringStart.push(points.length / 2);\n polygonStart.push(ringStart.length - 1);\n return {\n points: points.done(),\n ringStart: ringStart.done(),\n polygonStart: polygonStart.done(),\n feature: feature.done(),\n };\n}\n\n// ── Layers ──\n\n/** Floats per feature in the engine's style (see `setFeatureStyle`) */\nexport const FLOATS = 32;\n\n/** What every feature layer shares: its data, its style in the engine, values, filter */\nexport abstract class FeatureLayer<P, S extends FeatureLayerStyle<P>> extends Layer {\n protected list: Feature<P>[];\n protected values: Float32Array | undefined;\n\n /** @internal */\n constructor(\n map: LayerHost,\n data: FeatureData<P>,\n protected style: S,\n ) {\n super(map);\n this.list = featuresOf(data);\n }\n\n /** The features, in the order of the data (their index is what `pick` returns) */\n get features(): readonly Feature<P>[] {\n return this.list;\n }\n\n /** The feature of a picked index */\n featureAt(index: number): Feature<P> | undefined {\n return this.list[index];\n }\n\n /** Replaces the features; the style is evaluated again for them */\n setData(data: FeatureData<P>): void {\n const before = this.list.length;\n this.list = featuresOf(data);\n if (this.list.length !== before) this.values = undefined;\n // A new feature count needs new textures: the layer is created again at its place\n if (this.list.length !== before) this.recreate();\n else {\n this.upload(this.map.engine, this.id);\n this.applyStyle(this.map.engine, this.id);\n }\n this.map.requestRender();\n }\n\n setStyle(style: Partial<S>): void {\n this.style = { ...this.style, ...style };\n this.applyStyle(this.map.engine, this.id);\n this.map.requestRender();\n }\n\n /** One value per feature (in data order), colored through the style's `ramp`; NaN keeps a feature's color */\n setValues(values: Float32Array | undefined): void {\n this.values = values;\n this.map.engine.setFeatureValues(this.id, values ?? new Float32Array(this.list.length).fill(Number.NaN));\n this.map.requestRender();\n }\n\n /** Shows only the features the predicate keeps; undefined shows them all */\n setFilter(filter: ((properties: P, index: number) => boolean) | undefined): void {\n this.style = { ...this.style, filter };\n this.map.engine.setFeatureMask(this.id, this.mask());\n this.map.requestRender();\n }\n\n setVisible(visible: boolean): void {\n this.setStyle({ visible } as Partial<S>);\n }\n\n private mask(): Uint8Array {\n const { filter } = this.style;\n const mask = new Uint8Array(this.list.length).fill(255);\n if (filter)\n this.list.forEach((f, i) => {\n if (!filter(f.properties, i)) mask[i] = 0;\n });\n return mask;\n }\n\n /** Recreated in the engine at the same place (a new feature count) */\n private recreate(): void {\n const engine = this.map.engine;\n const old = this.id;\n this.attach(engine);\n this.map.replaceLayer(this, old);\n }\n\n /** @internal */\n protected create(engine: Engine): number {\n const id = this.add(engine);\n this.applyStyle(engine, id);\n if (this.values) engine.setFeatureValues(id, this.values);\n return id;\n }\n\n /** @internal Adds the geometry to the engine, returns the layer id */\n protected abstract add(engine: Engine): number;\n /** @internal Sends the geometry again (same feature count) */\n protected abstract upload(engine: Engine, id: number): void;\n /** Two colors and two sizes of a feature */\n protected abstract featureStyle(\n properties: P,\n index: number,\n ): [color: string, second: string, size: Size, second: Size];\n /** @internal Layer-specific settings (dashes, alignment) */\n protected abstract applyExtra(engine: Engine, id: number): void;\n\n /** @internal */\n protected applyStyle(engine: Engine, id: number): void {\n const out = new Float32Array(this.list.length * FLOATS);\n this.list.forEach((f, i) => {\n const [color, second, size, size2] = this.featureStyle(f.properties, i);\n const o = i * FLOATS;\n out.set(parseColor(color), o);\n out.set(parseColor(second), o + 4);\n out.set(stops(size), o + 8);\n out.set(stops(size2), o + 16);\n });\n engine.setFeatureStyle(id, out);\n engine.setFeatureMask(id, this.mask());\n const { ramp, opacity, minZoom, maxZoom, visible } = this.style;\n const r = ramp && rampTexels(ramp);\n engine.setFeatureRamp(id, r?.rgba, r?.min ?? 0, r?.max ?? 1);\n engine.setFeatureLayer(id, Float32Array.from(stops(opacity)), minZoom, maxZoom, visible);\n this.applyExtra(engine, id);\n }\n}\n\nexport class LineLayer<P = Properties> extends FeatureLayer<P, LineStyle<P>> {\n /** @internal */\n protected add(engine: Engine): number {\n const g = lineGeometry(this.list);\n return engine.addLines(g.points, g.start, g.feature, this.list.length);\n }\n\n /** @internal */\n protected upload(engine: Engine, id: number): void {\n const g = lineGeometry(this.list);\n engine.setLines(id, g.points, g.start, g.feature);\n }\n\n protected featureStyle(properties: P, index: number): [string, string, Size, Size] {\n const { color, width } = this.style;\n return [evaluate(color, properties, index), '#000', evaluate(width, properties, index), 0];\n }\n\n /** @internal */\n protected applyExtra(engine: Engine, id: number): void {\n const [dash, gap] = this.style.dash ?? [0, 0];\n engine.setLineDash(id, dash, gap);\n }\n}\n\nexport class CircleLayer<P = Properties> extends FeatureLayer<P, CircleStyle<P>> {\n /** @internal */\n protected add(engine: Engine): number {\n const g = pointGeometry(this.list);\n return engine.addCircles(g.points, g.feature, this.list.length);\n }\n\n /** @internal */\n protected upload(engine: Engine, id: number): void {\n const g = pointGeometry(this.list);\n engine.setCircles(id, g.points, g.feature);\n }\n\n protected featureStyle(properties: P, index: number): [string, string, Size, Size] {\n const { color, strokeColor, radius, strokeWidth } = this.style;\n return [\n evaluate(color, properties, index),\n evaluate(strokeColor, properties, index),\n evaluate(radius, properties, index),\n evaluate(strokeWidth, properties, index),\n ];\n }\n\n /** @internal */\n protected applyExtra(engine: Engine, id: number): void {\n engine.setCircleAlignment(id, this.style.alignment === 'map');\n }\n}\n\nexport class FillLayer<P = Properties> extends FeatureLayer<P, FillStyle<P>> {\n /** @internal */\n protected add(engine: Engine): number {\n const g = polygonGeometry(this.list);\n return engine.addFills(g.points, g.ringStart, g.polygonStart, g.feature, this.list.length);\n }\n\n /** @internal */\n protected upload(engine: Engine, id: number): void {\n const g = polygonGeometry(this.list);\n engine.setFills(id, g.points, g.ringStart, g.polygonStart, g.feature);\n }\n\n protected featureStyle(properties: P, index: number): [string, string, Size, Size] {\n return [evaluate(this.style.color, properties, index), '#000', 0, 0];\n }\n\n protected applyExtra(): void {}\n}\n\nexport function lineStyle<P>(options: LineOptions<P>): LineStyle<P> {\n const { data: _, before: __, ...rest } = options;\n return { ...(BASE as FeatureLayerStyle<P>), color: '#000', width: 1, dash: undefined, ...rest };\n}\n\nexport function circleStyle<P>(options: CircleOptions<P>): CircleStyle<P> {\n const { data: _, before: __, ...rest } = options;\n return {\n ...(BASE as FeatureLayerStyle<P>),\n color: '#000',\n radius: 5,\n strokeColor: '#fff',\n strokeWidth: 0,\n alignment: 'viewport',\n ...rest,\n };\n}\n\nexport function fillStyle<P>(options: FillOptions<P>): FillStyle<P> {\n const { data: _, before: __, ...rest } = options;\n return { ...(BASE as FeatureLayerStyle<P>), color: '#000', ...rest };\n}\n"]}
@@ -8,8 +8,8 @@
8
8
  * runs out. A glyph's atlas row counts the rows of the pages before its own (`y + page × size`, the pages stacked):
9
9
  * the coordinates of the glyphs placed so far stay valid as the atlas grows.
10
10
  */
11
- import type { Anchor } from './overlay.ts';
12
- import type { Engine } from './wasm/isard.js';
11
+ import type { Anchor } from '../ui/overlay.ts';
12
+ import type { Engine } from '../wasm/isard.js';
13
13
  /** OpenFreeMap's fonts, those of its styles (Noto Sans Regular, Bold, Italic) */
14
14
  export declare const GLYPHS_URL = "https://tiles.openfreemap.org/fonts/{fontstack}/{range}.pbf";
15
15
  /** The font of labels that name none */
@@ -88,7 +88,7 @@ export interface TextPart {
88
88
  scale?: number;
89
89
  font?: string;
90
90
  }
91
- export type { Anchor } from './overlay.ts';
91
+ export type { Anchor } from '../ui/overlay.ts';
92
92
  export interface Shaping {
93
93
  /** Glyph quads: x, y, width, height (CSS pixels from the anchor), atlas u0, v0, u1, v1, font scale */
94
94
  quads: number[][];
@@ -1,4 +1,14 @@
1
- import { withHeaders } from "./requests.js";
1
+ /**
2
+ * Glyphs for the symbol layers: signed distance fields in MapLibre's glyph format (ranges of 256 code points per
3
+ * protobuf file, 24 px glyphs with a 3 px buffer), loaded on first use (from OpenFreeMap's fonts by default, a vector
4
+ * basemap's labels from the glyphs of its style), packed into an atlas the engine samples; and the shaping of a label:
5
+ * its lines (explicit and wrapped), their glyphs placed around the anchor.
6
+ *
7
+ * The atlas has pages of one size: the first one grows up to the page size limit, then pages are added, so it never
8
+ * runs out. A glyph's atlas row counts the rows of the pages before its own (`y + page × size`, the pages stacked):
9
+ * the coordinates of the glyphs placed so far stay valid as the atlas grows.
10
+ */
11
+ import { withHeaders } from "../engine/requests.js";
2
12
  /** OpenFreeMap's fonts, those of its styles (Noto Sans Regular, Bold, Italic) */
3
13
  export const GLYPHS_URL = 'https://tiles.openfreemap.org/fonts/{fontstack}/{range}.pbf';
4
14
  /** The font of labels that name none */
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glyphs.js","sourceRoot":"","sources":["../../src/layers/glyphs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAIpD,iFAAiF;AACjF,MAAM,CAAC,MAAM,UAAU,GAAG,6DAA6D,CAAC;AAExF,wCAAwC;AACxC,MAAM,CAAC,MAAM,YAAY,GAAG,mBAAmB,CAAC;AAEhD,kEAAkE;AAClE,MAAM,EAAE,GAAG,EAAE,CAAC;AACd,MAAM,MAAM,GAAG,CAAC,CAAC;AAkBjB,4GAA4G;AAC5G,MAAM,QAAQ,GAAG,IAAI,CAAC;AACtB,MAAM,SAAS,GAAG,GAAG,CAAC;AAEtB,oDAAoD;AACpD,MAAM,MAAM;IAEmB;IAD7B,GAAG,GAAG,CAAC,CAAC;IACR,YAA6B,GAAe;QAAf,QAAG,GAAH,GAAG,CAAY;IAAG,CAAC;IAChD,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC;IACrC,CAAC;IACD,MAAM;QACJ,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,SAAS,CAAC;YACR,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAA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n * Glyphs for the symbol layers: signed distance fields in MapLibre's glyph format (ranges of 256 code points per\n * protobuf file, 24 px glyphs with a 3 px buffer), loaded on first use (from OpenFreeMap's fonts by default, a vector\n * basemap's labels from the glyphs of its style), packed into an atlas the engine samples; and the shaping of a label:\n * its lines (explicit and wrapped), their glyphs placed around the anchor.\n *\n * The atlas has pages of one size: the first one grows up to the page size limit, then pages are added, so it never\n * runs out. A glyph's atlas row counts the rows of the pages before its own (`y + page × size`, the pages stacked):\n * the coordinates of the glyphs placed so far stay valid as the atlas grows.\n */\n\nimport { withHeaders } from '../engine/requests.ts';\nimport type { Anchor } from '../ui/overlay.ts';\nimport type { Engine } from '../wasm/isard.js';\n\n/** OpenFreeMap's fonts, those of its styles (Noto Sans Regular, Bold, Italic) */\nexport const GLYPHS_URL = 'https://tiles.openfreemap.org/fonts/{fontstack}/{range}.pbf';\n\n/** The font of labels that name none */\nexport const DEFAULT_FONT = 'Noto Sans Regular';\n\n/** Size the glyphs are drawn at in the files, and their buffer */\nconst EM = 24;\nconst BUFFER = 3;\n\nexport interface Glyph {\n width: number;\n height: number;\n left: number;\n top: number;\n advance: number;\n /**\n * Place of its bitmap ((width + 6) × (height + 6)) in the atlas, `y` counting the rows of the pages before its\n * own; undefined for an empty one (a space)\n */\n x?: number;\n y?: number;\n /** Its page of the atlas */\n page?: number;\n}\n\n/** Largest side of a page of the atlas, and most pages (WebGL2 guarantees 256 layers of a texture array) */\nconst PAGE_MAX = 2048;\nconst MAX_PAGES = 256;\n\n/** A protobuf reader, enough for the glyph files */\nclass Reader {\n pos = 0;\n constructor(private readonly buf: Uint8Array) {}\n get done(): boolean {\n return this.pos >= this.buf.length;\n }\n varint(): number {\n let value = 0;\n let shift = 0;\n for (;;) {\n const b = this.buf[this.pos++] ?? 0;\n value += (b & 0x7f) * 2 ** shift;\n if (b < 0x80) return value;\n shift += 7;\n }\n }\n sint(): number {\n const v = this.varint();\n return v % 2 === 1 ? -(v + 1) / 2 : v / 2;\n }\n bytes(): Uint8Array {\n const n = this.varint();\n const out = this.buf.subarray(this.pos, this.pos + n);\n this.pos += n;\n return out;\n }\n skip(wire: number): void {\n if (wire === 0) this.varint();\n else if (wire === 2) this.pos += this.varint();\n else if (wire === 5) this.pos += 4;\n else if (wire === 1) this.pos += 8;\n }\n}\n\n/** Glyphs of a range file: id → metrics and bitmap */\nfunction parse(buffer: ArrayBuffer): Map<number, { glyph: Glyph; bitmap: Uint8Array }> {\n const out = new Map<number, { glyph: Glyph; bitmap: Uint8Array }>();\n const root = new Reader(new Uint8Array(buffer));\n while (!root.done) {\n const tag = root.varint();\n if (tag >> 3 !== 1) {\n root.skip(tag & 7);\n continue;\n }\n // A fontstack\n const stack = new Reader(root.bytes());\n while (!stack.done) {\n const t = stack.varint();\n if (t >> 3 !== 3) {\n stack.skip(t & 7);\n continue;\n }\n const g = new Reader(stack.bytes());\n let id = 0;\n let bitmap: Uint8Array = new Uint8Array(0);\n const glyph: Glyph = { width: 0, height: 0, left: 0, top: 0, advance: 0 };\n while (!g.done) {\n const f = g.varint();\n switch (f >> 3) {\n case 1:\n id = g.varint();\n break;\n case 2:\n bitmap = g.bytes();\n break;\n case 3:\n glyph.width = g.varint();\n break;\n case 4:\n glyph.height = g.varint();\n break;\n case 5:\n glyph.left = g.sint();\n break;\n case 6:\n glyph.top = g.sint();\n break;\n case 7:\n glyph.advance = g.varint();\n break;\n default:\n g.skip(f & 7);\n }\n }\n out.set(id, { glyph, bitmap });\n }\n }\n return out;\n}\n\n/** A shelf of the packer: its page, y, height, and the x of the next free place */\ninterface Shelf {\n page: number;\n y: number;\n height: number;\n x: number;\n}\n\n/** The glyphs of a map and their atlas */\nexport class Glyphs {\n /** Side of the pages */\n private size = 512;\n private pages: Uint8Array[] = [new Uint8Array(512 * 512)];\n /** Pages allocated in the engine (doubled when more are needed: fewer reallocations) */\n private capacity = 1;\n private shelves: Shelf[] = [];\n /** Rows of each page holding glyphs (from its top): the rest is blank, never sent */\n private readonly used: number[] = [0];\n private readonly fonts = new Map<string, Map<number, Glyph>>();\n private readonly ranges = new Map<string, Promise<void>>();\n /** Glyph URLs of fonts other than the map's (those of a vector basemap's style) */\n private readonly sources = new Map<string, string>();\n private engine: Engine | undefined;\n /** Rows of each page changed since the last upload: first, end */\n private readonly dirty = new Map<number, [number, number]>();\n /** The atlas has its most pages: new glyphs stay blank */\n private full = false;\n /** Largest side of a page */\n private readonly maxSize: number;\n /** Bumped each time glyphs are added: labels shaped while some of theirs were missing are shaped again */\n version = 0;\n\n /** `maxSize`: the GPU's texture size limit if known (the pages are at most 2048 × 2048) */\n constructor(\n private readonly url = GLYPHS_URL,\n maxSize = 4096,\n ) {\n this.maxSize = Math.max(512, Math.min(PAGE_MAX, maxSize));\n }\n\n /** Sends the whole atlas to an engine (a new one after a context loss) */\n attach(engine: Engine): void {\n this.engine = engine;\n this.dirty.clear();\n this.upload();\n }\n\n /** Side of the pages of the atlas */\n get atlasSize(): number {\n return this.size;\n }\n\n get pageCount(): number {\n return this.pages.length;\n }\n\n /** Loads these fonts from another glyph URL (a style's `glyphs`); a font keeps the first URL given for it */\n register(url: string, fonts: Iterable<string>): void {\n for (const font of fonts) if (!this.sources.has(font)) this.sources.set(font, url);\n }\n\n /** Loads the glyphs of these code points in a font */\n async load(font: string, codes: Iterable<number>): Promise<Map<number, Glyph>> {\n const glyphs = this.fonts.get(font) ?? new Map<number, Glyph>();\n this.fonts.set(font, glyphs);\n const starts = new Set<number>();\n for (const code of codes) if (!glyphs.has(code)) starts.add(Math.floor(code / 256) * 256);\n await Promise.all([...starts].map((start) => this.range(font, start, glyphs)));\n return glyphs;\n }\n\n private range(font: string, start: number, glyphs: Map<number, Glyph>): Promise<void> {\n const key = `${font}/${start}`;\n let pending = this.ranges.get(key);\n if (!pending) {\n const url = (this.sources.get(font) ?? this.url)\n .replace('{fontstack}', encodeURIComponent(font))\n .replace('{range}', `${start}-${start + 255}`);\n pending = fetch(url, withHeaders(url))\n .then((r) => (r.ok ? r.arrayBuffer() : Promise.reject(new Error(`${url}: ${r.status}`))))\n .then((buffer) => {\n for (const [id, { glyph, bitmap }] of parse(buffer)) {\n if (glyph.width > 0 && bitmap.length >= (glyph.width + 2 * BUFFER) * (glyph.height + 2 * BUFFER)) {\n this.pack(glyph, bitmap);\n }\n glyphs.set(id, glyph);\n }\n this.version += 1;\n // One upload for the range\n this.flush();\n })\n .catch((error: unknown) => {\n // A missing range is not retried this session; its characters stay blank\n console.warn('isard: glyphs', error);\n });\n this.ranges.set(key, pending);\n }\n return pending;\n }\n\n /**\n * Allocates the pages in the engine and sends what they hold (their rows with glyphs). The engine allocates its\n * pages again empty: everything is sent each time, the pages doubled to make it rare\n */\n private upload(): void {\n const engine = this.engine;\n if (!engine) return;\n engine.setGlyphPages(this.size, this.size, this.capacity);\n this.pages.forEach((page, i) => {\n const rows = this.used[i] ?? 0;\n if (rows > 0) engine.updateGlyphPage(i, 0, 0, this.size, rows, page.subarray(0, rows * this.size));\n });\n }\n\n /** Sends the rows changed since the last upload to the engine */\n private flush(): void {\n for (const [page, [y0, y1]] of this.dirty) {\n const data = this.pages[page];\n if (data)\n this.engine?.updateGlyphPage(page, 0, y0, this.size, y1 - y0, data.subarray(y0 * this.size, y1 * this.size));\n }\n this.dirty.clear();\n }\n\n /**\n * Places a bitmap in the atlas (growing the first page, then adding pages when full); `flush` sends it to the\n * engine\n */\n private pack(glyph: Glyph, bitmap: Uint8Array): void {\n const w = glyph.width + 2 * BUFFER;\n const h = glyph.height + 2 * BUFFER;\n // One texel of padding between bitmaps: linear filtering never reads a neighbour\n let shelf = this.shelves.find((s) => s.height >= h && s.height <= h + 4 && s.x + w + 1 <= this.size);\n if (!shelf) {\n const page = this.pages.length - 1;\n // New shelves go on the last page only: the last shelf is on it, unless the page is new\n const last = this.shelves.at(-1);\n const y = last && last.page === page ? last.y + last.height + 1 : 0;\n if (y + h > this.size) {\n if (this.pages.length === 1 && this.size * 2 <= this.maxSize) this.grow();\n else if (this.pages.length < MAX_PAGES) this.addPage();\n else {\n // Full: the glyph takes its room in the text but is not drawn\n if (!this.full) console.warn(`isard: the glyph atlas is full (${MAX_PAGES} pages)`);\n this.full = true;\n return;\n }\n this.pack(glyph, bitmap);\n return;\n }\n shelf = { page, y, height: h, x: 0 };\n this.shelves.push(shelf);\n }\n const data = this.pages[shelf.page];\n if (!data) return;\n glyph.x = shelf.x;\n glyph.y = shelf.page * this.size + shelf.y;\n glyph.page = shelf.page;\n shelf.x += w + 1;\n for (let row = 0; row < h; row += 1) {\n data.set(bitmap.subarray(row * w, row * w + w), (shelf.y + row) * this.size + glyph.x);\n }\n this.used[shelf.page] = Math.max(this.used[shelf.page] ?? 0, shelf.y + h);\n const dirty = this.dirty.get(shelf.page);\n this.dirty.set(shelf.page, [Math.min(dirty?.[0] ?? shelf.y, shelf.y), Math.max(dirty?.[1] ?? 0, shelf.y + h)]);\n }\n\n /** Doubles the only page; the glyphs keep their places (texel coordinates) */\n private grow(): void {\n const size = this.size * 2;\n const old = this.pages[0] ?? new Uint8Array(this.size * this.size);\n const page = new Uint8Array(size * size);\n for (let row = 0; row < this.size; row += 1) {\n page.set(old.subarray(row * this.size, (row + 1) * this.size), row * size);\n }\n this.size = size;\n this.pages = [page];\n // The whole atlas is sent with what it holds so far\n this.dirty.clear();\n this.upload();\n }\n\n /** A new empty page, after the others; the engine's pages are allocated again only past its capacity */\n private addPage(): void {\n this.pages.push(new Uint8Array(this.size * this.size));\n this.used.push(0);\n if (this.pages.length > this.capacity) {\n this.capacity = Math.min(MAX_PAGES, this.capacity * 2);\n // The pages are allocated again: everything is sent, pending changes included\n this.dirty.clear();\n this.upload();\n }\n }\n}\n\n/** A run of text with its own scale (MapLibre's `format` with `font-scale`) and font */\nexport interface TextPart {\n text: string;\n scale?: number;\n font?: string;\n}\n\nexport type { Anchor } from '../ui/overlay.ts';\n\nexport interface Shaping {\n /** Glyph quads: x, y, width, height (CSS pixels from the anchor), atlas u0, v0, u1, v1, font scale */\n quads: number[][];\n /** Ink box from the anchor: min x, min y, max x, max y */\n box: [number, number, number, number];\n /** Layout box from the anchor, what an icon fitted to the text frames: the advances of its widest line across, its\n * lines' height (`lineHeight` each) down, centered on the ink */\n layout: [number, number, number, number];\n}\n\n/** Code points of a text, for loading */\nexport function codes(parts: readonly TextPart[]): Set<number> {\n const out = new Set<number>();\n for (const p of parts) for (const ch of p.text) out.add(ch.codePointAt(0) ?? 32);\n return out;\n}\n\n/**\n * Lays out a label: lines split at `\\n` and wrapped at `maxWidth` ems, centered, the block placed by `anchor` around\n * the anchor point and moved by `offset` (ems); `size` in CSS pixels. Glyphs not loaded take no room.\n */\nexport function shape(\n parts: readonly TextPart[],\n glyphsOf: (font: string) => Map<number, Glyph> | undefined,\n options: {\n font: string;\n size: number;\n maxWidth: number;\n lineHeight: number;\n anchor: Anchor;\n offset: [number, number];\n },\n): Shaping {\n const { size, maxWidth, lineHeight, anchor, offset } = options;\n const k = size / EM;\n // Characters with their glyph and scale, split into lines\n type Char = { glyph: Glyph | undefined; scale: number; space: boolean };\n const lines: Char[][] = [[]];\n for (const part of parts) {\n const glyphs = glyphsOf(part.font ?? options.font);\n for (const ch of part.text) {\n if (ch === '\\n') {\n lines.push([]);\n continue;\n }\n const code = ch.codePointAt(0) ?? 32;\n lines.at(-1)?.push({ glyph: glyphs?.get(code), scale: part.scale ?? 1, space: /\\s/.test(ch) });\n }\n }\n const advance = (c: Char) => (c.glyph?.advance ?? (c.space ? EM / 4 : 0)) * c.scale;\n // Wrapping at spaces, greedy\n const limit = maxWidth * EM;\n const wrapped: Char[][] = [];\n for (const line of lines) {\n let current: Char[] = [];\n let width = 0;\n let lastSpace = -1;\n for (const c of line) {\n current.push(c);\n width += advance(c);\n if (c.space) lastSpace = current.length - 1;\n if (width > limit && lastSpace > 0) {\n wrapped.push(current.slice(0, lastSpace));\n current = current.slice(lastSpace + 1);\n width = current.reduce((s, x) => s + advance(x), 0);\n lastSpace = -1;\n }\n }\n wrapped.push(current);\n }\n // Glyphs on their lines, each line centered on x = 0, in units of the 24 px font\n const quads: number[][] = [];\n let [x0, y0, x1, y1] = [\n Number.POSITIVE_INFINITY,\n Number.POSITIVE_INFINITY,\n Number.NEGATIVE_INFINITY,\n Number.NEGATIVE_INFINITY,\n ];\n let baseline = 0;\n let widest = 0;\n let height = 0;\n wrapped.forEach((line, i) => {\n const scale = Math.max(1, ...line.map((c) => c.scale));\n if (i > 0) baseline += lineHeight * EM * scale;\n height += lineHeight * EM * scale;\n const width = line.reduce((s, c) => s + advance(c), 0);\n widest = Math.max(widest, width);\n let pen = -width / 2;\n for (const c of line) {\n const g = c.glyph;\n if (g && g.x !== undefined && g.y !== undefined && g.width > 0) {\n const qx = pen + (g.left - BUFFER) * c.scale;\n const qy = baseline - (g.top + BUFFER) * c.scale;\n const qw = (g.width + 2 * BUFFER) * c.scale;\n const qh = (g.height + 2 * BUFFER) * c.scale;\n quads.push([qx, qy, qw, qh, g.x, g.y, g.x + g.width + 2 * BUFFER, g.y + g.height + 2 * BUFFER, c.scale]);\n x0 = Math.min(x0, qx + BUFFER * c.scale);\n y0 = Math.min(y0, qy + BUFFER * c.scale);\n x1 = Math.max(x1, qx + qw - BUFFER * c.scale);\n y1 = Math.max(y1, qy + qh - BUFFER * c.scale);\n }\n pen += advance(c);\n }\n });\n if (!quads.length) return { quads, box: [0, 0, 0, 0], layout: [0, 0, 0, 0] };\n // The block placed around the anchor by its ink box\n // The side of the box at the anchor: its start, its end, or its middle\n const side = (start: boolean, end: boolean, lo: number, hi: number) => {\n if (start) return -lo;\n if (end) return -hi;\n return -(lo + hi) / 2;\n };\n const horizontal = side(anchor.includes('left'), anchor.includes('right'), x0, x1);\n const vertical = side(anchor.startsWith('top'), anchor.startsWith('bottom'), y0, y1);\n const dx = horizontal + offset[0] * EM;\n const dy = vertical + offset[1] * EM;\n for (const q of quads) {\n q[0] = ((q[0] ?? 0) + dx) * k;\n q[1] = ((q[1] ?? 0) + dy) * k;\n q[2] = (q[2] ?? 0) * k;\n q[3] = (q[3] ?? 0) * k;\n q[8] = (q[8] ?? 1) * k;\n }\n const middle = (y0 + y1) / 2 + dy;\n height = Math.max(height, y1 - y0);\n return {\n quads,\n box: [(x0 + dx) * k, (y0 + dy) * k, (x1 + dx) * k, (y1 + dy) * k],\n layout: [(dx - widest / 2) * k, (middle - height / 2) * k, (dx + widest / 2) * k, (middle + height / 2) * k],\n };\n}\n"]}
@@ -5,8 +5,8 @@
5
5
  * layout of an icon around its anchor: by its anchor and offset, or stretched around its text (`icon-text-fit`), by
6
6
  * the stretchable zones and the content box of its image when it has them (`stretchX`, `stretchY`, `content`).
7
7
  */
8
- import type { Anchor } from './overlay.ts';
9
- import type { Engine } from './wasm/isard.js';
8
+ import type { Anchor } from '../ui/overlay.ts';
9
+ import type { Engine } from '../wasm/isard.js';
10
10
  /** An image of a sprite's index: its place in the sheet (pixels) and how it is drawn */
11
11
  export interface SpriteIcon {
12
12
  x: number;
@@ -1,4 +1,11 @@
1
- import { withHeaders } from "./requests.js";
1
+ /**
2
+ * Icons for the symbol layers: the images of a style's sprite (MapLibre's sprite format: a JSON index and a PNG sheet,
3
+ * `@2x` on high-density screens, one sprite or several with their ids) and the application's own (`map.addImage`),
4
+ * packed on first use into an RGBA atlas the engine samples (premultiplied: no dark fringe where it is scaled); and the
5
+ * layout of an icon around its anchor: by its anchor and offset, or stretched around its text (`icon-text-fit`), by
6
+ * the stretchable zones and the content box of its image when it has them (`stretchX`, `stretchY`, `content`).
7
+ */
8
+ import { withHeaders } from "../engine/requests.js";
2
9
  /** The sprites of a style's `sprite`: one URL, or several with their ids (MapLibre's style specification) */
3
10
  export function spriteSources(sprite) {
4
11
  if (typeof sprite === 'string')
@@ -0,0 +1 @@
1
+ {"version":3,"file":"icons.js","sourceRoot":"","sources":["../../src/layers/icons.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAqDpD,6GAA6G;AAC7G,MAAM,UAAU,aAAa,CAAC,MAAoD;IA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,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;AAC3D,CAAC","sourcesContent":["/**\n * Icons for the symbol layers: the images of a style's sprite (MapLibre's sprite format: a JSON index and a PNG sheet,\n * `@2x` on high-density screens, one sprite or several with their ids) and the application's own (`map.addImage`),\n * packed on first use into an RGBA atlas the engine samples (premultiplied: no dark fringe where it is scaled); and the\n * layout of an icon around its anchor: by its anchor and offset, or stretched around its text (`icon-text-fit`), by\n * the stretchable zones and the content box of its image when it has them (`stretchX`, `stretchY`, `content`).\n */\n\nimport { withHeaders } from '../engine/requests.ts';\nimport type { Anchor } from '../ui/overlay.ts';\nimport type { Engine } from '../wasm/isard.js';\n\n/** An image of a sprite's index: its place in the sheet (pixels) and how it is drawn */\nexport interface SpriteIcon {\n x: number;\n y: number;\n width: number;\n height: number;\n /** Image pixels per CSS pixel (default 1; 2 in an `@2x` sheet) */\n pixelRatio?: number;\n /** A signed distance field in alpha, drawn in the icon color */\n sdf?: boolean;\n /** Columns and rows that stretch when the icon is fitted to its text (image pixels): the others keep their size */\n stretchX?: [number, number][];\n stretchY?: [number, number][];\n /** Where the text goes when the icon is fitted to it: left, top, right, bottom (image pixels) */\n content?: [number, number, number, number];\n}\n\nexport type SpriteIndex = Record<string, SpriteIcon>;\n\n/** RGBA pixels, straight alpha, row after row */\nexport interface Pixels {\n width: number;\n height: number;\n data: Uint8Array | Uint8ClampedArray;\n}\n\n/** How an image of the application is drawn (`map.addImage`): `SpriteIcon` without its place */\nexport type ImageOptions = Omit<SpriteIcon, 'x' | 'y' | 'width' | 'height'>;\n\n/** An icon in the atlas: its place (texels) and how it is drawn */\nexport interface Icon {\n x: number;\n y: number;\n width: number;\n height: number;\n pixelRatio: number;\n sdf: boolean;\n stretchX: [number, number][] | undefined;\n stretchY: [number, number][] | undefined;\n content: [number, number, number, number] | undefined;\n}\n\n/** A sprite of a style: its id (`default`: its images keep their names, else `id:name`) and its URL without\n * extension */\nexport interface SpriteSource {\n id: string;\n url: string;\n}\n\n/** The sprites of a style's `sprite`: one URL, or several with their ids (MapLibre's style specification) */\nexport function spriteSources(sprite: string | readonly SpriteSource[] | undefined): SpriteSource[] {\n if (typeof sprite === 'string') return sprite ? [{ id: 'default', url: sprite }] : [];\n return Array.isArray(sprite) ? sprite.filter((s) => typeof s?.url === 'string' && typeof s.id === 'string') : [];\n}\n\n/** The name of an image of a sprite in the style: its own in the `default` sprite, `id:name` in another */\nexport function spriteName(id: string, name: string): string {\n return id === 'default' ? name : `${id}:${name}`;\n}\n\n/** The URL of a sprite's index or sheet: `.json` or `.png`, `@2x` before it for high-density screens, before the\n * query of the URL if it has one */\nexport function spriteFile(url: string, extension: 'json' | 'png', ratio: number): string {\n const suffix = `${ratio > 1 ? '@2x' : ''}.${extension}`;\n const query = url.search(/[?#]/);\n return query < 0 ? `${url}${suffix}` : `${url.slice(0, query)}${suffix}${url.slice(query)}`;\n}\n\n/** A sprite loaded: its images by name (with the sprite's prefix) and its sheet */\nexport interface LoadedSprite {\n icons: SpriteIndex;\n image: ImageBitmap;\n}\n\n/** Loads a style's sprites (`@2x` above a device pixel ratio of 1, the 1x ones if a server has none); the sprites\n * that fail are left out */\nexport async function loadSprites(\n sprite: string | readonly SpriteSource[] | undefined,\n ratio = typeof devicePixelRatio === 'number' ? devicePixelRatio : 1,\n): Promise<LoadedSprite[]> {\n const one = async ({ id, url }: SpriteSource, r: number): Promise<LoadedSprite | undefined> => {\n const [json, png] = await Promise.all([\n fetch(spriteFile(url, 'json', r), withHeaders(spriteFile(url, 'json', r))),\n fetch(spriteFile(url, 'png', r), withHeaders(spriteFile(url, 'png', r))),\n ]);\n if (!json.ok || !png.ok) return r > 1 ? one({ id, url }, 1) : undefined;\n const index = (await json.json()) as SpriteIndex;\n const icons: SpriteIndex = {};\n for (const [name, icon] of Object.entries(index)) icons[spriteName(id, name)] = icon;\n return { icons, image: await createImageBitmap(await png.blob()) };\n };\n const loaded = await Promise.all(spriteSources(sprite).map((s) => one(s, ratio).catch(() => undefined)));\n return loaded.filter((s): s is LoadedSprite => s !== undefined);\n}\n\n/** The pixels of an image (read back through a canvas) */\nexport function readPixels(image: CanvasImageSource & { width: number; height: number }): Pixels | undefined {\n const { width, height } = image;\n if (!(width > 0 && height > 0)) return undefined;\n const canvas =\n typeof OffscreenCanvas === 'function'\n ? new OffscreenCanvas(width, height)\n : Object.assign(document.createElement('canvas'), { width, height });\n const g = canvas.getContext('2d') as CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D | null;\n if (!g) return undefined;\n g.drawImage(image, 0, 0);\n return g.getImageData(0, 0, width, height);\n}\n\n/** Where an icon's pixels are: a region of an image, read when first packed */\ninterface IconSource {\n pixels: () => Pixels | undefined;\n x: number;\n y: number;\n width: number;\n height: number;\n options: ImageOptions;\n}\n\n/** A shelf of the packer: its y, height, and the x of the next free place */\ninterface Shelf {\n y: number;\n height: number;\n x: number;\n}\n\n/** The icons of a map and their atlas: a square that doubles as it fills, up to the texture size limit */\nexport class Icons {\n private size = 256;\n private data = new Uint8Array(256 * 256 * 4);\n private shelves: Shelf[] = [];\n private readonly sources = new Map<string, IconSource>();\n /** Icons packed, null for those that cannot be (no pixels, the atlas full) */\n private readonly packed = new Map<string, Icon | null>();\n private engine: Engine | undefined;\n /** Rows changed since the last upload: first, end */\n private dirty: [number, number] | undefined;\n private full = false;\n private readonly maxSize: number;\n /** Bumped each time icons are added or removed: labels laid out without some of theirs are laid out again */\n version = 0;\n\n /** `maxSize`: the GPU's texture size limit if known (the atlas is at most 4096 × 4096) */\n constructor(maxSize = 4096) {\n this.maxSize = Math.max(256, Math.min(4096, maxSize));\n }\n\n /** Sends the whole atlas to an engine (a new one after a context loss) */\n attach(engine: Engine): void {\n this.engine = engine;\n this.dirty = undefined;\n this.upload();\n }\n\n /** Side of the atlas */\n get atlasSize(): number {\n return this.size;\n }\n\n /** An image of the application under `name` (another image of that name is replaced) */\n add(name: string, pixels: Pixels, options: ImageOptions = {}): void {\n this.define(name, { pixels: () => pixels, x: 0, y: 0, width: pixels.width, height: pixels.height, options });\n }\n\n /** The images of a sprite's index, `prefix` before their names, their pixels read from the sheet on first use */\n addSprite(prefix: string, index: SpriteIndex, sheet: () => Pixels | undefined): void {\n let pixels: Pixels | undefined;\n let read = false;\n const once = () => {\n if (!read) {\n read = true;\n pixels = sheet();\n }\n return pixels;\n };\n for (const [name, icon] of Object.entries(index)) {\n if (!icon || typeof icon !== 'object') continue;\n const { x, y, width, height, ...options } = icon;\n this.define(`${prefix}${name}`, { pixels: once, x, y, width, height, options }, false);\n }\n this.version += 1;\n }\n\n private define(name: string, source: IconSource, bump = true): void {\n this.sources.set(name, source);\n // Packed again on its next use (its old place stays taken)\n this.packed.delete(name);\n if (bump) this.version += 1;\n }\n\n has(name: string): boolean {\n return this.sources.has(name);\n }\n\n /** Forgets an image, or every image whose name starts with `prefix` (a sprite's) */\n remove(name: string, prefix = false): void {\n for (const key of [...this.sources.keys()]) {\n if (prefix ? key.startsWith(name) : key === name) {\n this.sources.delete(key);\n this.packed.delete(key);\n }\n }\n this.version += 1;\n }\n\n /** The icon of this name, packed into the atlas on first use; undefined if there is none (`flush` uploads it) */\n get(name: string): Icon | undefined {\n const hit = this.packed.get(name);\n if (hit !== undefined) return hit ?? undefined;\n const source = this.sources.get(name);\n if (!source) return undefined;\n const icon = this.pack(source);\n this.packed.set(name, icon ?? null);\n return icon;\n }\n\n /** Sends the rows changed since the last upload to the engine */\n flush(): void {\n const dirty = this.dirty;\n this.dirty = undefined;\n if (!dirty || !this.engine) return;\n const [y0, y1] = dirty;\n const row = this.size * 4;\n this.engine.updateIconAtlas(0, y0, this.size, y1 - y0, this.data.subarray(y0 * row, y1 * row));\n }\n\n private upload(): void {\n const engine = this.engine;\n if (!engine) return;\n engine.setIconAtlas(this.size, this.size);\n const used = this.shelves.reduce((m, s) => Math.max(m, s.y + s.height), 0);\n if (used > 0) engine.updateIconAtlas(0, 0, this.size, used, this.data.subarray(0, used * this.size * 4));\n }\n\n /** Copies an icon's pixels into the atlas, premultiplied, with a texel of room around it */\n private pack(source: IconSource): Icon | undefined {\n const pixels = source.pixels();\n const { x, y, width: w, height: h } = source;\n if (!pixels || !(w > 0 && h > 0) || x < 0 || y < 0 || x + w > pixels.width || y + h > pixels.height) {\n return undefined;\n }\n const place = this.place(w + 2, h + 2);\n if (!place) return undefined;\n const [px, py] = [place[0] + 1, place[1] + 1];\n for (let row = 0; row < h; row += 1) {\n for (let col = 0; col < w; col += 1) {\n const from = ((y + row) * pixels.width + x + col) * 4;\n const to = ((py + row) * this.size + px + col) * 4;\n const a = pixels.data[from + 3] ?? 0;\n this.data[to] = ((pixels.data[from] ?? 0) * a + 127) / 255;\n this.data[to + 1] = ((pixels.data[from + 1] ?? 0) * a + 127) / 255;\n this.data[to + 2] = ((pixels.data[from + 2] ?? 0) * a + 127) / 255;\n this.data[to + 3] = a;\n }\n }\n const [d0, d1] = this.dirty ?? [place[1], place[1]];\n this.dirty = [Math.min(d0, place[1]), Math.max(d1, place[1] + h + 2)];\n const { pixelRatio, sdf, stretchX, stretchY, content } = source.options;\n return {\n x: px,\n y: py,\n width: w,\n height: h,\n pixelRatio: pixelRatio && pixelRatio > 0 ? pixelRatio : 1,\n sdf: sdf === true,\n stretchX: Array.isArray(stretchX) ? stretchX : undefined,\n stretchY: Array.isArray(stretchY) ? stretchY : undefined,\n content: Array.isArray(content) && content.length === 4 ? content : undefined,\n };\n }\n\n /** A free place of `w` × `h` texels (shelves, the atlas doubled when full); undefined once it cannot grow */\n private place(w: number, h: number): [number, number] | undefined {\n for (;;) {\n const shelf = this.shelves.find((s) => s.height >= h && s.height <= h + 8 && s.x + w <= this.size);\n if (shelf) {\n shelf.x += w;\n return [shelf.x - w, shelf.y];\n }\n const last = this.shelves.at(-1);\n const y = last ? last.y + last.height : 0;\n if (y + h <= this.size && w <= this.size) {\n this.shelves.push({ y, height: h, x: w });\n return [0, y];\n }\n if (this.size * 2 > this.maxSize) {\n if (!this.full) console.warn(`isard: the icon atlas is full (${this.size} × ${this.size})`);\n this.full = true;\n return undefined;\n }\n this.grow();\n }\n }\n\n /** Doubles the atlas; the icons keep their places (texels) */\n private grow(): void {\n const size = this.size * 2;\n const data = new Uint8Array(size * size * 4);\n for (let row = 0; row < this.size; row += 1) {\n data.set(this.data.subarray(row * this.size * 4, (row + 1) * this.size * 4), row * size * 4);\n }\n this.size = size;\n this.data = data;\n this.dirty = undefined;\n this.upload();\n }\n}\n\n/** How an icon is laid out around its anchor */\nexport interface IconLayoutOptions {\n /** Scale of the image (`icon-size`) */\n size: number;\n anchor: Anchor;\n /** CSS pixels at size 1 */\n offset: [number, number];\n /** Degrees, clockwise */\n rotate: number;\n /** Stretched around the text: its width, its height, both (`icon-text-fit`) */\n fit: 'none' | 'width' | 'height' | 'both';\n /** Room around the text when fitted: top, right, bottom, left (CSS pixels) */\n padding: [number, number, number, number];\n /** The text's box around the anchor (CSS pixels), if it has one */\n text?: [number, number, number, number] | undefined;\n}\n\n/** An icon laid out: its quads (x, y, width, height in CSS pixels from the anchor, atlas u0, v0, u1, v1 in texels, -1\n * or -2 for a distance field, turn in radians) and its box from the anchor */\nexport interface IconLayout {\n quads: number[][];\n box: [number, number, number, number];\n}\n\n/** Pieces of an image along one axis: image start, end, laid out start, end */\ntype Pieces = [number, number, number, number][];\n\n/**\n * An axis of an icon fitted to `lo`…`hi` (CSS pixels): its content (the whole image by default) spans them, its\n * stretchable zones (the whole image by default) taking the room the fixed parts (at `scale` CSS pixels per image\n * pixel) leave\n */\nexport function stretch(\n length: number,\n zones: readonly [number, number][] | undefined,\n content: [number, number] | undefined,\n lo: number,\n hi: number,\n scale: number,\n): Pieces {\n const clamp = (v: number) => Math.max(0, Math.min(length, Number(v) || 0));\n const spans = (zones?.length ? zones : [[0, length] as [number, number]])\n .map(([a, b]): [number, number] => [clamp(Math.min(a, b)), clamp(Math.max(a, b))])\n .filter(([a, b]) => b > a);\n const cuts = [...new Set([0, length, ...spans.flat()])].sort((a, b) => a - b);\n const pieces = cuts.slice(1).map((b, i): [number, number, boolean] => {\n const a = cuts[i] ?? 0;\n return [a, b, spans.some(([s, e]) => s <= a && b <= e)];\n });\n const [c0, c1] = content ? [clamp(content[0]), clamp(content[1])] : [0, length];\n const overlap = (a: number, b: number) => Math.max(0, Math.min(b, c1) - Math.max(a, c0));\n const stretchable = pieces.reduce((n, [a, b, s]) => n + (s ? overlap(a, b) : 0), 0);\n const fixed = c1 - c0 - stretchable;\n // CSS pixels per stretchable image pixel: what the fixed parts of the content leave of the room\n const k = stretchable > 0 ? Math.max(0, (hi - lo - fixed * scale) / stretchable) : scale;\n // Laid out position of an image coordinate\n const at = (x: number) => pieces.reduce((n, [a, b, s]) => n + Math.max(0, Math.min(x, b) - a) * (s ? k : scale), 0);\n const origin = lo - at(c0);\n return pieces.map(([a, b]) => [a, b, origin + at(a), origin + at(b)]);\n}\n\n/** Where an anchor's side lies along an axis of the icon: at its start 0, at its end 1, else the middle */\nfunction align(start: boolean, end: boolean): number {\n if (start) return 0;\n return end ? 1 : 0.5;\n}\n\n/** Lays an icon out around its anchor: placed by its anchor and offset, or fitted to its text */\nexport function layoutIcon(icon: Icon, options: IconLayoutOptions): IconLayout {\n const { size, anchor, offset, rotate, fit, padding, text } = options;\n const { width: w, height: h, pixelRatio } = icon;\n let xs: Pieces;\n let ys: Pieces;\n if (fit !== 'none' && text) {\n const [top, right, bottom, left] = padding;\n const [x0, y0, x1, y1] = [text[0] - left, text[1] - top, text[2] + right, text[3] + bottom];\n // The fixed parts at the image's own size; an axis not fitted at the icon's size, centered on the text\n const own = 1 / pixelRatio;\n const scaled = size / pixelRatio;\n const centered = (length: number, lo: number, hi: number): Pieces => {\n const c = (lo + hi) / 2;\n return [[0, length, c - (length * scaled) / 2, c + (length * scaled) / 2]];\n };\n const content = icon.content;\n xs =\n fit === 'height'\n ? centered(w, x0, x1)\n : stretch(w, icon.stretchX, content && [content[0], content[2]], x0, x1, own);\n ys =\n fit === 'width'\n ? centered(h, y0, y1)\n : stretch(h, icon.stretchY, content && [content[1], content[3]], y0, y1, own);\n } else {\n const [dw, dh] = [(w / pixelRatio) * size, (h / pixelRatio) * size];\n const ax = align(anchor.includes('left'), anchor.includes('right'));\n const ay = align(anchor.startsWith('top'), anchor.startsWith('bottom'));\n const [left, top] = [offset[0] * size - dw * ax, offset[1] * size - dh * ay];\n xs = [[0, w, left, left + dw]];\n ys = [[0, h, top, top + dh]];\n }\n const angle = ((Number(rotate) || 0) * Math.PI) / 180;\n const kind = icon.sdf ? -2 : -1;\n const quads: number[][] = [];\n const [cs, sn] = [Math.cos(angle), Math.sin(angle)];\n const box: [number, number, number, number] = [\n Number.POSITIVE_INFINITY,\n Number.POSITIVE_INFINITY,\n Number.NEGATIVE_INFINITY,\n Number.NEGATIVE_INFINITY,\n ];\n for (const [v0, v1, top, bottom] of ys) {\n for (const [u0, u1, left, right] of xs) {\n if (right <= left || bottom <= top) continue;\n quads.push([\n left,\n top,\n right - left,\n bottom - top,\n icon.x + u0,\n icon.y + v0,\n icon.x + u1,\n icon.y + v1,\n kind,\n angle,\n ]);\n // The box of the turned corners\n for (const [px, py] of [\n [left, top],\n [right, top],\n [left, bottom],\n [right, bottom],\n ] as const) {\n const [rx, ry] = [px * cs - py * sn, px * sn + py * cs];\n box[0] = Math.min(box[0], rx);\n box[1] = Math.min(box[1], ry);\n box[2] = Math.max(box[2], rx);\n box[3] = Math.max(box[3], ry);\n }\n }\n }\n return { quads, box: quads.length ? box : [0, 0, 0, 0] };\n}\n"]}
@@ -1,6 +1,11 @@
1
- import type { GeoMap } from './map.ts';
2
- import type { LonLat, NetworkStyle, RasterStyle, Tiles3dStyle } from './types.ts';
3
- import type { Camera, NetworkStats, Tiles3dStats } from './wasm/isard.js';
1
+ /**
2
+ * Handles of the layers added to a map. Each one keeps what it needs to be created again: after a WebGL context loss,
3
+ * the map recreates its engine and every layer in order, with the same handle (its id is updated). Also the page's
4
+ * own 3D content: custom layers (its WebGL code called in every frame) and glTF models drawn at positions.
5
+ */
6
+ import type { GeoMap } from '../map.ts';
7
+ import type { LonLat, NetworkStyle, RasterStyle, Tiles3dStyle } from '../types.ts';
8
+ import type { Camera, NetworkStats, Tiles3dStats } from '../wasm/isard.js';
4
9
  export declare abstract class Layer {
5
10
  #private;
6
11
  /** Id of the layer in the engine */
@@ -3,9 +3,9 @@
3
3
  * the map recreates its engine and every layer in order, with the same handle (its id is updated). Also the page's
4
4
  * own 3D content: custom layers (its WebGL code called in every frame) and glTF models drawn at positions.
5
5
  */
6
+ import { rgb } from "../settings.js";
7
+ import { mercatorX, mercatorY, toMercator } from "../util/geo.js";
6
8
  import { parseColor, rampTexels, stops } from "./features.js";
7
- import { mercatorX, mercatorY, toMercator } from "./geo.js";
8
- import { rgb } from "./settings.js";
9
9
  export class Layer {
10
10
  #id = -1;
11
11
  /** @internal */
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layers.js","sourceRoot":"","sources":["../../src/layers/layers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAUrC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAElE,OAAO,EAAgB,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAE5E,MAAM,OAAgB,KAAK;IACzB,GAAG,GAAG,CAAC,CAAC,CAAC;IAET,gBAAgB;IACG,GAAG,CAAY;IAElC,gBAAgB;IAChB,YAAY,GAAc;QACxB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAED,oCAAoC;IACpC,IAAI,EAAE;QACJ,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;IAED,MAAM,CAA4B;IAElC;iFAC6E;IAC7E,IAAI,KAAK;QACP,IAAI,CAAC,MAAM,KAAK,CAAC,KAAK,IAAI,EAAE;YAC1B;gBAA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,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QACxE,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC;IAC3B,CAAC;IAEQ,MAAM;QACb,KAAK,CAAC,MAAM,EAAE,CAAC;QACf,IAAI,CAAC,OAAO,EAAE,CAAC;IACjB,CAAC;IAED,gBAAgB;IACP,OAAO;QACd,IAAI,IAAI,CAAC,IAAI;YAAE,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChD,CAAC;IAED,gBAAgB;IACN,MAAM,CAAC,MAAc;QAC7B,OAAO,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACjE,CAAC;CACF","sourcesContent":["/**\n * Handles of the layers added to a map. Each one keeps what it needs to be created again: after a WebGL context loss,\n * the map recreates its engine and every layer in order, with the same handle (its id is updated). Also the page's\n * own 3D content: custom layers (its WebGL code called in every frame) and glTF models drawn at positions.\n */\n\nimport type { GeoMap } from '../map.ts';\nimport { rgb } from '../settings.ts';\nimport type {\n LayerHost,\n LonLat,\n NetworkOptions,\n NetworkStyle,\n RasterOptions,\n RasterStyle,\n Tiles3dStyle,\n} from '../types.ts';\nimport { mercatorX, mercatorY, toMercator } from '../util/geo.ts';\nimport type { Camera, Engine, NetworkStats, Tiles3dStats } from '../wasm/isard.js';\nimport { type Feature, parseColor, rampTexels, stops } from './features.ts';\n\nexport abstract class Layer {\n #id = -1;\n\n /** @internal */\n protected readonly map: LayerHost;\n\n /** @internal */\n constructor(map: LayerHost) {\n this.map = map;\n }\n\n /** Id of the layer in the engine */\n get id(): number {\n return this.#id;\n }\n\n #ready: Promise<void> | undefined;\n\n /** Resolves once the map has drawn the layer, what it shows in view loaded (the map idle after it was added; a\n * layer waiting for the engine with 3D Tiles, once that one has drawn it) */\n get ready(): Promise<void> {\n this.#ready ??= (async () => {\n do await this.map.whenIdle();\n while (this.#id < 0 && this.needsFullEngine);\n })();\n return this.#ready;\n }\n\n /** @internal Creates the layer in an engine (again after a context loss); its id is -1 if that fails */\n attach(engine: Engine): void {\n this.#id = -1;\n this.#id = this.create(engine);\n }\n\n /** @internal Forgets its id in an engine that is gone (before the layers are created in a new one) */\n forgetEngine(): void {\n this.#id = -1;\n }\n\n /** @internal Sends what refers to other layers, once every layer of a new engine has its id */\n relink(_engine: Engine): void {}\n\n /** @internal Drawn by the engine with 3D Tiles only (3D Tiles, models): on the core engine, it waits for that one */\n get needsFullEngine(): boolean {\n return false;\n }\n\n /** @internal The layer is removed or its map destroyed: frees what it holds outside the engine */\n dispose(): void {}\n\n /** @internal */\n protected abstract create(engine: Engine): number;\n\n remove(): void {\n // Not created yet: a 3D Tiles layer or a model waiting for the engine with 3D Tiles\n if (this.#id >= 0) this.map.engine.removeLayer(this.#id);\n this.#id = -1;\n this.map.detach(this);\n this.map.requestRender();\n }\n\n /** Moves the layer under `other`, or on top of every layer (above the labels of a vector basemap too) */\n moveBefore(other: Layer | undefined): void {\n this.map.moveLayer(this, other);\n }\n}\n\n/** Raster tiles (basemaps, overlays) */\nexport class RasterLayer extends Layer {\n /** @internal */\n constructor(\n map: LayerHost,\n private readonly options: Required<Omit<RasterOptions, 'size' | 'loader' | 'grid' | 'attribution'>> & {\n size: number | undefined;\n loader: RasterOptions['loader'] | undefined;\n },\n ) {\n super(map);\n }\n\n /** Changes the opacity or saturation, the other kept */\n setStyle(style: Partial<RasterStyle>): void {\n this.options.opacity = style.opacity ?? this.options.opacity;\n this.options.saturation = style.saturation ?? this.options.saturation;\n this.map.engine.setRasterStyle(this.id, this.options.opacity, this.options.saturation);\n this.map.requestRender();\n }\n\n /** @internal */\n protected create(engine: Engine): number {\n const { url, minZoom, maxZoom, opacity, saturation, size, loader } = this.options;\n return engine.addRaster(url, minZoom, maxZoom, opacity, saturation, size, loader);\n }\n}\n\n/** Line network colored by a value per node (travel time, water depth…) */\nexport class NetworkLayer extends Layer {\n private values: Float32Array | undefined;\n /** Node and line positions in Mercator, kept for a context loss: f32 offsets from an origin (exact to the centimetre\n * across a region, half the memory of f64) */\n private kept: { origin: [number, number]; nodes: Float32Array; lines: Float32Array | undefined } | undefined;\n\n /** @internal */\n constructor(\n map: LayerHost,\n private geometry: { nodes: Float64Array; edges: Uint32Array; lines: NetworkOptions['lines'] | undefined },\n private costs: Float32Array | undefined,\n private style: NetworkStyle,\n private edgeWidths: Float32Array | undefined,\n ) {\n super(map);\n }\n\n /** One value per node, in node order; negative (or 1e30 and above) = unreached. Costs one texture upload, drawn\n * next frame. */\n setValues(values: Float32Array): void {\n this.values = values;\n this.map.engine.setNetworkValues(this.id, values);\n this.map.requestRender();\n }\n\n /** Costs of the edges, A → B then B → A (see `NetworkOptions.costs`), when the way the network is travelled\n * changes; undefined: values interpolated along the edges. The geometry stays on the graphics card. */\n setCosts(costs: Float32Array | undefined): void {\n this.costs = costs;\n this.map.engine.setNetworkCosts(this.id, costs);\n this.map.requestRender();\n }\n\n setStyle(style: Partial<NetworkStyle>): void {\n const ramp = this.style.ramp;\n this.style = { ...this.style, ...style };\n this.map.engine.setNetworkStyle(this.id, networkStyle(this.style));\n if (this.style.ramp !== ramp)\n this.map.engine.setNetworkRamp(this.id, this.style.ramp && rampTexels(this.style.ramp).rgba);\n this.map.requestRender();\n }\n\n /** Width factor of each edge (undefined: 1 for all) */\n setEdgeWidths(widths: Float32Array | undefined): void {\n this.edgeWidths = widths;\n this.map.engine.setNetworkScales(this.id, widths);\n this.map.requestRender();\n }\n\n /** Pieces in all and drawn in the last frame */\n stats(): NetworkStats | undefined {\n return this.map.engine.networkStats(this.id);\n }\n\n /** @internal */\n protected create(engine: Engine): number {\n const { nodes, edges, lines } = this.geometry;\n let mercator: { nodes: Float64Array; lines: Float64Array | undefined };\n if (this.kept) {\n const { origin, nodes: n, lines: l } = this.kept;\n mercator = { nodes: unpack(n, origin), lines: l && unpack(l, origin) };\n } else {\n // Mercator here: Math.tan and Math.log run natively, several times faster than in WebAssembly\n mercator = { nodes: mercatorPoints(nodes), lines: lines && mercatorPoints(lines.points) };\n const origin: [number, number] = [mercator.nodes[0] ?? 0, mercator.nodes[1] ?? 0];\n this.kept = {\n origin,\n nodes: pack(mercator.nodes, origin),\n lines: mercator.lines && pack(mercator.lines, origin),\n };\n // The degrees are not needed again: millions of points for a region\n this.geometry = { nodes: EMPTY, edges, lines: lines && { start: lines.start, points: EMPTY } };\n }\n const id = engine.addNetwork(\n mercator.nodes,\n edges,\n lines?.start,\n mercator.lines,\n this.costs,\n networkStyle(this.style),\n );\n if (this.style.ramp) engine.setNetworkRamp(id, rampTexels(this.style.ramp).rgba);\n if (this.edgeWidths) engine.setNetworkScales(id, this.edgeWidths);\n if (this.values) engine.setNetworkValues(id, this.values);\n return id;\n }\n}\n\n/** The 25 numbers of a network style for the engine */\nfunction networkStyle(style: NetworkStyle): Float32Array {\n const { width, halo, max, contour, opacity, haloOpacity, unreachedColor, fade } = style;\n return Float32Array.from([\n ...stops(width),\n ...stops(halo),\n max,\n contour,\n opacity,\n haloOpacity,\n ...parseColor(unreachedColor),\n fade,\n ]);\n}\n\nconst EMPTY = new Float64Array(0);\n\n/** Interleaved points as f32 offsets from an origin, and back */\nfunction pack(points: Float64Array, [ox, oy]: [number, number]): Float32Array {\n const out = new Float32Array(points.length);\n for (let i = 0; i < points.length; i += 2) {\n out[i] = (points[i] ?? 0) - ox;\n out[i + 1] = (points[i + 1] ?? 0) - oy;\n }\n return out;\n}\n\nfunction unpack(points: Float32Array, [ox, oy]: [number, number]): Float64Array {\n const out = new Float64Array(points.length);\n for (let i = 0; i < points.length; i += 2) {\n out[i] = (points[i] ?? 0) + ox;\n out[i + 1] = (points[i + 1] ?? 0) + oy;\n }\n return out;\n}\n\n/** Longitudes and latitudes (degrees, interleaved) to Mercator [0, 1], y towards the south */\nfunction mercatorPoints(lonLat: Float64Array): Float64Array {\n const out = new Float64Array(lonLat.length);\n for (let i = 0; i < lonLat.length; i += 2) {\n out[i] = mercatorX(lonLat[i] ?? 0);\n out[i + 1] = mercatorY(lonLat[i + 1] ?? 0);\n }\n return out;\n}\n\n/** Textured meshes in 3D Tiles */\nexport class Tiles3dLayer extends Layer {\n /** @internal */\n constructor(\n map: LayerHost,\n private readonly url: string,\n private readonly geoid: boolean,\n private style: Tiles3dStyle,\n ) {\n super(map);\n }\n\n setStyle(style: Partial<Tiles3dStyle>): void {\n this.style = { ...this.style, ...style };\n // Kept for its creation while the engine with 3D Tiles loads\n if (this.id < 0) return;\n this.applyStyle(this.map.engine, this.id);\n this.map.requestRender();\n }\n\n /** @internal */\n override get needsFullEngine(): boolean {\n return true;\n }\n\n /** @internal The feature picked (`pickFeature`, 'hoverfeature'): the properties of its feature in the tile\n * (`EXT_structural_metadata`, a b3dm batch table), none for a mesh without features; its index in the tile as id */\n featureAt(index: number): Feature<Record<string, unknown>> | undefined {\n if (this.id < 0) return undefined;\n const hit = this.map.engine.tiles3dFeature(this.id, index);\n if (!hit) return undefined;\n const [properties, feature] = hit;\n return { type: 'Feature', id: feature, properties: properties ?? {}, geometry: null };\n }\n\n /** Loading counters; undefined once the layer is removed, and while the engine with 3D Tiles loads (see\n * `GeoMapOptions.tiles3d`) */\n stats(): Tiles3dStats | undefined {\n return this.id < 0 ? undefined : this.map.engine.tiles3dStats(this.id);\n }\n\n /** @internal */\n protected create(engine: Engine): number {\n const id = engine.addTiles3d(this.url, this.style.maxScreenSpaceError, this.geoid);\n this.applyStyle(engine, id);\n return id;\n }\n\n private applyStyle(engine: Engine, id: number): void {\n const { maxScreenSpaceError, opacity, pointSize, color } = this.style;\n engine.setTiles3dStyle(id, maxScreenSpaceError, opacity, pointSize, new Float32Array(color ? rgb(color) : []));\n }\n}\n\n/** A texture of a ground layer (see `GroundLayer`) */\nexport interface GroundTexture {\n /** `r8`, `r8ui`, `r16ui`, `r16i`, `r32ui`, `r32f`, `rg16ui`, `rg32f`, `rgba8`, `rgba8ui`, `rgba16ui`, `rgba32f`:\n * integer formats are read with `usampler2D` / `isampler2D` and `texelFetch` */\n format: string;\n width: number;\n height: number;\n /** Layers of a 2D array (`sampler2DArray`, `usampler2DArray`…); 0 or undefined: a 2D texture */\n depth?: number;\n /** Linear filtering (non-integer formats); default nearest */\n linear?: boolean;\n /** Texels row after row (layer after layer), any typed array; undefined: left empty */\n data?: ArrayBufferView;\n}\n\nexport interface GroundOptions {\n /**\n * GLSL ES 3.0 defining `vec4 ground(vec2 offset)`: the color of the ground (premultiplied alpha, 0 for nothing) at\n * `offset`, the Mercator offset of the pixel from `anchor` (times `ISARD_CIRCUMFERENCE`: metres of EPSG:3857), exact to\n * the millimetre at any zoom. The code declares its own uniforms and samplers; also there: `u_zoom`,\n * `u_pixel_ratio`\n */\n code: string;\n /** Where the offsets are taken from */\n anchor: LonLat;\n /** Box it shows in, `[west, south, east, north]` (default the world): only the ground there is drawn again */\n bounds?: [west: number, south: number, east: number, north: number];\n textures?: Record<string, GroundTexture>;\n uniforms?: Record<string, number | readonly number[]>;\n}\n\nconst bytesOf = (data: ArrayBufferView) => new Uint8Array(data.buffer, data.byteOffset, data.byteLength);\n\n/** The application's fragment shader run over the ground, draped on the relief (water depth, heat maps…) */\nexport class GroundLayer extends Layer {\n private readonly textures = new Map<string, GroundTexture>();\n private readonly uniforms = new Map<string, number[]>();\n private visible = true;\n\n /** @internal */\n constructor(\n map: LayerHost,\n private readonly options: GroundOptions,\n ) {\n super(map);\n for (const [name, texture] of Object.entries(options.textures ?? {})) this.textures.set(name, texture);\n for (const [name, value] of Object.entries(options.uniforms ?? {})) this.uniforms.set(name, [value].flat());\n }\n\n /** Creates or replaces a texture of the code's sampler `name` */\n setTexture(name: string, texture: GroundTexture): void {\n this.textures.set(name, texture);\n this.sendTexture(this.map.engine, this.id, name, texture);\n this.map.requestRender();\n }\n\n /**\n * Replaces a region of a texture: `data` holds `width` × `height` texels for (`x`, `y`) of `layer` (2D arrays).\n * Keep the texture's own `data` up to date too if it must survive a WebGL context loss.\n */\n updateTexture(\n name: string,\n data: ArrayBufferView,\n region: { x?: number; y?: number; layer?: number; width: number; height: number },\n ): void {\n const { x = 0, y = 0, layer = 0, width, height } = region;\n this.map.engine.updateGroundTexture(this.id, name, x, y, layer, width, height, bytesOf(data));\n this.map.requestRender();\n }\n\n /** A uniform of the code: a number, or numbers for vectors, arrays and matrices (column major) */\n setUniform(name: string, value: number | readonly number[]): void {\n const values = [value].flat();\n this.uniforms.set(name, values);\n this.map.engine.setGroundUniform(this.id, name, Float64Array.from(values));\n this.map.requestRender();\n }\n\n setBounds(bounds: [west: number, south: number, east: number, north: number]): void {\n this.options.bounds = bounds;\n this.map.engine.setGroundBounds(this.id, ...mercatorBox(bounds));\n this.map.requestRender();\n }\n\n setVisible(visible: boolean): void {\n this.visible = visible;\n this.map.engine.setGroundVisible(this.id, visible);\n this.map.requestRender();\n }\n\n private sendTexture(engine: Engine, id: number, name: string, t: GroundTexture): void {\n const data = t.data && bytesOf(t.data);\n engine.setGroundTexture(id, name, t.format, t.width, t.height, t.depth ?? 0, t.linear ?? false, data);\n }\n\n /** @internal */\n protected create(engine: Engine): number {\n const [ax, ay] = toMercator(this.options.anchor);\n const id = engine.addGround(\n this.options.code,\n ax,\n ay,\n ...mercatorBox(this.options.bounds ?? [-180, -85.06, 180, 85.06]),\n );\n for (const [name, texture] of this.textures) this.sendTexture(engine, id, name, texture);\n for (const [name, values] of this.uniforms) engine.setGroundUniform(id, name, Float64Array.from(values));\n engine.setGroundVisible(id, this.visible);\n return id;\n }\n}\n\n/** A lon/lat box to Mercator min x, min y, max x, max y (y towards the south) */\nfunction mercatorBox([west, south, east, north]: [number, number, number, number]): [number, number, number, number] {\n const [x0, y1] = toMercator([west, south]);\n const [x1, y0] = toMercator([east, north]);\n return [x0, y0, x1, y1];\n}\n\n// ── The page's own 3D content: custom layers, glTF models ──\n\n/** Reports an error of the page without throwing it here: the console shows it, as an uncaught one */\nfunction report(error: unknown): void {\n if (typeof reportError === 'function') reportError(error);\n else\n queueMicrotask(() => {\n throw error;\n });\n}\n\n/** What a custom layer gets to draw a frame (`CustomLayerInterface.render`) */\nexport interface CustomFrame {\n /**\n * The model-view-projection matrix of a local frame at a position and altitude (metres above the ellipsoid, as the\n * relief is drawn: times its exaggeration), column-major for `uniformMatrix4fv` or a three.js camera: x east, y\n * north, z up, in metres. Made in double precision relative to the camera, so that what is drawn stays exact at\n * any zoom; draw within a few kilometres of the position (or take one matrix per object far apart). Only during\n * `render`.\n */\n matrixAt(lonLat: LonLat, altitude?: number): Float32Array;\n /** The camera of the frame */\n readonly camera: Camera;\n}\n\n/**\n * A layer drawn by the page with its own WebGL code, as MapLibre's `CustomLayerInterface`: `render` is called at the\n * layer's place in every frame drawn. It starts with the canvas bound, its viewport set, blending on (`SRC_ALPHA`,\n * `ONE_MINUS_SRC_ALPHA`), no culling, and in `'3d'` mode the depth test on (`LEQUAL`, depth written): the relief, the\n * buildings and the 3D Tiles hide what it draws and what it draws hides them. Whatever WebGL state it changes is set\n * back afterwards; a library that caches the WebGL state (three.js) must forget it first (`renderer.resetState()`).\n *\n * The map is busy drawing meanwhile: `render` reads the frame, not the map (`getCamera` excepted); it may call\n * `requestRender` for an animation.\n */\nexport interface CustomLayerInterface {\n /** A name for the application (the map numbers its layers) */\n id?: string;\n /** `'2d'` (the default): drawn over what is under it; `'3d'`: with the depth buffer of the 3D layers */\n renderingMode?: '2d' | '3d';\n /** Creates the WebGL objects: once added, and again after the WebGL context was lost and restored */\n onAdd?(gl: WebGL2RenderingContext, map: GeoMap): void;\n render(gl: WebGL2RenderingContext, frame: CustomFrame): void;\n /** Frees the WebGL objects: the layer is removed, or the map destroyed */\n onRemove?(gl: WebGL2RenderingContext, map: GeoMap): void;\n}\n\n/** The model-view-projection of a local frame in the engine running the map (`Engine.customMatrix`) */\n/** @internal */\nexport type CustomMatrix = (lon: number, lat: number, altitude: number) => Float32Array | undefined;\n\n/** A layer drawn by the page's WebGL code (see `CustomLayerInterface`) */\nexport class CustomLayer extends Layer {\n /** The map's WebGL context, and whether `onAdd` made the layer's objects there (until `onRemove`) */\n private readonly gl: WebGL2RenderingContext;\n private added = false;\n /** The context was lost since `onAdd`: its objects are gone */\n private stale = false;\n private readonly lost = () => {\n this.stale = true;\n };\n private readonly frame: CustomFrame;\n\n /** @internal */\n constructor(\n map: LayerHost,\n /** The application's object */\n readonly implementation: CustomLayerInterface,\n private readonly canvas: HTMLCanvasElement,\n private readonly owner: GeoMap,\n matrix: CustomMatrix,\n camera: () => Camera,\n ) {\n super(map);\n // The context the engine made on the canvas\n this.gl = canvas.getContext('webgl2') as WebGL2RenderingContext;\n this.frame = {\n matrixAt: ([lon, lat], altitude = 0) => {\n const m = matrix(lon, lat, altitude);\n if (!m) throw new Error('isard: frame.matrixAt is only available during render');\n return m;\n },\n get camera() {\n return camera();\n },\n };\n }\n\n /** @internal */\n protected create(engine: Engine): number {\n // Once, and again on a context restored (not when the map moves onto another engine: the same context)\n if (!this.added || this.stale) {\n if (!this.added) this.canvas.addEventListener('webglcontextlost', this.lost);\n this.added = true;\n this.stale = false;\n this.implementation.onAdd?.(this.gl, this.owner);\n }\n return engine.addCustomLayer(this.draw, this.implementation.renderingMode === '3d');\n }\n\n /** Called by the engine at the layer's place in the frame; the page's errors are reported, the frame goes on */\n private readonly draw = (): void => {\n try {\n this.implementation.render(this.gl, this.frame);\n } catch (error) {\n report(error);\n }\n };\n\n override remove(): void {\n super.remove();\n this.dispose();\n }\n\n /** @internal The layer is removed or the map destroyed: `onRemove`, unless the context is lost */\n override dispose(): void {\n if (!this.added) return;\n this.added = false;\n this.canvas.removeEventListener('webglcontextlost', this.lost);\n if (this.stale) return;\n try {\n this.implementation.onRemove?.(this.gl, this.owner);\n } catch (error) {\n report(error);\n }\n }\n}\n\n/** Where and how a model stands */\nexport interface ModelInstance {\n lonLat: LonLat;\n /** Metres above the ground (or above the ellipsoid, `altitudeReference: 'sea'`); 0 by default */\n altitude?: number;\n /** Degrees clockwise from the north of the model's front (glTF +Z); 0 by default */\n heading?: number;\n /** Degrees, nose up */\n pitch?: number;\n /** Degrees, right side down */\n roll?: number;\n /** 1 by default: the model's metres */\n scale?: number;\n}\n\nexport interface ModelOptions {\n /** URL of a glTF binary (`.glb`): meshes, textures, Draco, meshopt, KTX2, as in 3D Tiles; or its bytes (`data`) */\n url?: string;\n data?: ArrayBuffer | ArrayBufferView<ArrayBuffer>;\n instances: readonly ModelInstance[];\n /** What the altitudes are above: `'ground'` (the relief, the default) or `'sea'` (the ellipsoid) */\n altitudeReference?: 'ground' | 'sea';\n}\n\n/** The numbers of instances for the engine: longitude, latitude, altitude, heading, pitch, roll, scale */\nexport function instanceNumbers(instances: readonly ModelInstance[]): Float64Array {\n const out = new Float64Array(instances.length * 7);\n instances.forEach(({ lonLat, altitude = 0, heading = 0, pitch = 0, roll = 0, scale = 1 }, i) => {\n out.set([lonLat[0], lonLat[1], altitude, heading, pitch, roll, scale], i * 7);\n });\n return out;\n}\n\n/** A glTF model drawn at positions, in one instanced draw; `pickFeature` gives the instance's index */\nexport class ModelLayer extends Layer {\n private readonly url: string;\n /** The `blob:` URL of the page's bytes, revoked once the layer is gone */\n private readonly blob: string | undefined;\n private instances: Float64Array;\n private ground: boolean;\n\n /** @internal */\n constructor(map: LayerHost, options: ModelOptions) {\n super(map);\n const { url, data } = options;\n if (data) {\n this.blob = URL.createObjectURL(new Blob([data], { type: 'model/gltf-binary' }));\n this.url = this.blob;\n } else if (url) {\n // Against the page: the decoding workers fetch it, and a relative URL would be theirs\n const base = typeof document === 'undefined' ? undefined : document.baseURI;\n this.url = base ? new URL(url, base).href : url;\n } else {\n throw new Error('isard: a model needs a url or data');\n }\n this.instances = instanceNumbers(options.instances);\n this.ground = options.altitudeReference !== 'sea';\n }\n\n /** @internal The engine with 3D Tiles decodes and draws the models */\n override get needsFullEngine(): boolean {\n return true;\n }\n\n /** Replaces the instances (and what their altitudes are above, kept if not given) */\n setInstances(instances: readonly ModelInstance[], altitudeReference?: 'ground' | 'sea'): void {\n this.instances = instanceNumbers(instances);\n if (altitudeReference) this.ground = altitudeReference === 'ground';\n // Kept for its creation while the engine with 3D Tiles loads\n if (this.id < 0) return;\n this.map.engine.setModelInstances(this.id, this.instances, this.ground);\n this.map.requestRender();\n }\n\n override remove(): void {\n super.remove();\n this.dispose();\n }\n\n /** @internal */\n override dispose(): void {\n if (this.blob) URL.revokeObjectURL(this.blob);\n }\n\n /** @internal */\n protected create(engine: Engine): number {\n return engine.addModels(this.url, this.instances, this.ground);\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { FirstPersonView, LonLat } from './types.ts';
1
+ import type { FirstPersonView, LonLat } from '../types.ts';
2
2
  export interface PanoramaOptions {
3
3
  /** URL of an image: `{cameraId}` and `{panoId}` replaced by a camera's id and a panorama's */
4
4
  url: string;
@@ -10,8 +10,8 @@
10
10
  * await panoramas.show(panoramas.nearest([2.3345, 48.8505]).index);
11
11
  * ```
12
12
  */
13
- import { getCrs } from "./crs.js";
14
- import { withHeaders } from "./requests.js";
13
+ import { getCrs } from "../data/crs.js";
14
+ import { withHeaders } from "../engine/requests.js";
15
15
  const RAD = Math.PI / 180;
16
16
  /** 3 × 3 product, row-major */
17
17
  function times(a, b) {
@@ -0,0 +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;AA0EpD,MAAM,GAAG,GAAG,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC;AAE1B,+BAA+B;AAC/B,SAAS,KAAK,CAAC,CAAW,EAAE,CAAW;IACrC,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3B,KAAK,IAAI,CAAC,GAAG,CAA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3B,CAAC,CAAC;IACL,CAAC;IACD,OAAO,IAAI,SAAS,CAClB,IAAI,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","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';\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 Attitude {\n heading: number;\n pitch: number;\n roll: number;\n}\n\nconst RAD = Math.PI / 180;\n\n/** 3 × 3 product, row-major */\nfunction times(a: number[], b: number[]): number[] {\n const out: number[] = [];\n for (let r = 0; r < 3; r++) {\n for (let c = 0; c < 3; c++) {\n let sum = 0;\n for (let k = 0; k < 3; k++) sum += (a[r * 3 + k] ?? 0) * (b[k * 3 + c] ?? 0);\n out.push(sum);\n }\n }\n return out;\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 function 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 return times(rotZ(convergence), vehicle);\n}\n\n/** The 25 numbers of a camera for `setPanorama` */\nfunction cameraNumbers(c: Calibration): number[] {\n const p = c.projection;\n const d = c.distortion;\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 let best: Panorama | undefined;\n let distance = Number.POSITIVE_INFINITY;\n for (const p of this.list) {\n const d = ((p.lonLat[0] - lonLat[0]) * cos) ** 2 + (p.lonLat[1] - lonLat[1]) ** 2;\n if (d < distance) [best, distance] = [p, d];\n }\n return 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 if (!pano || !attitude) return;\n const shown = ++this.shown;\n this.current = pano;\n const rotation = panoramaRotation(attitude, pano.lonLat[0], this.lambert93);\n const { url, backgroundDistance, opacity } = this.options;\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 if (!response.ok) throw new Error(`isard: panorama image ${src}: ${response.status}`);\n const image = await createImageBitmap(await response.blob(), { premultiplyAlpha: 'none' });\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 this.stopWalking?.();\n this.stopWalking = this.host.listen(\n (lonLat) => {\n const target = lonLat && this.nearest(lonLat);\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 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 const target = this.ahead(e.deltaY < 0);\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 if (!eye || !here) return undefined;\n const cos = Math.cos(here.lonLat[1] * RAD);\n const look = (eye.bearing + (forward ? 0 : 180)) * RAD;\n let best: Panorama | undefined;\n let distance = Number.POSITIVE_INFINITY;\n for (const p of this.list) {\n if (p === here) continue;\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 if (off < 60 * RAD && d < distance) [best, distance] = [p, d];\n }\n return 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 if (!pano) return;\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 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 async function loadPanoramas(host: PanoramaHost, options: PanoramaOptions): Promise<Panoramas> {\n const json = async <T>(src: string) => {\n const response = await fetch(src, withHeaders(src));\n if (!response.ok) throw new Error(`isard: ${src}: ${response.status}`);\n return (await response.json()) as T;\n };\n const [orientations, cameras] = await Promise.all([\n json<{\n crs?: { properties?: { name?: string } };\n features: { geometry: { coordinates: number[] }; properties: Record<string, unknown> }[];\n }>(options.orientationsUrl),\n json<Calibration[]>(options.calibrationUrl),\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 for (const feature of orientations.features) {\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) => (typeof p[key] === 'number' ? (p[key] as number) : 0);\n attitudes.push({ heading: number('heading'), pitch: number('pitch'), roll: number('roll') });\n list.push({\n index: list.length,\n id: (p.id as number | string | undefined) ?? list.length,\n lonLat: [lon, lat],\n height: z + (geoid ? host.geoidHeight(lon, lat) : 0),\n heading: number('heading'),\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"]}
@@ -5,10 +5,10 @@
5
5
  * in NGF-IGN69 (Lambert-93, the CC zones) are raised by the RAF20 geoid height onto the ellipsoid of the relief and
6
6
  * the 3D Tiles.
7
7
  */
8
- import { type CrsLike } from './crs.ts';
8
+ import { type CrsLike } from '../data/crs.ts';
9
+ import type { PointCloudCrs, PointCloudInfo, PointCloudStats, Tiles3dStats } from '../wasm/isard.js';
9
10
  import { type Ramp } from './features.ts';
10
11
  import { Layer } from './layers.ts';
11
- import type { PointCloudCrs, PointCloudInfo, PointCloudStats, Tiles3dStats } from './wasm/isard.js';
12
12
  /** What the points are colored by */
13
13
  export type PointColor = 'rgb' | 'classification' | 'elevation' | 'intensity';
14
14
  /** The look of a class of points */
@@ -5,7 +5,7 @@
5
5
  * in NGF-IGN69 (Lambert-93, the CC zones) are raised by the RAF20 geoid height onto the ellipsoid of the relief and
6
6
  * the 3D Tiles.
7
7
  */
8
- import { epsgCode, getCrs } from "./crs.js";
8
+ import { epsgCode, getCrs } from "../data/crs.js";
9
9
  import { parseColor, rampTexels } from "./features.js";
10
10
  import { Layer } from "./layers.js";
11
11
  /** The default classes: ASPRS LAS 1.4, then IGN's LiDAR HD (64 permanent structures, 65 artefacts, 66 virtual points,