@nika-js/onlymap 0.9.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/README.md +25 -2
- package/dist/{LercDecode.es-BMcxSLhD.js → LercDecode.es-IEPCRZOv.js} +1 -1
- package/dist/{basemap-m98j2wxG.js → basemap-DL0mk9Bf.js} +1 -1
- package/dist/dem-decode.d.ts +58 -0
- package/dist/elements/om-map.d.ts +2 -0
- package/dist/{geoparquet-XOwOmChh.js → geoparquet-DJxZA0if.js} +1 -1
- package/dist/hillshade-DR3TxO1a.js +186 -0
- package/dist/hillshade-apron-Bem3DWyJ.js +40 -0
- package/dist/hillshade-apron.d.ts +54 -0
- package/dist/hillshade-shader-n_zManfZ.js +160 -0
- package/dist/hillshade-shader.d.ts +152 -0
- package/dist/hillshade.d.ts +133 -0
- package/dist/html-data.d.ts +1 -1
- package/dist/{index-HZWdgtm4.js → index-BjcPjICh.js} +59 -59
- package/dist/{index-DzOvV-O7.js → index-CvuDsvnk.js} +22 -22
- package/dist/{index-CfPbQUqO.js → index-DO_w0tqR.js} +86 -83
- package/dist/{index-DDNElBTs.js → index-DdTZSuAb.js} +106 -106
- package/dist/{index-BSAY6CWm.js → index-oY3XHIux.js} +9843 -9623
- package/dist/{index-BMbpftvm.js → index-vLXZuog4.js} +1 -1
- package/dist/lerc-Bph62dCb.js +22 -0
- package/dist/onlymap.standalone.js +21279 -20558
- package/dist/onlymapjs.js +37 -37
- package/dist/{raster-Dg5p_99H.js → raster-D-eTzCE3.js} +609 -499
- package/dist/raster-hillshade.d.ts +119 -0
- package/dist/{raster-pipeline-DhjkqDYd.js → raster-pipeline-BlOnMPJe.js} +510 -484
- package/dist/raster-pipeline.d.ts +10 -0
- package/dist/raster.d.ts +5 -0
- package/dist/terrain-heightfield.d.ts +0 -16
- package/dist/terrain-sample.d.ts +0 -13
- package/dist/version.d.ts +1 -1
- package/dist/volumetrics.d.ts +7 -0
- package/dist/{zarr-D3CzK1Zm.js → zarr-BGDoEtFb.js} +2 -2
- package/docs/cartograph.md +2 -2
- package/docs/design/hillshade.md +290 -0
- package/docs/effects.md +11 -0
- package/docs/hillshade.md +203 -0
- package/llms.txt +2 -1
- package/onlymapjs.attributes.json +27 -2
- package/onlymapjs.html-data.json +44 -6
- package/package.json +13 -9
- package/skills/onlymapjs/SKILL.md +3 -2
- package/skills/onlymapjs/references/syntax.md +11 -3
- package/dist/lerc-qK-nhCaB.js +0 -30
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The hillshade GPU module and its arithmetic — shared by BOTH entry points.
|
|
3
|
+
*
|
|
4
|
+
* `HillshadeLayer` (tiled DEM, Web Mercator) and `shading="hillshade"` on a
|
|
5
|
+
* raster source (the author's own DEM, in its own CRS) run THIS module, with
|
|
6
|
+
* the same uniforms. They do not produce identical pixels over the same
|
|
7
|
+
* ground and should not be asked to: the tile path is integer-encoded height
|
|
8
|
+
* in Web Mercator at a tile zoom, the raster path is float bands in the
|
|
9
|
+
* source CRS at the source resolution, so pixel ground size, reprojection and
|
|
10
|
+
* nodata all differ before the shader runs. What is shared is the ARITHMETIC,
|
|
11
|
+
* which is the part that could silently drift.
|
|
12
|
+
*
|
|
13
|
+
* WHY THIS IS NOT IN `raster-pipeline.ts`. That pipeline's modules inject at
|
|
14
|
+
* `DECKGL_FILTER_COLOR`, which is POINTWISE — a module there is handed
|
|
15
|
+
* `color`, not the means to sample its neighbours. Hillshade is the first
|
|
16
|
+
* neighbourhood operation anyone has wanted, and a neighbourhood operation
|
|
17
|
+
* needs its own sampler and texel size. Declaring the sampler here (via
|
|
18
|
+
* `fs:#decl`, exactly as upstream's `CompositeBands` declares `band0`–
|
|
19
|
+
* `band3`) also frees the module from any host layer's declaration order —
|
|
20
|
+
* which is not a nicety but the only thing that compiles: a module's
|
|
21
|
+
* `DECKGL_FILTER_COLOR` injection becomes a function emitted ABOVE the host
|
|
22
|
+
* layer's own source, so reaching for BitmapLayer's `bitmapTexture` there
|
|
23
|
+
* gives "undeclared identifier" on every tap.
|
|
24
|
+
*/
|
|
25
|
+
/** Equatorial circumference (m) — the Web Mercator scale numerator. */
|
|
26
|
+
export declare const EARTH_CIRCUMFERENCE = 40075016.686;
|
|
27
|
+
/** Metres per degree of latitude (mean). Latitude degrees barely vary; longitude degrees do, which is the whole point of `latMode`. */
|
|
28
|
+
export declare const METRES_PER_DEGREE_LAT = 110574;
|
|
29
|
+
/** Metres per degree of longitude AT THE EQUATOR — scaled by cos(latitude) per fragment. */
|
|
30
|
+
export declare const METRES_PER_DEGREE_LNG = 111320;
|
|
31
|
+
export declare const DEG: number;
|
|
32
|
+
/**
|
|
33
|
+
* How ground scale varies with latitude across one tile.
|
|
34
|
+
*
|
|
35
|
+
* This is the one place the two entry points genuinely differ, and getting it
|
|
36
|
+
* wrong does not look like a bug — it looks like SHEARED terrain, with every
|
|
37
|
+
* shadow falling at a consistently wrong angle.
|
|
38
|
+
*
|
|
39
|
+
* - `none` — a projected CRS whose units are already linear ground distance
|
|
40
|
+
* (UTM metres, state-plane feet). The scale is constant across the tile.
|
|
41
|
+
* - `mercator` — Web Mercator. Conformal, so ONE scale serves both axes, and
|
|
42
|
+
* the falloff is exact via cos φ = 1 / cosh(y) with y the Mercator
|
|
43
|
+
* ordinate. No inverse projection in the shader.
|
|
44
|
+
* - `geographic` — a lng/lat CRS (EPSG:4326). ANISOTROPIC: a degree of
|
|
45
|
+
* latitude is ~constant while a degree of longitude shrinks with cos φ, so
|
|
46
|
+
* only the X axis scales. At 36°N that is a 1.23x difference between the
|
|
47
|
+
* axes — ignore it and east-west slopes come out ~23% too gentle.
|
|
48
|
+
*/
|
|
49
|
+
export type LatitudeMode = "none" | "mercator" | "geographic";
|
|
50
|
+
/**
|
|
51
|
+
* Parses `sun-azimuth` / `sun-weight`: one to four numbers, space- or
|
|
52
|
+
* comma-separated.
|
|
53
|
+
*
|
|
54
|
+
* `multi-directional` is deliberately NOT a boolean anywhere in this feature.
|
|
55
|
+
* A preset must be expressible in the tier below it (the rule `presets.ts`
|
|
56
|
+
* states for `<om-effect>`), and a boolean that blended azimuths the author
|
|
57
|
+
* could not otherwise name would be capability reachable only from the
|
|
58
|
+
* shorthand. Swiss-style relief wants the azimuths CHOSEN for the terrain,
|
|
59
|
+
* which is a tuning job, not a toggle.
|
|
60
|
+
*/
|
|
61
|
+
export declare function parseLights(azimuth: string | number | null | undefined, weight: string | number | null | undefined, label?: string): {
|
|
62
|
+
azimuths: number[];
|
|
63
|
+
weights: number[];
|
|
64
|
+
};
|
|
65
|
+
/** The luma shader module. Identical object for both entry points — only the uniforms differ. */
|
|
66
|
+
export declare const hillshadeModule: {
|
|
67
|
+
name: string;
|
|
68
|
+
fs: string;
|
|
69
|
+
inject: {
|
|
70
|
+
"fs:#decl": string;
|
|
71
|
+
"fs:DECKGL_FILTER_COLOR": string;
|
|
72
|
+
};
|
|
73
|
+
uniformTypes: {
|
|
74
|
+
azimuths: string;
|
|
75
|
+
weights: string;
|
|
76
|
+
interiorOffset: string;
|
|
77
|
+
interiorScale: string;
|
|
78
|
+
texel: string;
|
|
79
|
+
metresPerTexel: string;
|
|
80
|
+
latBounds: string;
|
|
81
|
+
latMode: string;
|
|
82
|
+
sunElevation: string;
|
|
83
|
+
zFactor: string;
|
|
84
|
+
composite: string;
|
|
85
|
+
};
|
|
86
|
+
getUniforms: (props: Record<string, unknown>) => Record<string, unknown>;
|
|
87
|
+
};
|
|
88
|
+
export interface HillshadeUniformValues {
|
|
89
|
+
azimuths: [number, number, number, number];
|
|
90
|
+
weights: [number, number, number, number];
|
|
91
|
+
interiorOffset: [number, number];
|
|
92
|
+
interiorScale: [number, number];
|
|
93
|
+
texel: [number, number];
|
|
94
|
+
metresPerTexel: [number, number];
|
|
95
|
+
latBounds: [number, number];
|
|
96
|
+
latMode: number;
|
|
97
|
+
sunElevation: number;
|
|
98
|
+
zFactor: number;
|
|
99
|
+
composite: number;
|
|
100
|
+
}
|
|
101
|
+
/** Mercator ordinate (radians) of a latitude, clamped to the projection's own limit. */
|
|
102
|
+
export declare function mercatorY(lat: number): number;
|
|
103
|
+
/**
|
|
104
|
+
* Ground scale for one Web Mercator tile, stated AT THE EQUATOR — the shader
|
|
105
|
+
* applies the cos φ falloff per fragment, which is why this number is
|
|
106
|
+
* deliberately latitude-free.
|
|
107
|
+
*/
|
|
108
|
+
export declare function mercatorTileScale(zoom: number, width: number, height: number): {
|
|
109
|
+
metresPerTexel: [number, number];
|
|
110
|
+
latMode: LatitudeMode;
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* Ground scale for one raster tile from a source with a known pixel size.
|
|
114
|
+
*
|
|
115
|
+
* `unitsPerPixel` is in the CRS's own units — degrees for a geographic CRS,
|
|
116
|
+
* metres or feet for a projected one. A geographic source keeps its X scale
|
|
117
|
+
* stated at the equator (the shader scales it by cos φ); everything else is
|
|
118
|
+
* already linear and converts once, here.
|
|
119
|
+
*/
|
|
120
|
+
export declare function rasterTileScale(opts: {
|
|
121
|
+
unitsPerPixelX: number;
|
|
122
|
+
unitsPerPixelY: number;
|
|
123
|
+
/** Pixels of the SOURCE covered by this tile, per axis. */
|
|
124
|
+
tileWidth: number;
|
|
125
|
+
tileHeight: number;
|
|
126
|
+
crsUnits: "degree" | "metre" | "foot";
|
|
127
|
+
}): {
|
|
128
|
+
metresPerTexel: [number, number];
|
|
129
|
+
latMode: LatitudeMode;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* Every uniform for one tile. Pure, so the arithmetic that decides what the
|
|
133
|
+
* relief MEANS is unit-testable without a GPU.
|
|
134
|
+
*
|
|
135
|
+
* `north`/`south` are the tile's latitude bounds in degrees, and are read
|
|
136
|
+
* only when `latMode` needs them — a projected source may pass anything.
|
|
137
|
+
*/
|
|
138
|
+
export declare function hillshadeUniformsForTile(opts: {
|
|
139
|
+
/** INTERIOR size of the padded heightfield; the apron is one pixel outside it. */
|
|
140
|
+
width: number;
|
|
141
|
+
height: number;
|
|
142
|
+
metresPerTexel: [number, number];
|
|
143
|
+
latMode: LatitudeMode;
|
|
144
|
+
north: number;
|
|
145
|
+
south: number;
|
|
146
|
+
azimuths: number[];
|
|
147
|
+
weights: number[];
|
|
148
|
+
sunElevation: number;
|
|
149
|
+
zFactor: number;
|
|
150
|
+
/** true multiplies the shade into the existing colour; false replaces it. */
|
|
151
|
+
composite: boolean;
|
|
152
|
+
}): HillshadeUniformValues;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hillshade / shaded relief — the lazy chunk (docs/design/hillshade.md).
|
|
3
|
+
*
|
|
4
|
+
* WHAT THIS IS, AND IS NOT. Cartographic shaded relief is RENDERED TEXTURE:
|
|
5
|
+
* pixels, never numbers. Nothing here is queryable, classified or reported,
|
|
6
|
+
* which is the line issue #13 drew when it put "raster analysis
|
|
7
|
+
* (hillshade/slope)" out of scope — the boundary there is QUERYABILITY, not
|
|
8
|
+
* the arithmetic. This ships no analytic product.
|
|
9
|
+
*
|
|
10
|
+
* It is a LAYER, not a mode of `terrain=`. `terrain=` means a 3D surface: it
|
|
11
|
+
* replaces the basemap, changes what the camera means, and is meaningless at
|
|
12
|
+
* pitch 0. Relief on a print sheet has to compose underneath the data layers
|
|
13
|
+
* like any other layer — and, decisively, a layer draws inside deck's own
|
|
14
|
+
* framebuffer, so it lands in `snapshot()` and UNDER `<om-effect>`. Relief a
|
|
15
|
+
* print finish could not reach would be worth very little.
|
|
16
|
+
*
|
|
17
|
+
* THE SEAM IS THE WHOLE DESIGN PROBLEM. A hillshade is a derivative, so every
|
|
18
|
+
* fragment needs its neighbours — and at a tile's edge the neighbours live in
|
|
19
|
+
* a different tile. Sampling with clamp-to-edge instead makes the derivative
|
|
20
|
+
* collapse to zero along every border, drawing a pale grid over the world:
|
|
21
|
+
* the single most recognisable way a hand-rolled hillshade looks broken.
|
|
22
|
+
* Rather than bind nine textures per draw, each tile is decoded on the CPU
|
|
23
|
+
* (`dem-decode.ts`, which exists because these bytes are heights and must not
|
|
24
|
+
* be colour-managed) into a heightfield with a ONE-PIXEL APRON copied from
|
|
25
|
+
* its eight neighbours. The shader then samples one texture with no edge
|
|
26
|
+
* cases at all, and the neighbour fetches are nearly free because a
|
|
27
|
+
* neighbour is almost always a tile the map is drawing anyway — see
|
|
28
|
+
* `tileCache`.
|
|
29
|
+
*/
|
|
30
|
+
import { CompositeLayer, type Layer } from "@deck.gl/core";
|
|
31
|
+
import { type ElevationDecoder } from "./terrain";
|
|
32
|
+
import { type PaddedHeights } from "./hillshade-apron";
|
|
33
|
+
/** Drops every cached decode — exported for tests and for a page tearing a map down. */
|
|
34
|
+
export declare function clearHillshadeTileCache(): void;
|
|
35
|
+
/**
|
|
36
|
+
* Builds one tile's padded heightfield, fetching the eight neighbours for the
|
|
37
|
+
* apron. x wraps around the antimeridian; y does not, because the poles are
|
|
38
|
+
* not a seam. The composition itself — including what happens when a
|
|
39
|
+
* neighbour genuinely does not exist — lives in `hillshade-apron.ts`, shared
|
|
40
|
+
* with the raster entry point.
|
|
41
|
+
*/
|
|
42
|
+
export declare function buildPaddedHeights(template: string, decoder: ElevationDecoder, index: {
|
|
43
|
+
x: number;
|
|
44
|
+
y: number;
|
|
45
|
+
z: number;
|
|
46
|
+
}): Promise<PaddedHeights | null>;
|
|
47
|
+
export interface OmHillshadeLayerProps {
|
|
48
|
+
/** A `registerTerrain` preset name, or a raw `{z}/{x}/{y}` DEM URL template. */
|
|
49
|
+
src: string;
|
|
50
|
+
/** Decoder name or explicit scalers — required alongside a RAW url, implied by a preset. */
|
|
51
|
+
decoder?: string | ElevationDecoder | null;
|
|
52
|
+
sunAzimuth?: string | number | null;
|
|
53
|
+
sunWeight?: string | number | null;
|
|
54
|
+
sunElevation?: number | null;
|
|
55
|
+
zFactor?: number | null;
|
|
56
|
+
blend?: string | null;
|
|
57
|
+
maxZoom?: number | null;
|
|
58
|
+
zoomOffset?: number | null;
|
|
59
|
+
opacity?: number;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* `src` resolution mirrors `parseTerrainAttrs` exactly: a registered preset
|
|
63
|
+
* name, or a raw `{z}/{x}/{y}` template plus a `decoder`. `src` is REQUIRED
|
|
64
|
+
* even for the keyless global default, which is a deliberate departure from
|
|
65
|
+
* "the bare element just works": every other keyless default in this library
|
|
66
|
+
* is still NAMED by the author (`basemap="positron"`, `terrain="terrarium"`).
|
|
67
|
+
* Keyless-first means no key and no account, not no attribute — and an
|
|
68
|
+
* element that reaches a public tile host with nothing written on it is a
|
|
69
|
+
* network call the markup does not show.
|
|
70
|
+
*/
|
|
71
|
+
export declare function resolveHillshadeSource(props: OmHillshadeLayerProps): {
|
|
72
|
+
template: string;
|
|
73
|
+
decoder: ElevationDecoder;
|
|
74
|
+
maxZoom: number;
|
|
75
|
+
} | null;
|
|
76
|
+
/**
|
|
77
|
+
* How much sharper the DEM should be than the screen asks for.
|
|
78
|
+
*
|
|
79
|
+
* A 300 dpi plate rendered from screen-resolution relief is mush, and this is
|
|
80
|
+
* the same class of bug the millimetre knobs solved for `<om-effect>`: a
|
|
81
|
+
* capture changes the pixel budget, so anything keyed to pixels has to be
|
|
82
|
+
* re-pointed. `useDevicePixels` is what `withCapturePixelRatio` moves, so the
|
|
83
|
+
* ratio of the canvas's device ratio to the DISPLAY's is exactly the capture
|
|
84
|
+
* boost — 1 while nobody is exporting, whatever the display's own density.
|
|
85
|
+
*/
|
|
86
|
+
export declare function captureZoomOffset(deviceRatio: number, displayRatio: number): number;
|
|
87
|
+
export declare class OmHillshadeLayer extends CompositeLayer<OmHillshadeLayerProps> {
|
|
88
|
+
static layerName: string;
|
|
89
|
+
static defaultProps: {
|
|
90
|
+
src: {
|
|
91
|
+
type: string;
|
|
92
|
+
value: string;
|
|
93
|
+
};
|
|
94
|
+
decoder: {
|
|
95
|
+
type: string;
|
|
96
|
+
value: null;
|
|
97
|
+
optional: boolean;
|
|
98
|
+
};
|
|
99
|
+
sunAzimuth: {
|
|
100
|
+
type: string;
|
|
101
|
+
value: string;
|
|
102
|
+
};
|
|
103
|
+
sunWeight: {
|
|
104
|
+
type: string;
|
|
105
|
+
value: null;
|
|
106
|
+
optional: boolean;
|
|
107
|
+
};
|
|
108
|
+
sunElevation: {
|
|
109
|
+
type: string;
|
|
110
|
+
value: number;
|
|
111
|
+
};
|
|
112
|
+
zFactor: {
|
|
113
|
+
type: string;
|
|
114
|
+
value: number;
|
|
115
|
+
};
|
|
116
|
+
blend: {
|
|
117
|
+
type: string;
|
|
118
|
+
value: string;
|
|
119
|
+
};
|
|
120
|
+
maxZoom: {
|
|
121
|
+
type: string;
|
|
122
|
+
value: null;
|
|
123
|
+
optional: boolean;
|
|
124
|
+
};
|
|
125
|
+
zoomOffset: {
|
|
126
|
+
type: string;
|
|
127
|
+
value: number;
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
renderLayers(): Layer | null;
|
|
131
|
+
initializeState(): void;
|
|
132
|
+
finalizeState(): void;
|
|
133
|
+
}
|
package/dist/html-data.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ interface TagData {
|
|
|
17
17
|
/** Hand-authored action list — validated against hasAction() in html-data.test.ts. */
|
|
18
18
|
export declare const BUILTIN_ACTIONS: readonly ["toggle-layer", "set-pickable", "zoom-in", "zoom-out", "filter-layer", "highlight-feature", "fade", "pulse", "populate", "trace", "story-play", "story-pause", "story-seek", "fly-to", "zoom-to-feature", "show-overlay", "hide-overlay", "show-tooltip", "hide-tooltip", "draw-mode", "draw-commit", "draw-cancel", "draw-delete", "draw-clear", "draw-config", "draw-save", "export-region-3d", "measure-mode", "measure-clear", "measure-units", "set-basemap", "set-effect", "set-lighting", "set-terrain", "set-clip-box", "clip-box-edit", "set-widgets-visible", "undo", "redo", "warm-tiles"];
|
|
19
19
|
/** Hand-authored widget types — validated against the widget registry in html-data.test.ts. */
|
|
20
|
-
export declare const BUILTIN_WIDGETS: readonly ["legend", "layer-switcher", "zoom-controls", "scale-bar", "attribution", "filter", "vega-lite", "dynamic-chart", "player", "draw", "measure", "basemap-switcher", "lighting", "clip-box", "undo-redo", "widgets-toggle", "time-slider", "ifc-browser", "ifc-legend", "feature-inspector", "ifc-inspector", "ifc-loader", "ifc-clash"];
|
|
20
|
+
export declare const BUILTIN_WIDGETS: readonly ["legend", "layer-switcher", "zoom-controls", "scale-bar", "attribution", "filter", "vega-lite", "dynamic-chart", "player", "draw", "measure", "basemap-switcher", "lighting", "effects", "clip-box", "undo-redo", "widgets-toggle", "time-slider", "ifc-browser", "ifc-legend", "feature-inspector", "ifc-inspector", "ifc-loader", "ifc-clash"];
|
|
21
21
|
export declare function buildHtmlCustomData(): {
|
|
22
22
|
version: number;
|
|
23
23
|
tags: TagData[];
|