@nika-js/onlymap 0.11.11 → 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.
- package/README.md +9 -3
- package/dist/attribute-resolution.d.ts +2 -0
- package/dist/{basemap-QT4ua-dL.js → basemap-CtDse0mW.js} +1514 -1462
- package/dist/basemap.d.ts +41 -1
- package/dist/cartograph.js +362 -321
- package/dist/cartograph.standalone.js +1995 -1914
- package/dist/{cityjson-k-z1r6c0.js → cityjson-DMc_dwu1.js} +1 -1
- package/dist/{crs-BzE_KP4M.js → crs-D5FyQfEu.js} +74 -7
- package/dist/{crs-ChglCB3O.js → crs-ZdDBJ2EY.js} +39 -36
- package/dist/data-layer.d.ts +36 -3
- package/dist/elements/om-map.d.ts +2 -1
- package/dist/geoparquet-BTHYX1ET.js +30 -0
- package/dist/geoparquet.d.ts +6 -7
- package/dist/{globe-view-BSGTUqWc.js → globe-view-KrKNOmVs.js} +11 -11
- package/dist/hillshade-CijRdYyU.js +209 -0
- package/dist/html-data.d.ts +1 -1
- package/dist/{ifc-DXwePQRv.js → ifc-sisRo7I7.js} +1 -1
- package/dist/{index-Bxue4Psc.js → index-21KGElDr.js} +9 -9
- package/dist/{index-DjYxw-8H.js → index-A45DtXly.js} +18 -18
- package/dist/{index-Dwc4s3mc.js → index-BPa2CC8T.js} +20 -20
- package/dist/{index-DudIuhJa.js → index-B_Vhebf7.js} +1 -1
- package/dist/{index-DBt_2x-w.js → index-Bfocr1_A.js} +106 -106
- package/dist/{index-CevWTqBO.js → index-DMc81n9B.js} +14362 -13782
- package/dist/{index-D1ZjhP2H.js → index-DS6VUGi6.js} +11 -11
- package/dist/{index-BO7MtTkn.js → index-DoGY-Vgi.js} +3 -3
- package/dist/{index-Bzypgr1v.js → index-eHYe06mM.js} +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/ir.d.ts +6 -0
- package/dist/layer-registry.d.ts +21 -0
- package/dist/layers/warped-bitmap-layer.d.ts +27 -0
- package/dist/{lerc-DQuf93SN.js → lerc-DjrPALEj.js} +1 -1
- package/dist/onlymap.standalone.js +53019 -52455
- package/dist/onlymapjs.js +86 -84
- package/dist/parse-manifest.d.ts +12 -9
- package/dist/{post-process-effect-B3j_nBzy.js → post-process-effect-Be1qa2DD.js} +5 -5
- package/dist/programmatic.d.ts +12 -0
- package/dist/projection.d.ts +44 -1
- package/dist/{raster-pipeline-CusoihQ3.js → raster-pipeline-DspBYxwc.js} +1 -1
- package/dist/{raster-CvAJ-h_g.js → raster-zC3qXBrs.js} +3 -3
- package/dist/react/om-layer.d.ts +4 -0
- package/dist/react/om-map.d.ts +2 -0
- package/dist/react.js +225 -218
- package/dist/runtime-core.d.ts +24 -0
- package/dist/source-crs.d.ts +99 -0
- package/dist/{text-on-path-D9u5SYCo.js → text-on-path-D0_URrD2.js} +1 -1
- package/dist/{zarr-DWb_nikR.js → zarr-DopOhzfY.js} +2 -2
- package/docs/cartography.md +106 -1
- package/llms.txt +2 -1
- package/onlymapjs.attributes.json +2 -0
- package/onlymapjs.html-data.json +26 -4
- package/package.json +1 -1
- package/skills/onlymapjs/SKILL.md +4 -2
- package/skills/onlymapjs/references/syntax.md +16 -1
- package/dist/geoparquet-hOsdfZJa.js +0 -35
- package/dist/hillshade-D2Ps3Nim.js +0 -298
|
@@ -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-CevWTqBO.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-CevWTqBO.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
|
-
};
|