@nika-js/onlymap 0.11.10 → 0.12.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 (60) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/README.md +10 -4
  3. package/dist/attribute-resolution.d.ts +2 -0
  4. package/dist/{basemap-Cc8v5hPA.js → basemap-CtDse0mW.js} +1328 -1263
  5. package/dist/basemap-request.d.ts +24 -0
  6. package/dist/basemap.d.ts +41 -1
  7. package/dist/cartograph.js +362 -321
  8. package/dist/cartograph.standalone.js +1995 -1914
  9. package/dist/{cityjson-k-z1r6c0.js → cityjson-DMc_dwu1.js} +1 -1
  10. package/dist/{crs-BzE_KP4M.js → crs-D5FyQfEu.js} +74 -7
  11. package/dist/{crs-ChglCB3O.js → crs-ZdDBJ2EY.js} +39 -36
  12. package/dist/data-layer.d.ts +36 -3
  13. package/dist/elements/om-map.d.ts +2 -1
  14. package/dist/geoparquet-BTHYX1ET.js +30 -0
  15. package/dist/geoparquet.d.ts +6 -7
  16. package/dist/{globe-view-BF6-01N_.js → globe-view-KrKNOmVs.js} +11 -11
  17. package/dist/hillshade-CijRdYyU.js +209 -0
  18. package/dist/html-data.d.ts +1 -1
  19. package/dist/{ifc-DXwePQRv.js → ifc-sisRo7I7.js} +1 -1
  20. package/dist/{index-CwoqJ6IK.js → index-21KGElDr.js} +9 -9
  21. package/dist/{index-C9gVsJaG.js → index-A45DtXly.js} +18 -18
  22. package/dist/{index-Dk12Fazj.js → index-BPa2CC8T.js} +20 -20
  23. package/dist/{index-CCY7Rk1s.js → index-B_Vhebf7.js} +1 -1
  24. package/dist/{index-C_0KCx9L.js → index-Bfocr1_A.js} +106 -106
  25. package/dist/{index-Bwdaim-c.js → index-DMc81n9B.js} +14362 -13782
  26. package/dist/{index-CawlYDgE.js → index-DS6VUGi6.js} +11 -11
  27. package/dist/{index-BaR4MzNc.js → index-DoGY-Vgi.js} +3 -3
  28. package/dist/{index-T5LATpR7.js → index-eHYe06mM.js} +1 -1
  29. package/dist/index.d.ts +3 -2
  30. package/dist/ir.d.ts +6 -0
  31. package/dist/layer-registry.d.ts +21 -0
  32. package/dist/layers/warped-bitmap-layer.d.ts +27 -0
  33. package/dist/{lerc-CElHRqrE.js → lerc-DjrPALEj.js} +1 -1
  34. package/dist/onlymap.standalone.js +53028 -52451
  35. package/dist/onlymapjs.js +86 -84
  36. package/dist/parse-manifest.d.ts +12 -9
  37. package/dist/{post-process-effect-VAE0lQ4c.js → post-process-effect-Be1qa2DD.js} +5 -5
  38. package/dist/programmatic.d.ts +12 -0
  39. package/dist/projection.d.ts +44 -1
  40. package/dist/{raster-pipeline-D26Sl0X2.js → raster-pipeline-DspBYxwc.js} +1 -1
  41. package/dist/{raster-Cn8jugd2.js → raster-zC3qXBrs.js} +3 -3
  42. package/dist/react/om-layer.d.ts +4 -0
  43. package/dist/react/om-map.d.ts +2 -0
  44. package/dist/react.js +225 -218
  45. package/dist/runtime-core.d.ts +24 -0
  46. package/dist/source-crs.d.ts +99 -0
  47. package/dist/{text-on-path-C6SLSkus.js → text-on-path-D0_URrD2.js} +1 -1
  48. package/dist/version.d.ts +1 -1
  49. package/dist/{zarr-Do5FzYXm.js → zarr-DopOhzfY.js} +2 -2
  50. package/docs/basemaps.md +1 -1
  51. package/docs/cartograph.md +2 -2
  52. package/docs/cartography.md +106 -1
  53. package/llms.txt +2 -1
  54. package/onlymapjs.attributes.json +2 -0
  55. package/onlymapjs.html-data.json +26 -4
  56. package/package.json +1 -1
  57. package/skills/onlymapjs/SKILL.md +5 -3
  58. package/skills/onlymapjs/references/syntax.md +18 -3
  59. package/dist/geoparquet-B9p5-Yxf.js +0 -35
  60. package/dist/hillshade-Dd7MQHfp.js +0 -298
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: onlymapjs
3
- description: Build, edit, debug, or review OnlyMapJS declarative HTML maps and dashboards, or React maps via the @nika-js/onlymap/react adapter. Use when a user asks for an interactive map, deck.gl-style visualization, geospatial dashboard, live fleet/telemetry map, choropleth, marker clustering / clustered points (count bubbles that split on zoom — the `cluster` toggle), popup/tooltip map, map story/tour, manual drawing/sketch map, 3D map assets, a React map component, a map page shared as a single HTML file (incl. no-JS fallbacks for chat/email previews), a print-ready map sheet / PDF map / atlas (the cartograph entry: mm-based pages, frames, derived legends, scale bars, graticules), a cartograph sheet whose map frame renders BLANK or empty outside the app that made it (frame fallback sources), a styled/post-processed map look (film grain, halftone, duotone, vintage or printed finish, bloom-style passes — the <om-effect> pipeline), shaded relief / hillshade / terrain shading on a flat cartographic map (the HillshadeLayer), a map in a REAL PROJECTION (Albers, state plane, British National Grid, UTM, Lambert — the crs attribute), a label that FOLLOWS A LINE / curved text / text along a path (a river's name down the river — the TextOnPathLayer), generalizing or ornamenting geometry (simplify, smooth, dot density, a coastal vignette/buffer band, contour lines from a DEM — the <om-transform> pipeline), or EXPORTING A MAP AS SVG / editable vector for Illustrator or a print shop (incl. freezing a cartograph frame to inline vector), a responsive/mobile map whose controls auto-fold on narrow screens, auditing a map's widget layout with the check-layout tool, syncing OnlyMapJS map/camera state into an app state store (Redux, MobX, Zustand, Jotai — the getStore contract), BIM/IFC models (loading .ifc files in the browser, 3D Tiles per-element picking, isolate/hide/ghost, clash detection, model federation), routes and directions (a styled A-to-B route line, OSRM or another routing engine, click-to-route), live vehicle/rider/delivery tracking (a moving marker gliding between GPS fixes with a follow camera), a Remotion map video or programmatic map flyover with overlays (route to the separate @nika-js/onlymap-remotion package), a React Native or Expo mobile map (route to the separate @nika-js/onlymap-native package), or help with OnlyMapJS syntax, validation, widgets, data formats, testing, or publishing examples.
3
+ description: Build, edit, debug, or review OnlyMapJS declarative HTML maps and dashboards, or React maps via the @nika-js/onlymap/react adapter. Use when a user asks for an interactive map, deck.gl-style visualization, geospatial dashboard, live fleet/telemetry map, choropleth, marker clustering / clustered points (count bubbles that split on zoom — the `cluster` toggle), popup/tooltip map, map story/tour, manual drawing/sketch map, 3D map assets, a React map component, a map page shared as a single HTML file (incl. no-JS fallbacks for chat/email previews), a print-ready map sheet / PDF map / atlas (the cartograph entry: mm-based pages, frames, derived legends, scale bars, graticules), a cartograph sheet whose map frame renders BLANK or empty outside the app that made it (frame fallback sources), a styled/post-processed map look (film grain, halftone, duotone, vintage or printed finish, bloom-style passes — the <om-effect> pipeline), shaded relief / hillshade / terrain shading on a flat cartographic map (the HillshadeLayer), a map in a REAL PROJECTION (Albers, state plane, British National Grid, UTM, Lambert — the crs attribute), data in a local grid / eastings and northings / a shapefile .prj in BNG or SVY21 (crs on the layer), a label that FOLLOWS A LINE / curved text / text along a path (a river's name down the river — the TextOnPathLayer), generalizing or ornamenting geometry (simplify, smooth, dot density, a coastal vignette/buffer band, contour lines from a DEM — the <om-transform> pipeline), or EXPORTING A MAP AS SVG / editable vector for Illustrator or a print shop (incl. freezing a cartograph frame to inline vector), a responsive/mobile map whose controls auto-fold on narrow screens, auditing a map's widget layout with the check-layout tool, syncing OnlyMapJS map/camera state into an app state store (Redux, MobX, Zustand, Jotai — the getStore contract), BIM/IFC models (loading .ifc files in the browser, 3D Tiles per-element picking, isolate/hide/ghost, clash detection, model federation), routes and directions (a styled A-to-B route line, OSRM or another routing engine, click-to-route), live vehicle/rider/delivery tracking (a moving marker gliding between GPS fixes with a follow camera), a Remotion map video or programmatic map flyover with overlays (route to the separate @nika-js/onlymap-remotion package), a React Native or Expo mobile map (route to the separate @nika-js/onlymap-native package), or help with OnlyMapJS syntax, validation, widgets, data formats, testing, or publishing examples.
4
4
  ---
5
5
 
6
6
  # OnlyMapJS
@@ -23,7 +23,7 @@ Use OnlyMapJS as a declarative HTML map library. Write custom elements such as `
23
23
  </script>
24
24
  ```
25
25
 
26
- For no-build CDN pages, use the single-file standalone bundle from a raw-file CDN — `https://unpkg.com/@nika-js/onlymap@0.11.10` (the bare package URL serves `dist/onlymap.standalone.js`) — plus `<link rel="stylesheet" href="https://unpkg.com/@nika-js/onlymap@0.11.10/dist/onlymapjs.css">`. Never a rebundling CDN (esm.sh, skypack): re-bundling duplicates the deck.gl/luma.gl runtime and every layer fails shader compilation.
26
+ For no-build CDN pages, use the single-file standalone bundle from a raw-file CDN — `https://unpkg.com/@nika-js/onlymap@0.11.11` (the bare package URL serves `dist/onlymap.standalone.js`) — plus `<link rel="stylesheet" href="https://unpkg.com/@nika-js/onlymap@0.11.11/dist/onlymapjs.css">`. Never a rebundling CDN (esm.sh, skypack): re-bundling duplicates the deck.gl/luma.gl runtime and every layer fails shader compilation.
27
27
 
28
28
  ## React Projects
29
29
 
@@ -80,7 +80,9 @@ Load the smallest reference needed for the task:
80
80
  - Keep mobile chrome usable -> rely on the default map-width auto-fold into per-side drawers; mark only essential controls `fold="never"`. Use `widgets-fold="off"` only when the user explicitly wants fixed wide-layout chrome.
81
81
  - Group adjacent map buttons (zoom + undo + toggle into one control group) -> just place compact button widgets in the same `position` slot; they auto-cluster. `cluster="false"` opts one out. Do NOT build a wrapper widget.
82
82
  - Shaded relief / hillshade / terrain shading on a FLAT map (a cartographic relief base, Swiss-style multi-directional relief) -> `<om-layer type="HillshadeLayer" src="terrarium">`, NOT `terrain=` (that raises a 3D surface and means nothing at pitch 0). `sun-azimuth` takes a LIST of one to four azimuths (`"315 45 135"`) — there is no `multi-directional` boolean. `src` is required even though `terrarium` is keyless. See references/syntax.md and docs/hillshade.md.
83
- - A map in a REAL PROJECTION (an Albers or state-plane sheet, a national grid, "not Web Mercator") -> `crs="EPSG:5070"` on `<om-map>`, with `basemap="none"`. The authored camera STAYS geographic (`center` is lng/lat, `zoom` unchanged), so stories and `seek()` keep working. A projected map cannot carry a MapLibre basemap, `terrain`, `pitch`/`bearing`, or H3/S2/geohash/quadkey layers — each is a validation error with a fix. Relief DOES work. See docs/cartography.md.
83
+ - A map in a REAL PROJECTION (an Albers or state-plane sheet, a national grid, "not Web Mercator") -> `crs="EPSG:5070"` on `<om-map>`, with `basemap="none"`. The authored camera STAYS geographic (`center` is lng/lat, `zoom` unchanged), so stories and `seek()` keep working. A projected map cannot carry a MapLibre basemap, `terrain`, `pitch`/`bearing`, vector/3D tile layers, or H3/S2/geohash/quadkey layers — each is a validation error with a fix. Relief DOES work, and so do IMAGE tiles: for a satellite or OSM backdrop, keep `basemap="none"` and add `<om-layer type="TileLayer" data="…/{z}/{x}/{y}.jpg">` (the validation error for `basemap="satellite"` gives the exact line), then show the tiles' credit yourself with `<om-widget type="attribution" text="…">`. See docs/cartography.md.
84
+ - A GLOBE ("show it on a globe", flight routes, polar or whole-world data) -> `projection="globe"` on `<om-map>` WITH a basemap (`basemap="satellite"` is keyless). Layers and `center`/`zoom` are unchanged; it switches live (`set-projection` action). No `pitch`/`bearing`, `terrain`, `crs`, TextLayer/IconLayer/TextOnPathLayer/PopupLayer, ArcLayer, or heatmap/hexagon/grid/contour layers on a globe — each is a validation error with a fix. Put labels in `<om-overlay anchor="[lng,lat]">` (they hide on the far side) and draw routes as a PathLayer through points along the great circle. Preview.
85
+ - Data whose coordinates are eastings/northings (a national grid, State Plane, UTM — "it's in SVY21", "the shapefile is in BNG", numbers in the hundreds of thousands) -> leave the data as it is. A shapefile `.prj`, a FlatGeobuf/GeoParquet header or a GeoJSON `crs` member is read automatically; otherwise add `crs="EPSG:<code>"` to the `<om-layer>` (for a CSV: `crs="EPSG:3414" get-position="[$easting, $northing]"`). Do NOT convert the coordinates yourself, and do NOT put this on `<om-map crs>` — that one chooses how the MAP is drawn (syntax.md "Data in a local grid").
84
86
  - Generalizing or ornamenting geometry (smooth a jagged coastline, thin a dense one, scatter dots for population, an engraved coastal vignette, contour lines) -> `<om-transform type="simplify|smooth|dot-density|buffer|contour">` as a CHILD of the `<om-layer>`. Spatial knobs are millimetres on paper and need `reference-scale` on `<om-map>`; ground units (`tolerance="50m"`) need none. `buffer` is a cartographic ORNAMENT with a measured half-cell bound — for a setback somebody will act on, say so and point at PostGIS/turf. See docs/cartography.md.
85
87
  - A label that FOLLOWS a line (curved text, text on a path, "the river's name should run along the river") -> `<om-layer type="TextOnPathLayer" get-path="$path" get-text="$name">`. deck has no such layer; this is a composite emitting one text instance per glyph. `letter-spacing` tracks names out (the convention for oceans and ranges), `offset` moves it off the line, `placement="start|middle|end"` picks where. It reads left-to-right whichever way the line was digitised, and a name that does not fit is DROPPED rather than squeezed. Add `pickable` to make labels clickable — a pick reports the label's ROW, so `{{name}}` popups work (0.11.6+). Exports as one `<textPath>`. See docs/cartography.md.
86
88
  - Exporting a map as EDITABLE VECTOR (SVG for Illustrator, a print shop, "not a screenshot") -> `await map.snapshot({ format: "svg" })`, which returns SVG text. Labels come out as real `<text>`; rasters and 3D come out as placed `<image>` bands. A `<om-effect>` print finish forces the whole frame to one raster band — say that BEFORE the user builds a sheet around both. `frame.freeze({format: "svg"})` does the same inside a cartograph frame. See docs/cartography.md.
@@ -16,8 +16,8 @@ Vite/npm project:
16
16
  Static CDN page (raw-file CDNs only — unpkg/jsDelivr; never esm.sh or another rebundling CDN, which duplicates the WebGL runtime and breaks layer shaders):
17
17
 
18
18
  ```html
19
- <link rel="stylesheet" href="https://unpkg.com/@nika-js/onlymap@0.11.10/dist/onlymapjs.css">
20
- <script type="module" src="https://unpkg.com/@nika-js/onlymap@0.11.10"></script>
19
+ <link rel="stylesheet" href="https://unpkg.com/@nika-js/onlymap@0.11.11/dist/onlymapjs.css">
20
+ <script type="module" src="https://unpkg.com/@nika-js/onlymap@0.11.11"></script>
21
21
  ```
22
22
 
23
23
  Always include `onlymapjs.css` — it carries the MapLibre basemap styles and the no-JS fallback rules (`<om-fallback>` / default banner). For the fallback to work in script-disabled previews it must load without JavaScript: a real `<link rel="stylesheet">` or inlined `<style>` on no-build pages (a bundler-emitted stylesheet is fine in npm projects).
@@ -52,7 +52,9 @@ Common attributes:
52
52
  - A REAL PROJECTION is `crs` on `<om-map>`: `<om-map crs="EPSG:5070" basemap="none" center="[-98,39]" zoom="4">`. The whole renderer draws in that plane — parallels curve, an equal-area projection is genuinely equal-area. Web Mercator and plate carrée need nothing; national grids and UTM zones resolve through proj4, loaded only when a map asks; anything else takes `crs-def="+proj=…"` or `OmMap.registerCrs(code, defOrFunctions)`.
53
53
  - THE AUTHORED CAMERA STAYS GEOGRAPHIC. `center` is lng/lat and `zoom` means what it always meant, so stories, `seek()`, `getCamera()` and state bridges are unchanged. Clicks report lng/lat, not plane metres.
54
54
  - Limits, each a validation ERROR with a fix, never a silent no-op: no MapLibre basemap (`basemap="none"`), no `terrain`, no `pitch`/`bearing` (the view is planimetric), no H3/S2/geohash/quadkey layers (deck builds their geometry from a token inside the layer — convert the cells to polygons), and the CRS is fixed for the map's life.
55
+ - IMAGE TILES work on a projected sheet: `<om-layer type="TileLayer" data="…/{z}/{x}/{y}.png">` (`.png`/`.jpg`/`.jpeg`/`.webp`) is re-indexed and warped onto the plane — this is how a raster basemap goes on a projected map. The map never swaps `basemap` for you: `basemap="satellite"` or `"osm"` stays an error whose fix is that preset's tiles as this layer. Credit the tiles yourself (`<om-widget type="attribution" text="…">` — the error's fix includes the line), since the map credits only the basemaps it picks. Vector tiles (`MVTLayer`, a `.pbf` TileLayer), `TerrainLayer` and `Tile3DLayer` stay errors.
55
56
  - Relief DOES work on a projected sheet, both routes. `sun-datum="sheet"` (default) keeps the apparent light constant across the plate; `"geographic"` is physically true. The swing is 34° across a CONUS sheet; the attribute is inert in Mercator and the validator says so.
57
+ - A GLOBE is `projection="globe"` (preview), not `crs`: `<om-map projection="globe" basemap="satellite" center="[-20,30]" zoom="1.6">`. It NEEDS a basemap (MapLibre draws the sphere). Zoomed in it becomes the flat map by itself. Live: `set-projection {projection: "globe" | "mercator"}` writes the attribute, and a basemap switch keeps the globe. Overlays on the far side hide; a click in space reports `coordinate: null`. Flat-on and north-up — no `pitch`/`bearing`. Errors with fixes: `crs`, `terrain`/TerrainLayer, `basemap="none"`, TextLayer/IconLayer/TextOnPathLayer/PopupLayer (use `<om-overlay>` labels), ArcLayer/GreatCircleLayer (use a PathLayer through points along the route), Heatmap/Hexagon/Grid/ScreenGrid/Contour (pre-aggregate to polygons), and a globe inside a cartograph frame. Clustered layers warn: bubbles draw, counts do not.
56
58
  - `reference-scale="1:50000"` (or `"50m"`) is what millimetre-authored `<om-transform>` knobs resolve against.
57
59
  - GEOMETRY TRANSFORMS are `<om-transform>` CHILDREN of an `<om-layer>`, applied in document order, in the DATA stage — so deck, `anchor="surface"`, the legend and the vector exporter all see the same geometry.
58
60
  - `type="simplify" tolerance="0.15mm"` — Douglas–Peucker, measured on the GROUND rather than in degrees (a longitude degree is 111 km at the equator and 56 km at 60°N).
@@ -407,7 +409,7 @@ A `data` URL that fails to load (404, CORS, a typo) is reported as a diagnostic
407
409
  | Columnar JSON | `{"columns": {"lon": [...], "lat": [...]}}` | Fast point path. |
408
410
  | CSV / TSV | `data="./quakes.csv"` | Parsed to typed columns. |
409
411
  | Arrow / GeoArrow IPC | `data="./big.arrow"` | Points stay columnar; lines/polygons become GeoJSON features. |
410
- | Shapefile | `data="./countries.shp"` | Loads sidecars and joins `.dbf` attributes. |
412
+ | Shapefile | `data="./countries.shp"` | Loads sidecars and joins `.dbf` attributes; a `.prj` in a local grid is converted to lng/lat. |
411
413
  | KML | `data="./tour.kml"` | Placemarks become GeoJSON features. |
412
414
  | GPX | `data="./hike.gpx"` (opt. `#waypoints`/`#tracks`/`#routes`) | Waypoints/tracks/routes → GeoJSON features, each tagged `_gpxKind`; a URL fragment selects one part (no fragment = all). |
413
415
  | FlatGeobuf | `data="./cities.fgb"` | Cloud-native binary vector — whole-file decode to GeoJSON features (bbox-streaming is a later phase). |
@@ -420,6 +422,19 @@ A `data` URL that fails to load (404, CORS, a typo) is reported as a diagnostic
420
422
  | Tiled layer | `type="TileLayer" data="…/{z}/{x}/{y}.png"` or `type="MVTLayer" data="…/{z}/{x}/{y}.pbf"` | A `{z}/{x}/{y}` template is deck's tile URL, NOT rows — passed through verbatim (never fetched/parsed). See below. |
421
423
 
422
424
 
425
+ **Data in a local grid** (eastings/northings — British National Grid, SVY21, State Plane, UTM): the map converts it to longitude/latitude when it loads. A file that names its own CRS needs nothing: a shapefile's `.prj`, a FlatGeobuf or GeoParquet header, or a legacy GeoJSON `crs` member is read and applied. Otherwise declare it on the layer — `crs="EPSG:27700"` — which also overrides the file. A CSV of eastings/northings is the usual case:
426
+
427
+ ```html
428
+ <om-layer id="sites" type="ScatterplotLayer" data="./sites.csv" crs="EPSG:3414"
429
+ get-position="[$easting, $northing]" radius-units="pixels" get-radius="6"></om-layer>
430
+ ```
431
+
432
+ - `crs` takes an EPSG code (`EPSG:27700`, `27700`, `urn:ogc:def:crs:EPSG::27700`) or WKT. `crs-def="+proj=…"` supplies a definition for a grid with no EPSG code.
433
+ - Bundled offline: every WGS84, ETRS89, NAD83 and GDA94/GDA2020 UTM zone, and the common national grids (BNG 27700, SVY21 3414, RD New 28992, LV95 2056, Lambert-93 2154, NZTM 2193, SWEREF99 3006, LAEA Europe 3035, Australian Albers 3577, Hong Kong 2326, Korea 5179, Taiwan 3826, Conus Albers 5070, Austria, Japan). Any other EPSG code is looked up ONCE at `https://epsg.io/<code>.proj4` from the reader's browser and cached for the session; `OmMap.configureCrs({ online: false })` turns that off, and a code nothing knows is then an error naming `OmMap.registerCrs(code, "+proj=…")` / `crs-def`.
434
+ - Never a guess: coordinates too large to be degrees with no CRS anywhere are an error (`om-layer#<id> [crs]` in diagnostics) naming the fix; a declared grid on data that is already degrees is a warning.
435
+ - `crs` on a LAYER says what the data is in. `crs` on `<om-map>` is a different thing: the projection the whole map is drawn in. They combine — BNG data on a BNG map, SVY21 data on a Mercator map.
436
+ - Accuracy: the built-in datum shifts are good to a few metres (BNG's OSTN15 correction grid is not shipped).
437
+
423
438
  Data URLs accept any scheme the runtime's `fetch` supports — desktop webviews (Tauri, Electron) pass asset-protocol URLs (`asset://localhost/…`, custom schemes) straight in; format detection reads the path extension either way.
424
439
 
425
440
  ### Tiled layers (TileLayer, MVTLayer)
@@ -1,35 +0,0 @@
1
- import { a4 as p, a5 as d } from "./index-Bwdaim-c.js";
2
- function g(t) {
3
- if (t == null) return !0;
4
- const e = t, n = e.id?.code;
5
- return n != null ? n === 84 || n === 4326 || n === "CRS84" || n === "4326" : typeof e.name == "string" && /^\s*(ogc:)?(wgs\s*84|crs\s*84|wgs84)\s*$/i.test(e.name);
6
- }
7
- function y(t) {
8
- const e = t;
9
- return typeof e?.name == "string" && e.name ? `"${e.name}"` : e?.id?.code != null ? `${e.id.authority ?? "?"}:${e.id.code}` : "a non-CRS84 CRS";
10
- }
11
- function h(t, e, n) {
12
- const r = e.primary_column;
13
- if (!r)
14
- throw new Error(`data="${n}": GeoParquet "geo" metadata names no primary_column — can't tell which column is geometry.`);
15
- const c = e.columns?.[r]?.crs;
16
- if (!g(c))
17
- throw new Error(
18
- `data="${n}": GeoParquet CRS ${y(c)} isn't CRS84/EPSG:4326 — reprojection isn't supported yet (deck.gl renders lng/lat). Reproject first, e.g. ogr2ogr -t_srs EPSG:4326 out.parquet in.parquet.`
19
- );
20
- if (t.length === 0)
21
- return console.warn(`[onlymapjs] data="${n}": GeoParquet has no rows — empty layer.`), [];
22
- const u = t.map((o) => o[r]);
23
- if (u.every((o) => o != null && o.type === "Point")) {
24
- const o = t.map(({ [r]: i, ...m }) => m), a = p(o), s = u.map((i) => i.coordinates ?? void 0);
25
- return { length: t.length, columns: { ...a?.columns ?? {}, [r]: s } };
26
- }
27
- const l = t.map(({ [r]: o, ...a }) => {
28
- const s = a.id;
29
- return { type: "Feature", ...s != null ? { id: s } : {}, geometry: o ?? null, properties: a };
30
- });
31
- return d({ type: "FeatureCollection", features: l });
32
- }
33
- export {
34
- h as geoParquetToLayerData
35
- };
@@ -1,298 +0,0 @@
1
- import { al as P, am as T, an as N, ao as Z, c as B, ap as E, aq as C, ar as b, as as D, at as I, au as O } from "./index-Bwdaim-c.js";
2
- import { N as _, c as H } from "./hillshade-apron-Bem3DWyJ.js";
3
- import { p as $, h as j, m as A, a as U } from "./hillshade-shader-DI2uLSNU.js";
4
- function R(t, e, o) {
5
- return [t.west + (t.east - t.west) * e, t.north + (t.south - t.north) * o];
6
- }
7
- function W(t, e, o) {
8
- const n = Math.max(1, Math.round(o)), a = n + 1, s = a * a, m = new Float64Array(s * 3), i = new Float32Array(s * 2), u = new Uint32Array(n * n * 6);
9
- for (let h = 0; h < a; h++) {
10
- const f = h / n;
11
- for (let d = 0; d < a; d++) {
12
- const l = d / n, c = h * a + d, [p, g] = e.toPlane(R(t, l, f));
13
- m[c * 3] = p, m[c * 3 + 1] = g, m[c * 3 + 2] = 0, i[c * 2] = l, i[c * 2 + 1] = f;
14
- }
15
- }
16
- let r = 0;
17
- for (let h = 0; h < n; h++)
18
- for (let f = 0; f < n; f++) {
19
- const d = h * a + f, l = d + 1, c = d + a, p = c + 1;
20
- u[r++] = d, u[r++] = c, u[r++] = l, u[r++] = l, u[r++] = c, u[r++] = p;
21
- }
22
- return { positions: m, texCoords: i, indices: u, vertexCount: u.length };
23
- }
24
- function k(t, e = 1) {
25
- const o = Number.isFinite(t) ? t : 0, n = o <= 3 ? 8 : o <= 5 ? 4 : o <= 8 ? 2 : 1, a = Number.isFinite(e) && e > 1 ? Math.sqrt(e) : 1;
26
- return Math.min(16, Math.max(1, Math.round(n * a)));
27
- }
28
- function q(t, e, o = 1e3) {
29
- const [n, a] = t.toPlane(e), s = o / (t.projection.metresPerUnit || 1), m = t.fromPlane([n, a]), i = t.fromPlane([n, a + s]);
30
- if (!Number.isFinite(i[0]) || !Number.isFinite(i[1])) return 0;
31
- const u = (m[1] + i[1]) / 2 * Math.PI / 180, r = (i[0] - m[0]) * Math.cos(u), h = i[1] - m[1], f = Math.atan2(r, h) * 180 / Math.PI;
32
- return Number.isFinite(f) ? f : 0;
33
- }
34
- const w = 512;
35
- function J(t, e, o, n = w) {
36
- return Z(t.zoom, o, e.projection.metresPerUnit) + Math.log2(w / (n || w));
37
- }
38
- const M = /* @__PURE__ */ new WeakMap();
39
- function K(t) {
40
- const e = M.get(t);
41
- if (e) return e;
42
- class o extends P {
43
- getTileIndices(a) {
44
- const s = a.viewport, m = this, i = s.unproject([s.width / 2, s.height / 2]), [, u] = t.fromPlane([i[0], i[1]]), r = a.zoomOffset ?? m.opts.zoomOffset ?? 0;
45
- let h = Math.round(J(s, t, u, m.opts.tileSize) + r);
46
- const f = a.maxZoom ?? m.opts.maxZoom, d = a.minZoom ?? m.opts.minZoom;
47
- if (typeof f == "number" && (h = Math.min(h, f)), typeof d == "number" && (h = Math.max(h, d)), !Number.isFinite(h)) return [];
48
- const l = s.unproject([0, 0]), c = s.unproject([s.width, s.height]), p = {
49
- left: Math.min(l[0], c[0]),
50
- right: Math.max(l[0], c[0]),
51
- bottom: Math.min(l[1], c[1]),
52
- top: Math.max(l[1], c[1])
53
- };
54
- return T(t, p, Math.max(0, h));
55
- }
56
- /**
57
- * Two extents, because a warped tile genuinely has two.
58
- *
59
- * `bbox` is what deck CULLS against, and it compares against
60
- * `viewport.unproject()` of the screen rectangle — plane metres here. A
61
- * geographic bbox put in this slot compares degrees against metres, never
62
- * overlaps, and every tile is silently invisible: tiles fetch, nothing
63
- * draws, and no error is raised anywhere. It is the `left/top/right/bottom`
64
- * form, which is the one deck reads for a non-geospatial viewport.
65
- *
66
- * `lngLatBbox` is the tile's own geographic extent, which is what the warp
67
- * mesh projects. The plane envelope is taken by sampling the tile's EDGES,
68
- * not its corners — a conic bows them, so a corner-only envelope clips the
69
- * tile away at exactly the zoom where the bowing matters.
70
- */
71
- getTileMetadata(a) {
72
- const s = N(a.x, a.y, a.z);
73
- let m = 1 / 0, i = -1 / 0, u = 1 / 0, r = -1 / 0;
74
- const h = 5;
75
- for (let f = 0; f <= h; f++) {
76
- const d = f / h, l = s.west + (s.east - s.west) * d, c = s.south + (s.north - s.south) * d;
77
- for (const p of [
78
- t.toPlane([l, s.north]),
79
- t.toPlane([l, s.south]),
80
- t.toPlane([s.west, c]),
81
- t.toPlane([s.east, c])
82
- ])
83
- !Number.isFinite(p[0]) || !Number.isFinite(p[1]) || (p[0] < m && (m = p[0]), p[0] > i && (i = p[0]), p[1] < u && (u = p[1]), p[1] > r && (r = p[1]));
84
- }
85
- return {
86
- bbox: { left: m, top: r, right: i, bottom: u },
87
- lngLatBbox: { west: s.west, south: s.south, east: s.east, north: s.north }
88
- };
89
- }
90
- }
91
- return M.set(t, o), o;
92
- }
93
- const G = 64, y = /* @__PURE__ */ new Map();
94
- function z(t) {
95
- const e = y.get(t);
96
- if (e) return e;
97
- const o = I(t);
98
- if (y.set(t, o), y.size > G) {
99
- const n = y.keys().next().value;
100
- n !== void 0 && y.delete(n);
101
- }
102
- return o;
103
- }
104
- function F(t, e, o, n) {
105
- return t.replace("{z}", String(n)).replace("{x}", String(e)).replace("{y}", String(o));
106
- }
107
- async function V(t, e, o) {
108
- const n = await z(F(t, o.x, o.y, o.z));
109
- if (!n) return null;
110
- const a = (i) => ({
111
- width: i.width,
112
- height: i.height,
113
- at: (u, r) => {
114
- const h = (r * i.width + u) * 4;
115
- return O(e, i.data[h], i.data[h + 1], i.data[h + 2]);
116
- }
117
- }), s = 2 ** o.z, m = /* @__PURE__ */ new Map();
118
- return await Promise.all(
119
- _.map(async ({ dx: i, dy: u }) => {
120
- const r = o.y + u;
121
- if (r < 0 || r >= s) return;
122
- const h = ((o.x + i) % s + s) % s;
123
- m.set(`${i},${u}`, await z(F(t, h, r, o.z)));
124
- })
125
- ), H(a(n), (i, u) => {
126
- const r = m.get(`${i},${u}`);
127
- return r ? a(r) : null;
128
- });
129
- }
130
- const Y = {
131
- blendColorSrcFactor: "dst",
132
- blendColorDstFactor: "zero",
133
- blendAlphaSrcFactor: "zero",
134
- blendAlphaDstFactor: "one"
135
- };
136
- class S extends D {
137
- static layerName = "HillshadeBitmapLayer";
138
- getShaders() {
139
- const e = super.getShaders();
140
- return { ...e, modules: [...e.modules, U] };
141
- }
142
- draw(e) {
143
- const o = this.props, n = { ...o.hillshadeUniforms, hillshadeHeights: o.image };
144
- for (const a of this.getModels()) a.shaderInputs.setProps({ hillshade: n });
145
- super.draw(e);
146
- }
147
- }
148
- class Q extends S {
149
- static layerName = "WarpedHillshadeBitmapLayer";
150
- _createMesh() {
151
- const e = this.props, o = e._planeFrame, n = e._planeBounds;
152
- return !o || !n ? super._createMesh() : W(n, o, e._subdivision ?? 1);
153
- }
154
- }
155
- function X(t, e) {
156
- if (!t) return e;
157
- if (typeof t != "string") return t;
158
- if (t in b) return b[t];
159
- try {
160
- const o = JSON.parse(t);
161
- if ([o?.rScaler, o?.gScaler, o?.bScaler, o?.offset].every((n) => typeof n == "number" && Number.isFinite(n))) return o;
162
- } catch {
163
- }
164
- return console.warn(`[onlymapjs] HillshadeLayer: decoder="${t}" is not "terrarium", "mapbox-rgb" or {rScaler,gScaler,bScaler,offset} JSON — using terrarium.`), e;
165
- }
166
- function tt(t) {
167
- const e = C(t.src);
168
- return e ? e.requiresKey ? (console.warn(`[onlymapjs] HillshadeLayer: src="${t.src}" needs a ${e.requiresKey} key, which this layer does not plumb — use a keyless source such as "terrarium".`), null) : {
169
- template: e.elevationData,
170
- decoder: typeof e.decoder == "string" ? b[e.decoder] : e.decoder,
171
- maxZoom: t.maxZoom ?? e.maxZoom
172
- } : !t.src || !t.src.includes("{z}") ? (console.warn(`[onlymapjs] HillshadeLayer: src="${t.src}" is neither a registered terrain preset nor a {z}/{x}/{y} DEM URL template.`), null) : { template: t.src, decoder: X(t.decoder, b.terrarium), maxZoom: t.maxZoom ?? 14 };
173
- }
174
- function et(t, e) {
175
- return !Number.isFinite(t) || !Number.isFinite(e) || e <= 0 ? 0 : Math.max(0, Math.round(Math.log2(Math.max(1, t / e))));
176
- }
177
- class rt extends B {
178
- static layerName = "OmHillshadeLayer";
179
- static defaultProps = {
180
- src: { type: "string", value: "terrarium" },
181
- decoder: { type: "string", value: null, optional: !0 },
182
- sunAzimuth: { type: "string", value: "315" },
183
- sunWeight: { type: "string", value: null, optional: !0 },
184
- sunElevation: { type: "number", value: 45 },
185
- zFactor: { type: "number", value: 1 },
186
- blend: { type: "string", value: "normal" },
187
- maxZoom: { type: "number", value: null, optional: !0 },
188
- zoomOffset: { type: "number", value: 0 },
189
- _planeFrame: { type: "object", value: null, optional: !0, compare: !1 },
190
- sunDatum: { type: "string", value: "sheet" }
191
- };
192
- renderLayers() {
193
- const e = tt(this.props);
194
- if (!e) return null;
195
- const { azimuths: o, weights: n } = $(this.props.sunAzimuth, this.props.sunWeight), a = this.props.blend === "multiply", s = this.context.device, m = s?.canvasContext?.cssToDeviceRatio?.() ?? 1, i = typeof devicePixelRatio == "number" && devicePixelRatio > 0 ? devicePixelRatio : 1, u = this.state.textures, r = this.props._planeFrame ?? null, h = Math.max(1, m / i), f = this.props.sunDatum === "geographic";
196
- return new E(
197
- this.getSubLayerProps({ id: "tiles" }),
198
- {
199
- data: e.template,
200
- tileSize: 256,
201
- maxZoom: e.maxZoom,
202
- // A plane view's viewport zoom is in PLANE units — about -12 for a
203
- // continental Albers sheet, because a plane unit is a metre and a
204
- // Mercator world unit at that latitude is sixty kilometres. TileLayer's
205
- // `minZoom` gate compares the VIEWPORT's zoom against it, so deck's
206
- // default of 0 hid every tile: they fetched, they were selected, and
207
- // `renderSubLayers` was never called — no error anywhere. The tile
208
- // PYRAMID's zoom range is a different number entirely, and the plane
209
- // tileset applies it to the geographic zoom it derives.
210
- ...r ? { TilesetClass: K(r), minZoom: -1 / 0 } : {},
211
- zoomOffset: (this.props.zoomOffset ?? 0) + et(m, i),
212
- // deck compares FUNCTION props by their update triggers, never by
213
- // identity — inline closures would otherwise invalidate everything on
214
- // every render. So anything a closure captures is invisible to deck
215
- // unless it is declared here, which is why moving the sun with no
216
- // trigger produced a byte-identical frame.
217
- //
218
- // The split is exactly the one we want. `getTileData` names only what
219
- // changes the HEIGHTS, so a new decoder or source refetches; the
220
- // illumination names `renderSubLayers`, which regenerates the draw
221
- // calls and refetches nothing — moving the sun costs no network at
222
- // all, because every knob below is a uniform.
223
- updateTriggers: {
224
- getTileData: [e.template, JSON.stringify(e.decoder)],
225
- renderSubLayers: [o.join(","), n.join(","), this.props.sunElevation, this.props.zFactor, a, f, r?.projection.code ?? ""]
226
- },
227
- getTileData: async (d) => {
228
- const l = await V(e.template, e.decoder, d.index);
229
- if (!l || !s) return null;
230
- const c = `${d.index.z}/${d.index.x}/${d.index.y}`;
231
- u.get(c)?.destroy();
232
- const p = s.createTexture({
233
- data: l.data,
234
- format: "r32float",
235
- width: l.width + 2,
236
- height: l.height + 2,
237
- // NEAREST, because linear filtering of a float texture needs
238
- // OES_texture_float_linear, which is not universal (the same
239
- // constraint raster-pipeline.ts documents).
240
- sampler: { minFilter: "nearest", magFilter: "nearest", addressModeU: "clamp-to-edge", addressModeV: "clamp-to-edge" }
241
- });
242
- return u.set(c, p), { texture: p, width: l.width, height: l.height, key: c };
243
- },
244
- onTileUnload: (d) => {
245
- const l = `${d.index.z}/${d.index.x}/${d.index.y}`;
246
- u.get(l)?.destroy(), u.delete(l);
247
- },
248
- renderSubLayers: (d) => {
249
- const l = d.data;
250
- if (!l) return null;
251
- const c = d.tile, [[p, g], [v, x]] = r && c.lngLatBbox ? [[c.lngLatBbox.west, c.lngLatBbox.south], [c.lngLatBbox.east, c.lngLatBbox.north]] : c.boundingBox, L = r ? Q : S;
252
- return new L(d, {
253
- id: `${d.id}-bitmap`,
254
- data: void 0,
255
- image: l.texture,
256
- bounds: [p, g, v, x],
257
- _planeFrame: r,
258
- _planeBounds: r ? { west: p, south: g, east: v, north: x } : void 0,
259
- _subdivision: r ? k(c.index.z, h) : 1,
260
- multiply: a,
261
- parameters: a ? Y : {},
262
- hillshadeUniforms: j({
263
- width: l.width,
264
- height: l.height,
265
- azimuthOffset: r && !f ? q(r, [(p + v) / 2, (x + g) / 2]) : 0,
266
- // Web Mercator: one scale for both axes, stated at the equator
267
- // and given its cos-phi falloff per fragment by the shader.
268
- ...A(c.index.z, l.width, l.height),
269
- north: x,
270
- south: g,
271
- azimuths: o,
272
- weights: n,
273
- sunElevation: this.props.sunElevation ?? 45,
274
- zFactor: this.props.zFactor ?? 1,
275
- // This layer's texture IS the heightfield, so there is no
276
- // sampled colour to multiply into — a multiply-blended tile emits
277
- // the shade and lets the GL blend put it in the framebuffer.
278
- composite: a ? "framebuffer" : !1
279
- })
280
- });
281
- }
282
- }
283
- );
284
- }
285
- initializeState() {
286
- this.setState({ textures: /* @__PURE__ */ new Map() });
287
- }
288
- finalizeState() {
289
- for (const e of this.state.textures.values()) e.destroy();
290
- this.state.textures.clear();
291
- }
292
- }
293
- export {
294
- rt as OmHillshadeLayer,
295
- V as buildPaddedHeights,
296
- et as captureZoomOffset,
297
- tt as resolveHillshadeSource
298
- };