isard 0.4.0 → 0.5.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 +60 -0
- package/README.md +6 -2
- package/dist/decoder.worker.js +4 -4
- package/dist/decoder.worker.js.map +7 -6
- package/dist/decoders.d.ts +3 -2
- package/dist/decoders.js +28 -5
- package/dist/decoders.js.map +1 -1
- package/dist/engine-loader.d.ts +6 -3
- package/dist/engine-loader.js +10 -3
- package/dist/engine-loader.js.map +1 -1
- package/dist/formats.d.ts +11 -0
- package/dist/formats.js +12 -0
- package/dist/formats.js.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/isard_bg.wasm +0 -0
- package/dist/isard_core_bg.wasm +0 -0
- package/dist/isard_points_bg.wasm +0 -0
- package/dist/layers.js +2 -2
- package/dist/layers.js.map +1 -1
- package/dist/loader.d.ts +9 -3
- package/dist/loader.js +22 -3
- package/dist/loader.js.map +1 -1
- package/dist/map.d.ts +8 -0
- package/dist/map.js +10 -2
- package/dist/map.js.map +1 -1
- package/dist/pointclouds.d.ts +98 -0
- package/dist/pointclouds.js +232 -0
- package/dist/pointclouds.js.map +1 -0
- package/dist/projections.d.ts +13 -0
- package/dist/projections.js +13 -0
- package/dist/projections.js.map +1 -0
- package/dist/protocol.d.ts +17 -0
- package/dist/protocol.js.map +1 -1
- package/dist/types.d.ts +8 -2
- package/dist/types.js.map +1 -1
- package/dist/wasm/isard.d.ts +124 -12
- package/dist/wasm/isard.js +127 -8
- package/dist/wasm/isard_core.d.ts +0 -3
- package/dist/wasm/isard_core.js +0 -1
- package/dist/wasm/isard_points.d.ts +43 -0
- package/dist/wasm/isard_points.js +212 -0
- package/package.json +17 -1
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Point clouds: a COPC file (Cloud Optimized Point Cloud: LAZ 1.4 with an octree, read by HTTP range requests, as the
|
|
3
|
+
* IGN distributes LiDAR HD) or a 3D Tiles point cloud (`.pnts`, glTF points), drawn by the engine with 3D Tiles. The
|
|
4
|
+
* COPC file's CRS comes from its WKT (built-in CRSs, or registered ones: `registerCrs`) or the `crs` option; altitudes
|
|
5
|
+
* in NGF-IGN69 (Lambert-93, the CC zones) are raised by the RAF20 geoid height onto the ellipsoid of the relief and
|
|
6
|
+
* the 3D Tiles.
|
|
7
|
+
*/
|
|
8
|
+
import { type CrsLike } from './crs.ts';
|
|
9
|
+
import { type Ramp } from './features.ts';
|
|
10
|
+
import { Layer } from './layers.ts';
|
|
11
|
+
import type { PointCloudCrs, PointCloudInfo, PointCloudStats, Tiles3dStats } from './wasm/isard.js';
|
|
12
|
+
/** What the points are colored by */
|
|
13
|
+
export type PointColor = 'rgb' | 'classification' | 'elevation' | 'intensity';
|
|
14
|
+
/** The look of a class of points */
|
|
15
|
+
export interface ClassStyle {
|
|
16
|
+
/** CSS color */
|
|
17
|
+
color?: string;
|
|
18
|
+
/** false hides the class */
|
|
19
|
+
visible?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface PointCloudStyle {
|
|
22
|
+
/** By RGB (files with colors), class (the ASPRS palette, `classifications`), altitude (`elevationRamp` over
|
|
23
|
+
* `elevationRange`) or intensity (grey over `intensityRange`). Default: RGB when the file has colors, else class */
|
|
24
|
+
colorBy?: PointColor;
|
|
25
|
+
/** CSS pixels: the size of the points, or the smallest with `sizeMode: 'adaptive'` (default 2) */
|
|
26
|
+
pointSize: number;
|
|
27
|
+
/** CSS pixels: the largest adaptive size (default 4) */
|
|
28
|
+
maxPointSize: number;
|
|
29
|
+
/** `'adaptive'` (default): the spacing of the points of the finest level drawn there, at their distance (the
|
|
30
|
+
* nearer, the larger, no gap); `'fixed'`: `pointSize` everywhere */
|
|
31
|
+
sizeMode: 'adaptive' | 'fixed';
|
|
32
|
+
/** `'circle'` (default) or `'square'` */
|
|
33
|
+
shape: 'circle' | 'square';
|
|
34
|
+
/** Eye-Dome Lighting: points shaded by the depth of their neighbours on screen, their relief read without normals
|
|
35
|
+
* nor colors (default false; `strength` 1, `radius` 1.4 CSS pixels) */
|
|
36
|
+
edl: boolean | {
|
|
37
|
+
strength?: number;
|
|
38
|
+
radius?: number;
|
|
39
|
+
};
|
|
40
|
+
/** Colors and visibility by class code, over the defaults (ASPRS, and IGN's LiDAR HD classes 64 to 67; the noise
|
|
41
|
+
* 7 and 18 and the artefacts 65 hidden): `{ 2: { color: '#a0522d' }, 66: { visible: false } }` */
|
|
42
|
+
classifications: Record<number, ClassStyle>;
|
|
43
|
+
/** Altitudes (metres, the file's vertical datum) mapped onto the ramp; default the file's lowest and highest */
|
|
44
|
+
elevationRange?: [min: number, max: number];
|
|
45
|
+
/** Colors from the lowest altitude (0) to the highest (1) */
|
|
46
|
+
elevationRamp: Ramp;
|
|
47
|
+
/** Intensities mapped from black to white; default the bulk of the first node's (2nd to 98th percentile) */
|
|
48
|
+
intensityRange?: [min: number, max: number];
|
|
49
|
+
/** CSS pixels: a node is refined while the spacing of its points covers more on screen (default 1.5; lower is finer
|
|
50
|
+
* and heavier). For 3D Tiles, their screen-space error (default 16) */
|
|
51
|
+
maxScreenSpaceError: number;
|
|
52
|
+
/** Points drawn at most, the nearest and the coarsest first (default 3 000 000) */
|
|
53
|
+
pointBudget: number;
|
|
54
|
+
}
|
|
55
|
+
export interface PointCloudOptions extends Partial<PointCloudStyle> {
|
|
56
|
+
/** A COPC file (`.copc.laz`) or a 3D Tiles `tileset.json` of points */
|
|
57
|
+
url: string;
|
|
58
|
+
/** Default: `'3dtiles'` for a `.json` URL, else `'copc'` */
|
|
59
|
+
format?: 'copc' | '3dtiles';
|
|
60
|
+
/** The CRS of a COPC file without a WKT, or whose CRS is not built in (`proj4('EPSG:2992')`) */
|
|
61
|
+
crs?: CrsLike;
|
|
62
|
+
/** Its altitudes are above the geoid (NGF-IGN69), raised by the RAF20 geoid height; default for Lambert-93 and the
|
|
63
|
+
* CC zones */
|
|
64
|
+
geoid?: boolean;
|
|
65
|
+
/** Metres of a unit of z; default the vertical unit of the WKT (a US survey foot…), else that of x and y */
|
|
66
|
+
verticalScale?: number;
|
|
67
|
+
/** Requests a second at most: 8 by default for the Géoplateforme (data.geopf.fr allows 10), no limit elsewhere */
|
|
68
|
+
requestsPerSecond?: number;
|
|
69
|
+
}
|
|
70
|
+
/** The default classes: ASPRS LAS 1.4, then IGN's LiDAR HD (64 permanent structures, 65 artefacts, 66 virtual points,
|
|
71
|
+
* 67 miscellaneous buildings) */
|
|
72
|
+
export declare const CLASSIFICATIONS: Readonly<Record<number, Readonly<Required<ClassStyle>>>>;
|
|
73
|
+
/** The default ramp of the altitudes, low to high */
|
|
74
|
+
export declare const ELEVATION_RAMP: Ramp;
|
|
75
|
+
/** The colors of the 256 classes (RGBA, alpha 0 hides one) */
|
|
76
|
+
export declare function classPalette(overrides?: Record<number, ClassStyle>): Uint8Array;
|
|
77
|
+
/** What a WKT says of a CRS: its EPSG code (projected first), the metres of a unit of z */
|
|
78
|
+
export declare function wktCrs(wkt: string): {
|
|
79
|
+
code: number | undefined;
|
|
80
|
+
verticalScale: number | undefined;
|
|
81
|
+
};
|
|
82
|
+
/** The CRS of a COPC file for the engine, from its WKT and the options */
|
|
83
|
+
export declare function pointCloudCrs(wkt: string | undefined, options: Pick<PointCloudOptions, 'crs' | 'geoid' | 'verticalScale'>): PointCloudCrs;
|
|
84
|
+
/** A point cloud (`GeoMap.addPointCloud`): COPC or 3D Tiles points; `pickFeature` gives a COPC point's attributes */
|
|
85
|
+
export declare class PointCloudLayer extends Layer {
|
|
86
|
+
readonly url: string;
|
|
87
|
+
readonly format: 'copc' | '3dtiles';
|
|
88
|
+
private style;
|
|
89
|
+
private readonly options;
|
|
90
|
+
/** Changes the style, the rest kept */
|
|
91
|
+
setStyle(style: Partial<PointCloudStyle>): void;
|
|
92
|
+
getStyle(): Readonly<PointCloudStyle>;
|
|
93
|
+
/** Loading counters; undefined once removed and while the engine with 3D Tiles loads */
|
|
94
|
+
stats(): PointCloudStats | Tiles3dStats | undefined;
|
|
95
|
+
/** What a COPC file says of itself (points, format, CRS, center, altitudes), once its head is read */
|
|
96
|
+
info(): PointCloudInfo | undefined;
|
|
97
|
+
private apply;
|
|
98
|
+
}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Point clouds: a COPC file (Cloud Optimized Point Cloud: LAZ 1.4 with an octree, read by HTTP range requests, as the
|
|
3
|
+
* IGN distributes LiDAR HD) or a 3D Tiles point cloud (`.pnts`, glTF points), drawn by the engine with 3D Tiles. The
|
|
4
|
+
* COPC file's CRS comes from its WKT (built-in CRSs, or registered ones: `registerCrs`) or the `crs` option; altitudes
|
|
5
|
+
* in NGF-IGN69 (Lambert-93, the CC zones) are raised by the RAF20 geoid height onto the ellipsoid of the relief and
|
|
6
|
+
* the 3D Tiles.
|
|
7
|
+
*/
|
|
8
|
+
import { epsgCode, getCrs } from "./crs.js";
|
|
9
|
+
import { parseColor, rampTexels } from "./features.js";
|
|
10
|
+
import { Layer } from "./layers.js";
|
|
11
|
+
/** The default classes: ASPRS LAS 1.4, then IGN's LiDAR HD (64 permanent structures, 65 artefacts, 66 virtual points,
|
|
12
|
+
* 67 miscellaneous buildings) */
|
|
13
|
+
export const CLASSIFICATIONS = {
|
|
14
|
+
0: { color: '#a6a6a6', visible: true },
|
|
15
|
+
1: { color: '#c8c8c8', visible: true },
|
|
16
|
+
2: { color: '#b08458', visible: true },
|
|
17
|
+
3: { color: '#9ccc65', visible: true },
|
|
18
|
+
4: { color: '#5aa83f', visible: true },
|
|
19
|
+
5: { color: '#2e7d32', visible: true },
|
|
20
|
+
6: { color: '#e57352', visible: true },
|
|
21
|
+
7: { color: '#ff00ff', visible: false },
|
|
22
|
+
8: { color: '#ff0000', visible: true },
|
|
23
|
+
9: { color: '#3d8fd6', visible: true },
|
|
24
|
+
10: { color: '#8e6bb0', visible: true },
|
|
25
|
+
11: { color: '#7a7a7a', visible: true },
|
|
26
|
+
12: { color: '#ffe680', visible: true },
|
|
27
|
+
13: { color: '#ffff00', visible: true },
|
|
28
|
+
14: { color: '#ffc800', visible: true },
|
|
29
|
+
15: { color: '#c89600', visible: true },
|
|
30
|
+
16: { color: '#ff9632', visible: true },
|
|
31
|
+
17: { color: '#b48cc8', visible: true },
|
|
32
|
+
18: { color: '#ff00ff', visible: false },
|
|
33
|
+
64: { color: '#8c6e5a', visible: true },
|
|
34
|
+
65: { color: '#ff00ff', visible: false },
|
|
35
|
+
66: { color: '#5a6ec8', visible: true },
|
|
36
|
+
67: { color: '#e6966e', visible: true },
|
|
37
|
+
};
|
|
38
|
+
/** The default ramp of the altitudes, low to high */
|
|
39
|
+
export const ELEVATION_RAMP = [
|
|
40
|
+
[0, '#2b83ba'],
|
|
41
|
+
[0.25, '#abdda4'],
|
|
42
|
+
[0.5, '#ffffbf'],
|
|
43
|
+
[0.75, '#fdae61'],
|
|
44
|
+
[1, '#d7191c'],
|
|
45
|
+
];
|
|
46
|
+
/** The colors of the 256 classes (RGBA, alpha 0 hides one) */
|
|
47
|
+
export function classPalette(overrides = {}) {
|
|
48
|
+
const out = new Uint8Array(256 * 4);
|
|
49
|
+
for (let code = 0; code < 256; code += 1) {
|
|
50
|
+
const base = CLASSIFICATIONS[code] ?? { color: '#c8c8c8', visible: true };
|
|
51
|
+
const own = overrides[code] ?? {};
|
|
52
|
+
const [r = 0, g = 0, b = 0] = parseColor(own.color ?? base.color);
|
|
53
|
+
out.set([r * 255, g * 255, b * 255, (own.visible ?? base.visible) ? 255 : 0], code * 4);
|
|
54
|
+
}
|
|
55
|
+
return out;
|
|
56
|
+
}
|
|
57
|
+
/** The section of a WKT opening with one of `keywords` (`PROJCS[…]`), from its keyword to its closing bracket */
|
|
58
|
+
function section(wkt, keywords) {
|
|
59
|
+
for (const keyword of keywords) {
|
|
60
|
+
const start = wkt.indexOf(`${keyword}[`);
|
|
61
|
+
if (start < 0)
|
|
62
|
+
continue;
|
|
63
|
+
let depth = 0;
|
|
64
|
+
for (let i = start + keyword.length; i < wkt.length; i += 1) {
|
|
65
|
+
if (wkt[i] === '[')
|
|
66
|
+
depth += 1;
|
|
67
|
+
else if (wkt[i] === ']' && --depth === 0)
|
|
68
|
+
return wkt.slice(start, i + 1);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
/** The EPSG code a WKT section ends with (its own `AUTHORITY`, or `ID` in WKT2), the last of its nested ones */
|
|
74
|
+
function lastCode(part) {
|
|
75
|
+
const codes = [...part.matchAll(/(?:AUTHORITY|ID)\[\s*"EPSG"\s*,\s*"?(\d+)"?\s*\]/g)];
|
|
76
|
+
const last = codes.at(-1)?.[1];
|
|
77
|
+
return last === undefined ? undefined : Number(last);
|
|
78
|
+
}
|
|
79
|
+
/** The factor of the last `UNIT` (`LENGTHUNIT` in WKT2) of a WKT section */
|
|
80
|
+
function lastUnit(part) {
|
|
81
|
+
const units = [...(part ?? '').matchAll(/(?:LENGTH)?UNIT\[\s*"[^"]*"\s*,\s*([\d.eE+-]+)/g)];
|
|
82
|
+
const factor = Number(units.at(-1)?.[1]);
|
|
83
|
+
return Number.isFinite(factor) && factor > 0 ? factor : undefined;
|
|
84
|
+
}
|
|
85
|
+
/** What a WKT says of a CRS: its EPSG code (projected first), the metres of a unit of z */
|
|
86
|
+
export function wktCrs(wkt) {
|
|
87
|
+
const projected = section(wkt, ['PROJCS', 'PROJCRS']);
|
|
88
|
+
const geographic = section(wkt, ['GEOGCS', 'GEOGCRS']);
|
|
89
|
+
let code = lastCode(projected ?? geographic ?? '');
|
|
90
|
+
if (code === undefined && /Lambert[- ]93/i.test(wkt))
|
|
91
|
+
code = 2154;
|
|
92
|
+
const vertical = section(wkt, ['VERT_CS', 'VERTCRS']);
|
|
93
|
+
const verticalScale = lastUnit(vertical ?? projected);
|
|
94
|
+
return { code, verticalScale };
|
|
95
|
+
}
|
|
96
|
+
/** Whether the altitudes of a CRS are NGF-IGN69 by default: Lambert-93 and the CC zones */
|
|
97
|
+
const FRENCH = (code) => code === 2154 || (code !== undefined && code >= 3942 && code <= 3950);
|
|
98
|
+
/** The CRS of a COPC file for the engine, from its WKT and the options */
|
|
99
|
+
export function pointCloudCrs(wkt, options) {
|
|
100
|
+
const parsed = wkt ? wktCrs(wkt) : { code: undefined, verticalScale: undefined };
|
|
101
|
+
let crs;
|
|
102
|
+
let code = parsed.code;
|
|
103
|
+
if (options.crs !== undefined) {
|
|
104
|
+
crs = getCrs(options.crs);
|
|
105
|
+
if (typeof options.crs === 'string')
|
|
106
|
+
code = epsgCode(options.crs) ?? code;
|
|
107
|
+
}
|
|
108
|
+
else if (code !== undefined) {
|
|
109
|
+
try {
|
|
110
|
+
crs = getCrs(`EPSG:${code}`);
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
throw new Error(`the CRS of the file, EPSG:${code}, is not built in: give it as \`crs\` (proj4('EPSG:${code}'))`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
throw new Error('the file names no CRS: give it as `crs`');
|
|
118
|
+
}
|
|
119
|
+
const inverse = (xy) => {
|
|
120
|
+
const out = new Float64Array(xy.length);
|
|
121
|
+
for (let i = 0; i + 1 < xy.length; i += 2) {
|
|
122
|
+
const [lon = Number.NaN, lat = Number.NaN] = crs.inverse([xy[i], xy[i + 1]]);
|
|
123
|
+
out[i] = lon;
|
|
124
|
+
out[i + 1] = lat;
|
|
125
|
+
}
|
|
126
|
+
return out;
|
|
127
|
+
};
|
|
128
|
+
return {
|
|
129
|
+
inverse,
|
|
130
|
+
geoid: options.geoid ?? (FRENCH(code) || /IGN69|NGF/.test(wkt ?? '')),
|
|
131
|
+
verticalScale: options.verticalScale ?? parsed.verticalScale ?? 1,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
/** The style numbers of the engine (`setPointCloudStyle`) */
|
|
135
|
+
function styleNumbers(s, rate) {
|
|
136
|
+
const colors = ['rgb', 'classification', 'elevation', 'intensity'];
|
|
137
|
+
let edl;
|
|
138
|
+
if (s.edl)
|
|
139
|
+
edl = s.edl === true ? {} : s.edl;
|
|
140
|
+
const [emin = Number.NaN, emax = Number.NaN] = s.elevationRange ?? [];
|
|
141
|
+
const [imin = Number.NaN, imax = Number.NaN] = s.intensityRange ?? [];
|
|
142
|
+
return Float64Array.of(s.colorBy ? colors.indexOf(s.colorBy) : -1, s.pointSize, s.maxPointSize, s.sizeMode === 'fixed' ? 0 : 1, s.shape === 'square' ? 0 : 1, edl ? (edl.strength ?? 1) : 0, edl?.radius ?? 1.4, emin, emax, imin, imax, s.maxScreenSpaceError, s.pointBudget, rate);
|
|
143
|
+
}
|
|
144
|
+
/** A point cloud (`GeoMap.addPointCloud`): COPC or 3D Tiles points; `pickFeature` gives a COPC point's attributes */
|
|
145
|
+
export class PointCloudLayer extends Layer {
|
|
146
|
+
url;
|
|
147
|
+
format;
|
|
148
|
+
style;
|
|
149
|
+
options;
|
|
150
|
+
/** @internal */
|
|
151
|
+
constructor(map, options) {
|
|
152
|
+
super(map);
|
|
153
|
+
// Against the page: the decoding workers fetch it, and a relative URL would be theirs
|
|
154
|
+
const base = typeof document === 'undefined' ? undefined : document.baseURI;
|
|
155
|
+
this.url = base ? new URL(options.url, base).href : options.url;
|
|
156
|
+
this.format = options.format ?? (/\.json(?:[?#]|$)/i.test(options.url) ? '3dtiles' : 'copc');
|
|
157
|
+
this.options = options;
|
|
158
|
+
const tiles = this.format === '3dtiles';
|
|
159
|
+
this.style = {
|
|
160
|
+
...(options.colorBy ? { colorBy: options.colorBy } : {}),
|
|
161
|
+
pointSize: options.pointSize ?? 2,
|
|
162
|
+
maxPointSize: options.maxPointSize ?? 4,
|
|
163
|
+
sizeMode: options.sizeMode ?? 'adaptive',
|
|
164
|
+
shape: options.shape ?? 'circle',
|
|
165
|
+
edl: options.edl ?? false,
|
|
166
|
+
classifications: options.classifications ?? {},
|
|
167
|
+
...(options.elevationRange ? { elevationRange: options.elevationRange } : {}),
|
|
168
|
+
elevationRamp: options.elevationRamp ?? ELEVATION_RAMP,
|
|
169
|
+
...(options.intensityRange ? { intensityRange: options.intensityRange } : {}),
|
|
170
|
+
maxScreenSpaceError: options.maxScreenSpaceError ?? (tiles ? 16 : 1.5),
|
|
171
|
+
pointBudget: options.pointBudget ?? 3_000_000,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
/** @internal Drawn by the engine with 3D Tiles (the point cloud module loads with the first one) */
|
|
175
|
+
get needsFullEngine() {
|
|
176
|
+
return true;
|
|
177
|
+
}
|
|
178
|
+
/** Changes the style, the rest kept */
|
|
179
|
+
setStyle(style) {
|
|
180
|
+
this.style = { ...this.style, ...style };
|
|
181
|
+
// Kept for its creation while the engine with 3D Tiles loads
|
|
182
|
+
if (this.id < 0)
|
|
183
|
+
return;
|
|
184
|
+
this.apply(this.map.engine, this.id);
|
|
185
|
+
this.map.requestRender();
|
|
186
|
+
}
|
|
187
|
+
getStyle() {
|
|
188
|
+
return this.style;
|
|
189
|
+
}
|
|
190
|
+
/** Loading counters; undefined once removed and while the engine with 3D Tiles loads */
|
|
191
|
+
stats() {
|
|
192
|
+
if (this.id < 0)
|
|
193
|
+
return undefined;
|
|
194
|
+
return this.format === '3dtiles' ? this.map.engine.tiles3dStats(this.id) : this.map.engine.pointCloudStats(this.id);
|
|
195
|
+
}
|
|
196
|
+
/** What a COPC file says of itself (points, format, CRS, center, altitudes), once its head is read */
|
|
197
|
+
info() {
|
|
198
|
+
return this.id < 0 || this.format === '3dtiles' ? undefined : this.map.engine.pointCloudInfo(this.id);
|
|
199
|
+
}
|
|
200
|
+
/** @internal The point picked (`pickFeature`, 'hoverfeature'): a Point at its longitude, latitude and height, its
|
|
201
|
+
* attributes as properties */
|
|
202
|
+
featureAt(index) {
|
|
203
|
+
if (this.id < 0 || this.format === '3dtiles')
|
|
204
|
+
return undefined;
|
|
205
|
+
const point = this.map.engine.pointCloudPoint(this.id, index);
|
|
206
|
+
if (!point)
|
|
207
|
+
return undefined;
|
|
208
|
+
return {
|
|
209
|
+
type: 'Feature',
|
|
210
|
+
geometry: { type: 'Point', coordinates: [...point.lonLat, point.height] },
|
|
211
|
+
properties: point,
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
apply(engine, id) {
|
|
215
|
+
const s = this.style;
|
|
216
|
+
if (this.format === '3dtiles') {
|
|
217
|
+
engine.setTiles3dStyle(id, s.maxScreenSpaceError, 1, s.pointSize);
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
const rate = this.options.requestsPerSecond ?? (/^https?:\/\/data\.geopf\.fr\//.test(this.url) ? 8 : 0);
|
|
221
|
+
engine.setPointCloudStyle(id, styleNumbers(s, rate), classPalette(s.classifications), rampTexels(s.elevationRamp).rgba);
|
|
222
|
+
}
|
|
223
|
+
/** @internal */
|
|
224
|
+
create(engine) {
|
|
225
|
+
const id = this.format === '3dtiles'
|
|
226
|
+
? engine.addTiles3d(this.url, this.style.maxScreenSpaceError)
|
|
227
|
+
: engine.addPointCloud(this.url, (wkt) => pointCloudCrs(wkt, this.options));
|
|
228
|
+
this.apply(engine, id);
|
|
229
|
+
return id;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
//# sourceMappingURL=pointclouds.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pointclouds.js","sourceRoot":"","sources":["../src/pointclouds.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAA0B,QAAQ,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACpE,OAAO,EAAgB,UAAU,EAAa,UAAU,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAsEpC;iCACiC;AACjC,MAAM,CAAC,MAAM,eAAe,GAA6D;IACvF,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE;IACtC,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS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ized Point Cloud: LAZ 1.4 with an octree, read by HTTP range requests, as the\n * IGN distributes LiDAR HD) or a 3D Tiles point cloud (`.pnts`, glTF points), drawn by the engine with 3D Tiles. The\n * COPC file's CRS comes from its WKT (built-in CRSs, or registered ones: `registerCrs`) or the `crs` option; altitudes\n * in NGF-IGN69 (Lambert-93, the CC zones) are raised by the RAF20 geoid height onto the ellipsoid of the relief and\n * the 3D Tiles.\n */\nimport { type Crs, type CrsLike, epsgCode, getCrs } from './crs.ts';\nimport { type Feature, parseColor, type Ramp, rampTexels } from './features.ts';\nimport { Layer } from './layers.ts';\nimport type { LayerHost } from './types.ts';\nimport type {\n Engine,\n PointCloudCrs,\n PointCloudInfo,\n PointCloudPoint,\n PointCloudStats,\n Tiles3dStats,\n} from './wasm/isard.js';\n\n/** What the points are colored by */\nexport type PointColor = 'rgb' | 'classification' | 'elevation' | 'intensity';\n\n/** The look of a class of points */\nexport interface ClassStyle {\n /** CSS color */\n color?: string;\n /** false hides the class */\n visible?: boolean;\n}\n\nexport interface PointCloudStyle {\n /** By RGB (files with colors), class (the ASPRS palette, `classifications`), altitude (`elevationRamp` over\n * `elevationRange`) or intensity (grey over `intensityRange`). Default: RGB when the file has colors, else class */\n colorBy?: PointColor;\n /** CSS pixels: the size of the points, or the smallest with `sizeMode: 'adaptive'` (default 2) */\n pointSize: number;\n /** CSS pixels: the largest adaptive size (default 4) */\n maxPointSize: number;\n /** `'adaptive'` (default): the spacing of the points of the finest level drawn there, at their distance (the\n * nearer, the larger, no gap); `'fixed'`: `pointSize` everywhere */\n sizeMode: 'adaptive' | 'fixed';\n /** `'circle'` (default) or `'square'` */\n shape: 'circle' | 'square';\n /** Eye-Dome Lighting: points shaded by the depth of their neighbours on screen, their relief read without normals\n * nor colors (default false; `strength` 1, `radius` 1.4 CSS pixels) */\n edl: boolean | { strength?: number; radius?: number };\n /** Colors and visibility by class code, over the defaults (ASPRS, and IGN's LiDAR HD classes 64 to 67; the noise\n * 7 and 18 and the artefacts 65 hidden): `{ 2: { color: '#a0522d' }, 66: { visible: false } }` */\n classifications: Record<number, ClassStyle>;\n /** Altitudes (metres, the file's vertical datum) mapped onto the ramp; default the file's lowest and highest */\n elevationRange?: [min: number, max: number];\n /** Colors from the lowest altitude (0) to the highest (1) */\n elevationRamp: Ramp;\n /** Intensities mapped from black to white; default the bulk of the first node's (2nd to 98th percentile) */\n intensityRange?: [min: number, max: number];\n /** CSS pixels: a node is refined while the spacing of its points covers more on screen (default 1.5; lower is finer\n * and heavier). For 3D Tiles, their screen-space error (default 16) */\n maxScreenSpaceError: number;\n /** Points drawn at most, the nearest and the coarsest first (default 3 000 000) */\n pointBudget: number;\n}\n\nexport interface PointCloudOptions extends Partial<PointCloudStyle> {\n /** A COPC file (`.copc.laz`) or a 3D Tiles `tileset.json` of points */\n url: string;\n /** Default: `'3dtiles'` for a `.json` URL, else `'copc'` */\n format?: 'copc' | '3dtiles';\n /** The CRS of a COPC file without a WKT, or whose CRS is not built in (`proj4('EPSG:2992')`) */\n crs?: CrsLike;\n /** Its altitudes are above the geoid (NGF-IGN69), raised by the RAF20 geoid height; default for Lambert-93 and the\n * CC zones */\n geoid?: boolean;\n /** Metres of a unit of z; default the vertical unit of the WKT (a US survey foot…), else that of x and y */\n verticalScale?: number;\n /** Requests a second at most: 8 by default for the Géoplateforme (data.geopf.fr allows 10), no limit elsewhere */\n requestsPerSecond?: number;\n}\n\n/** The default classes: ASPRS LAS 1.4, then IGN's LiDAR HD (64 permanent structures, 65 artefacts, 66 virtual points,\n * 67 miscellaneous buildings) */\nexport const CLASSIFICATIONS: Readonly<Record<number, Readonly<Required<ClassStyle>>>> = {\n 0: { color: '#a6a6a6', visible: true },\n 1: { color: '#c8c8c8', visible: true },\n 2: { color: '#b08458', visible: true },\n 3: { color: '#9ccc65', visible: true },\n 4: { color: '#5aa83f', visible: true },\n 5: { color: '#2e7d32', visible: true },\n 6: { color: '#e57352', visible: true },\n 7: { color: '#ff00ff', visible: false },\n 8: { color: '#ff0000', visible: true },\n 9: { color: '#3d8fd6', visible: true },\n 10: { color: '#8e6bb0', visible: true },\n 11: { color: '#7a7a7a', visible: true },\n 12: { color: '#ffe680', visible: true },\n 13: { color: '#ffff00', visible: true },\n 14: { color: '#ffc800', visible: true },\n 15: { color: '#c89600', visible: true },\n 16: { color: '#ff9632', visible: true },\n 17: { color: '#b48cc8', visible: true },\n 18: { color: '#ff00ff', visible: false },\n 64: { color: '#8c6e5a', visible: true },\n 65: { color: '#ff00ff', visible: false },\n 66: { color: '#5a6ec8', visible: true },\n 67: { color: '#e6966e', visible: true },\n};\n\n/** The default ramp of the altitudes, low to high */\nexport const ELEVATION_RAMP: Ramp = [\n [0, '#2b83ba'],\n [0.25, '#abdda4'],\n [0.5, '#ffffbf'],\n [0.75, '#fdae61'],\n [1, '#d7191c'],\n];\n\n/** The colors of the 256 classes (RGBA, alpha 0 hides one) */\nexport function classPalette(overrides: Record<number, ClassStyle> = {}): Uint8Array {\n const out = new Uint8Array(256 * 4);\n for (let code = 0; code < 256; code += 1) {\n const base = CLASSIFICATIONS[code] ?? { color: '#c8c8c8', visible: true };\n const own = overrides[code] ?? {};\n const [r = 0, g = 0, b = 0] = parseColor(own.color ?? base.color);\n out.set([r * 255, g * 255, b * 255, (own.visible ?? base.visible) ? 255 : 0], code * 4);\n }\n return out;\n}\n\n/** The section of a WKT opening with one of `keywords` (`PROJCS[…]`), from its keyword to its closing bracket */\nfunction section(wkt: string, keywords: string[]): string | undefined {\n for (const keyword of keywords) {\n const start = wkt.indexOf(`${keyword}[`);\n if (start < 0) continue;\n let depth = 0;\n for (let i = start + keyword.length; i < wkt.length; i += 1) {\n if (wkt[i] === '[') depth += 1;\n else if (wkt[i] === ']' && --depth === 0) return wkt.slice(start, i + 1);\n }\n }\n return undefined;\n}\n\n/** The EPSG code a WKT section ends with (its own `AUTHORITY`, or `ID` in WKT2), the last of its nested ones */\nfunction lastCode(part: string): number | undefined {\n const codes = [...part.matchAll(/(?:AUTHORITY|ID)\\[\\s*\"EPSG\"\\s*,\\s*\"?(\\d+)\"?\\s*\\]/g)];\n const last = codes.at(-1)?.[1];\n return last === undefined ? undefined : Number(last);\n}\n\n/** The factor of the last `UNIT` (`LENGTHUNIT` in WKT2) of a WKT section */\nfunction lastUnit(part: string | undefined): number | undefined {\n const units = [...(part ?? '').matchAll(/(?:LENGTH)?UNIT\\[\\s*\"[^\"]*\"\\s*,\\s*([\\d.eE+-]+)/g)];\n const factor = Number(units.at(-1)?.[1]);\n return Number.isFinite(factor) && factor > 0 ? factor : undefined;\n}\n\n/** What a WKT says of a CRS: its EPSG code (projected first), the metres of a unit of z */\nexport function wktCrs(wkt: string): { code: number | undefined; verticalScale: number | undefined } {\n const projected = section(wkt, ['PROJCS', 'PROJCRS']);\n const geographic = section(wkt, ['GEOGCS', 'GEOGCRS']);\n let code = lastCode(projected ?? geographic ?? '');\n if (code === undefined && /Lambert[- ]93/i.test(wkt)) code = 2154;\n const vertical = section(wkt, ['VERT_CS', 'VERTCRS']);\n const verticalScale = lastUnit(vertical ?? projected);\n return { code, verticalScale };\n}\n\n/** Whether the altitudes of a CRS are NGF-IGN69 by default: Lambert-93 and the CC zones */\nconst FRENCH = (code: number | undefined) => code === 2154 || (code !== undefined && code >= 3942 && code <= 3950);\n\n/** The CRS of a COPC file for the engine, from its WKT and the options */\nexport function pointCloudCrs(\n wkt: string | undefined,\n options: Pick<PointCloudOptions, 'crs' | 'geoid' | 'verticalScale'>,\n): PointCloudCrs {\n const parsed = wkt ? wktCrs(wkt) : { code: undefined, verticalScale: undefined };\n let crs: Crs;\n let code = parsed.code;\n if (options.crs !== undefined) {\n crs = getCrs(options.crs);\n if (typeof options.crs === 'string') code = epsgCode(options.crs) ?? code;\n } else if (code !== undefined) {\n try {\n crs = getCrs(`EPSG:${code}`);\n } catch {\n throw new Error(`the CRS of the file, EPSG:${code}, is not built in: give it as \\`crs\\` (proj4('EPSG:${code}'))`);\n }\n } else {\n throw new Error('the file names no CRS: give it as `crs`');\n }\n const inverse = (xy: Float64Array) => {\n const out = new Float64Array(xy.length);\n for (let i = 0; i + 1 < xy.length; i += 2) {\n const [lon = Number.NaN, lat = Number.NaN] = crs.inverse([xy[i] as number, xy[i + 1] as number]);\n out[i] = lon;\n out[i + 1] = lat;\n }\n return out;\n };\n return {\n inverse,\n geoid: options.geoid ?? (FRENCH(code) || /IGN69|NGF/.test(wkt ?? '')),\n verticalScale: options.verticalScale ?? parsed.verticalScale ?? 1,\n };\n}\n\n/** The style numbers of the engine (`setPointCloudStyle`) */\nfunction styleNumbers(s: PointCloudStyle, rate: number): Float64Array {\n const colors: PointColor[] = ['rgb', 'classification', 'elevation', 'intensity'];\n let edl: { strength?: number; radius?: number } | undefined;\n if (s.edl) edl = s.edl === true ? {} : s.edl;\n const [emin = Number.NaN, emax = Number.NaN] = s.elevationRange ?? [];\n const [imin = Number.NaN, imax = Number.NaN] = s.intensityRange ?? [];\n return Float64Array.of(\n s.colorBy ? colors.indexOf(s.colorBy) : -1,\n s.pointSize,\n s.maxPointSize,\n s.sizeMode === 'fixed' ? 0 : 1,\n s.shape === 'square' ? 0 : 1,\n edl ? (edl.strength ?? 1) : 0,\n edl?.radius ?? 1.4,\n emin,\n emax,\n imin,\n imax,\n s.maxScreenSpaceError,\n s.pointBudget,\n rate,\n );\n}\n\n/** A point cloud (`GeoMap.addPointCloud`): COPC or 3D Tiles points; `pickFeature` gives a COPC point's attributes */\nexport class PointCloudLayer extends Layer {\n readonly url: string;\n readonly format: 'copc' | '3dtiles';\n private style: PointCloudStyle;\n private readonly options: PointCloudOptions;\n\n /** @internal */\n constructor(map: LayerHost, options: PointCloudOptions) {\n super(map);\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(options.url, base).href : options.url;\n this.format = options.format ?? (/\\.json(?:[?#]|$)/i.test(options.url) ? '3dtiles' : 'copc');\n this.options = options;\n const tiles = this.format === '3dtiles';\n this.style = {\n ...(options.colorBy ? { colorBy: options.colorBy } : {}),\n pointSize: options.pointSize ?? 2,\n maxPointSize: options.maxPointSize ?? 4,\n sizeMode: options.sizeMode ?? 'adaptive',\n shape: options.shape ?? 'circle',\n edl: options.edl ?? false,\n classifications: options.classifications ?? {},\n ...(options.elevationRange ? { elevationRange: options.elevationRange } : {}),\n elevationRamp: options.elevationRamp ?? ELEVATION_RAMP,\n ...(options.intensityRange ? { intensityRange: options.intensityRange } : {}),\n maxScreenSpaceError: options.maxScreenSpaceError ?? (tiles ? 16 : 1.5),\n pointBudget: options.pointBudget ?? 3_000_000,\n };\n }\n\n /** @internal Drawn by the engine with 3D Tiles (the point cloud module loads with the first one) */\n override get needsFullEngine(): boolean {\n return true;\n }\n\n /** Changes the style, the rest kept */\n setStyle(style: Partial<PointCloudStyle>): 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.apply(this.map.engine, this.id);\n this.map.requestRender();\n }\n\n getStyle(): Readonly<PointCloudStyle> {\n return this.style;\n }\n\n /** Loading counters; undefined once removed and while the engine with 3D Tiles loads */\n stats(): PointCloudStats | Tiles3dStats | undefined {\n if (this.id < 0) return undefined;\n return this.format === '3dtiles' ? this.map.engine.tiles3dStats(this.id) : this.map.engine.pointCloudStats(this.id);\n }\n\n /** What a COPC file says of itself (points, format, CRS, center, altitudes), once its head is read */\n info(): PointCloudInfo | undefined {\n return this.id < 0 || this.format === '3dtiles' ? undefined : this.map.engine.pointCloudInfo(this.id);\n }\n\n /** @internal The point picked (`pickFeature`, 'hoverfeature'): a Point at its longitude, latitude and height, its\n * attributes as properties */\n featureAt(index: number): Feature<PointCloudPoint> | undefined {\n if (this.id < 0 || this.format === '3dtiles') return undefined;\n const point = this.map.engine.pointCloudPoint(this.id, index);\n if (!point) return undefined;\n return {\n type: 'Feature',\n geometry: { type: 'Point', coordinates: [...point.lonLat, point.height] },\n properties: point,\n };\n }\n\n private apply(engine: Engine, id: number): void {\n const s = this.style;\n if (this.format === '3dtiles') {\n engine.setTiles3dStyle(id, s.maxScreenSpaceError, 1, s.pointSize);\n return;\n }\n const rate = this.options.requestsPerSecond ?? (/^https?:\\/\\/data\\.geopf\\.fr\\//.test(this.url) ? 8 : 0);\n engine.setPointCloudStyle(\n id,\n styleNumbers(s, rate),\n classPalette(s.classifications),\n rampTexels(s.elevationRamp).rgba,\n );\n }\n\n /** @internal */\n protected create(engine: Engine): number {\n const id =\n this.format === '3dtiles'\n ? engine.addTiles3d(this.url, this.style.maxScreenSpaceError)\n : engine.addPointCloud(this.url, (wkt) => pointCloudCrs(wkt, this.options));\n this.apply(engine, id);\n return id;\n }\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `isard/projections`: coordinate reference systems (Lambert-93, the CC zones, UTM, or any proj4 converter), GeoJSON
|
|
3
|
+
* reprojected into longitudes and latitudes, and the tile grids of rasters served in another projection.
|
|
4
|
+
*
|
|
5
|
+
* ```ts
|
|
6
|
+
* import { reproject, wmtsGrid } from 'isard/projections';
|
|
7
|
+
* map.addFills({ data: reproject(parcels, 'EPSG:2154') });
|
|
8
|
+
* map.addRaster({ url, grid: await wmtsGrid(capabilitiesUrl, 'PLANIGNV2.L93', '2154_10cm_6_20') });
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export { type Crs, type CrsLike, getCrs, lambertConformalConic, registerCrs, reproject, transverseMercator, } from './crs.ts';
|
|
12
|
+
export type { TileGrid, TileMatrix } from './grid.ts';
|
|
13
|
+
export { parseWmtsGrid, wmtsGrid } from './wmts.ts';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `isard/projections`: coordinate reference systems (Lambert-93, the CC zones, UTM, or any proj4 converter), GeoJSON
|
|
3
|
+
* reprojected into longitudes and latitudes, and the tile grids of rasters served in another projection.
|
|
4
|
+
*
|
|
5
|
+
* ```ts
|
|
6
|
+
* import { reproject, wmtsGrid } from 'isard/projections';
|
|
7
|
+
* map.addFills({ data: reproject(parcels, 'EPSG:2154') });
|
|
8
|
+
* map.addRaster({ url, grid: await wmtsGrid(capabilitiesUrl, 'PLANIGNV2.L93', '2154_10cm_6_20') });
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export { getCrs, lambertConformalConic, registerCrs, reproject, transverseMercator, } from "./crs.js";
|
|
12
|
+
export { parseWmtsGrid, wmtsGrid } from "./wmts.js";
|
|
13
|
+
//# sourceMappingURL=projections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projections.js","sourceRoot":"","sources":["../src/projections.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAGL,MAAM,EACN,qBAAqB,EACrB,WAAW,EACX,SAAS,EACT,kBAAkB,GACnB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC","sourcesContent":["/**\n * `isard/projections`: coordinate reference systems (Lambert-93, the CC zones, UTM, or any proj4 converter), GeoJSON\n * reprojected into longitudes and latitudes, and the tile grids of rasters served in another projection.\n *\n * ```ts\n * import { reproject, wmtsGrid } from 'isard/projections';\n * map.addFills({ data: reproject(parcels, 'EPSG:2154') });\n * map.addRaster({ url, grid: await wmtsGrid(capabilitiesUrl, 'PLANIGNV2.L93', '2154_10cm_6_20') });\n * ```\n */\nexport {\n type Crs,\n type CrsLike,\n getCrs,\n lambertConformalConic,\n registerCrs,\n reproject,\n transverseMercator,\n} from './crs.ts';\nexport type { TileGrid, TileMatrix } from './grid.ts';\nexport { parseWmtsGrid, wmtsGrid } from './wmts.ts';\n"]}
|
package/dist/protocol.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ export type WorkerRequest = {
|
|
|
6
6
|
module: WebAssembly.Module;
|
|
7
7
|
decoders: DecoderUrls;
|
|
8
8
|
formats: TextureFormats;
|
|
9
|
+
/** URL of the point cloud module (`isard_points_bg.wasm`), loaded with the first COPC chunk */
|
|
10
|
+
points: string;
|
|
9
11
|
} | {
|
|
10
12
|
type: 'load';
|
|
11
13
|
id: number;
|
|
@@ -14,6 +16,17 @@ export type WorkerRequest = {
|
|
|
14
16
|
yUp: boolean;
|
|
15
17
|
reload: boolean;
|
|
16
18
|
priority?: 'high' | 'low';
|
|
19
|
+
} | {
|
|
20
|
+
type: 'points';
|
|
21
|
+
id: number;
|
|
22
|
+
url: string;
|
|
23
|
+
offset: number;
|
|
24
|
+
size: number;
|
|
25
|
+
laz: Uint8Array;
|
|
26
|
+
layout: Float64Array;
|
|
27
|
+
grid: Float64Array;
|
|
28
|
+
count: number;
|
|
29
|
+
priority?: 'high' | 'low';
|
|
17
30
|
} | {
|
|
18
31
|
type: 'abort';
|
|
19
32
|
id: number;
|
|
@@ -22,6 +35,10 @@ export type WorkerReply = {
|
|
|
22
35
|
type: 'tile';
|
|
23
36
|
id: number;
|
|
24
37
|
tile: DecodedTile;
|
|
38
|
+
} | {
|
|
39
|
+
type: 'points';
|
|
40
|
+
id: number;
|
|
41
|
+
vertices: Uint8Array<ArrayBuffer>;
|
|
25
42
|
} | {
|
|
26
43
|
type: 'error';
|
|
27
44
|
id: number;
|
package/dist/protocol.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"","sourcesContent":["/** Messages between the main thread and the decoding workers */\nimport type { DecoderUrls } from './decoders.ts';\nimport type { DecodedTile, TextureFormats } from './wasm/isard.js';\n\nexport type WorkerRequest =\n | {
|
|
1
|
+
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"","sourcesContent":["/** Messages between the main thread and the decoding workers */\nimport type { DecoderUrls } from './decoders.ts';\nimport type { DecodedTile, TextureFormats } from './wasm/isard.js';\n\nexport type WorkerRequest =\n | {\n type: 'init';\n module: WebAssembly.Module;\n decoders: DecoderUrls;\n formats: TextureFormats;\n /** URL of the point cloud module (`isard_points_bg.wasm`), loaded with the first COPC chunk */\n points: string;\n }\n | {\n type: 'load';\n id: number;\n url: string;\n transform: Float64Array;\n yUp: boolean;\n reload: boolean;\n priority?: 'high' | 'low';\n }\n | {\n type: 'points';\n id: number;\n url: string;\n offset: number;\n size: number;\n laz: Uint8Array;\n layout: Float64Array;\n grid: Float64Array;\n count: number;\n priority?: 'high' | 'low';\n }\n | { type: 'abort'; id: number };\n\nexport type WorkerReply =\n | { type: 'tile'; id: number; tile: DecodedTile }\n | { type: 'points'; id: number; vertices: Uint8Array<ArrayBuffer> }\n | { type: 'error'; id: number; error: string; aborted: boolean };\n"]}
|
package/dist/types.d.ts
CHANGED
|
@@ -37,7 +37,8 @@ export type TerrainEncoding = 'float32' | 'terrarium' | 'mapbox';
|
|
|
37
37
|
* fade in; fewer downloads, for slow networks or GPUs.
|
|
38
38
|
*/
|
|
39
39
|
export type LoadingMode = 'immediate' | 'smooth';
|
|
40
|
-
/** 'globe': a sphere at low zoom, blending into Web Mercator between zooms 5 and 7
|
|
40
|
+
/** 'globe': a sphere at low zoom, blending into Web Mercator between zooms 5 and 7, up to three levels later under a
|
|
41
|
+
* tilted camera (it sees much farther than its center: the horizon stays curved) */
|
|
41
42
|
export type Projection = 'globe' | 'mercator';
|
|
42
43
|
/** A body to draw the map on, other than the named ones (`CelestialBody`) */
|
|
43
44
|
export interface BodyOptions {
|
|
@@ -104,6 +105,9 @@ export interface GeoMapOptions extends Partial<Camera> {
|
|
|
104
105
|
* resolve the default URL. Maps load it first, and the engine with 3D Tiles (`wasmUrl`) for their first 3D Tiles
|
|
105
106
|
* layer only */
|
|
106
107
|
coreWasmUrl?: string | URL;
|
|
108
|
+
/** Where the decoding workers load the point cloud module from (`isard_points_bg.wasm`, the LAZ decoder of COPC),
|
|
109
|
+
* when a bundler does not resolve the default URL. Loaded with the first point cloud only */
|
|
110
|
+
pointsWasmUrl?: string | URL;
|
|
107
111
|
/** Load the engine with 3D Tiles from the start (default false: it is loaded when the first 3D Tiles layer or glTF
|
|
108
112
|
* model is added, the map then moving its camera and layers onto it, a stall of about a frame or two). For a map that shows 3D Tiles
|
|
109
113
|
* at once: one engine downloaded instead of two. `'preload'`: the map starts on the engine without 3D Tiles and
|
|
@@ -257,9 +261,11 @@ export interface Tiles3dStyle {
|
|
|
257
261
|
/** Screen-space error (CSS pixels) above which a tile is refined: 16 by default, lower is finer and heavier */
|
|
258
262
|
maxScreenSpaceError: number;
|
|
259
263
|
opacity: number;
|
|
264
|
+
/** Size of the points of point cloud tiles (`.pnts`, glTF points), CSS pixels: 2 by default */
|
|
265
|
+
pointSize?: number;
|
|
260
266
|
}
|
|
261
267
|
export interface Tiles3dOptions extends Partial<Tiles3dStyle> {
|
|
262
|
-
/** URL of a `tileset.json` (3D Tiles 1.0 b3dm
|
|
268
|
+
/** URL of a `tileset.json` (3D Tiles 1.0 b3dm and pnts, 1.1 glb meshes and points, external tilesets) */
|
|
263
269
|
url: string;
|
|
264
270
|
}
|
|
265
271
|
export interface MapPointerEvent {
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["/** Public types of the `isard` package */\nimport type { AttributionOptions } from './controls.ts';\nimport type { DecoderUrls } from './decoders.ts';\nimport type { Feature, Ramp, Size } from './features.ts';\nimport type { TileGrid } from './grid.ts';\nimport type { Layer } from './layers.ts';\nimport type { Camera, Engine } from './wasm/isard.js';\n\nexport type LonLat = [lon: number, lat: number];\nexport type Point = [x: number, y: number];\n\n/**\n * The named basemaps. OpenFreeMap's vector styles, OpenStreetMap data worldwide, their labels above the other layers:\n * `osm-positron` (light grey, quiet: data over it reads first), `osm-liberty` and `osm-bright` (in colour). The\n * Géoplateforme's (IGN, France): rasters (`ign-plan`, `ign-plan-grey`, `ign-ortho`, the aerial photographs) or vector\n * tiles with their labels (`ign-plan-vector`, `ign-plan-grey-vector`, the PLAN.IGN styles).\n */\nexport type BasemapName =\n | 'osm-positron'\n | 'osm-liberty'\n | 'osm-bright'\n | 'ign-plan'\n | 'ign-plan-grey'\n | 'ign-ortho'\n | 'ign-plan-vector'\n | 'ign-plan-grey-vector'\n | 'none';\n\n/**\n * @deprecated The former names of the Géoplateforme basemaps, still accepted (with a warning): the same names with the\n * `ign-` prefix (`'plan-grey'` is `'ign-plan-grey'`)\n */\nexport type LegacyBasemap = 'plan' | 'plan-grey' | 'plan-vector' | 'plan-grey-vector' | 'ortho';\n\n/** A basemap by name (see `BasemapName`; the former names of `LegacyBasemap` are deprecated) */\nexport type Basemap = BasemapName | LegacyBasemap;\n\n/**\n * The Earth's named terrain models. `'terrain-tiles'`: worldwide, the Terrain Tiles of AWS's open data registry\n * (SRTM, EU-DEM, GMTED… merged by Mapzen, 30 m in most places), the sea floor flattened at sea level. `'ign'`: France,\n * the IGN's RGE ALTI from the Géoplateforme (1 to 5 m), raised by the RAF20 geoid to heights above the ellipsoid.\n */\nexport type TerrainModel = 'terrain-tiles' | 'ign';\n\n/** How tiles encode their altitudes: `'float32'`, raw little-endian floats (`image/x-bil;bits=32`, an ArcGIS raw\n * grid); `'terrarium'`, the colors of a PNG, `R × 256 + G + B / 256 - 32768`; `'mapbox'`, those of Terrain-RGB,\n * `(R × 65536 + G × 256 + B) / 10 - 10000` */\nexport type TerrainEncoding = 'float32' | 'terrarium' | 'mapbox';\n\n/**\n * How tiles load and show. 'immediate' (default): everything visible loads, tiles show as soon as they arrive.\n * 'smooth': during flights the levels flown through are skipped, off-center tiles wait while the camera moves, tiles\n * fade in; fewer downloads, for slow networks or GPUs.\n */\nexport type LoadingMode = 'immediate' | 'smooth';\n\n/** 'globe': a sphere at low zoom, blending into Web Mercator between zooms 5 and 7 */\nexport type Projection = 'globe' | 'mercator';\n\n/** A body to draw the map on, other than the named ones (`CelestialBody`) */\nexport interface BodyOptions {\n /** Equatorial radius, metres */\n radius: number;\n /** Flattening of its ellipsoid, 0 for a sphere (default 0) */\n flattening?: number;\n /** An atmosphere: its halo around the globe, true for the Earth's light blue, or a CSS color (its alpha the\n * halo's strength) (default false) */\n atmosphere?: boolean | string;\n /** Color of the globe where no tile covers it (past the Web Mercator latitudes, 85°), a CSS color (default\n * `#808080`) */\n color?: string;\n /** Lowest and highest altitudes of its ground, metres around the ellipsoid: what its relief may raise into view\n * (default ±1 % of the radius) */\n relief?: [lowest: number, highest: number];\n}\n\n/**\n * The body the map is drawn on: 'earth' (WGS 84, the default), 'moon' (a sphere of 1 737 400 m, no atmosphere),\n * 'mars' (a sphere of 3 396 190 m, its equatorial radius, a thin dusty halo; planetocentric latitudes) or another\n * one. Zoom levels keep their meaning on screen (the Web Mercator tile pyramid), their metres follow the body:\n * altitudes, relief, buildings, 3D Tiles. Off the Earth, the map has none of the Earth's defaults: no basemap, no\n * credits, and space for its background; the Moon and Mars have NASA's relief for `terrain: true`.\n */\nexport type CelestialBody = 'earth' | 'moon' | 'mars' | BodyOptions;\n\nexport interface GeoMapOptions extends Partial<Camera> {\n /** The body the map is drawn on (default 'earth'); set at creation */\n body?: CelestialBody;\n /** Default 'globe' */\n projection?: Projection;\n /** Default 'immediate' */\n loading?: LoadingMode;\n /** The basemap (default 'osm-positron'; 'none' off the Earth) */\n basemap?: Basemap;\n /** Opacity of the IGN hillshade over the basemap (France, Géoplateforme), 0 for none (default 0) */\n hillshade?: number;\n /** Color behind the map (sky of tilted flat views), a CSS color (default `#f2f2f0`; black off the Earth) */\n background?: string;\n /** Space behind the globe: stars and atmosphere halo, fading out as the globe turns flat (default true) */\n sky?: boolean;\n /** Relief under the basemap: true for the body's terrain model (on the Earth the worldwide Terrain Tiles; NASA's on\n * the Moon and Mars: LOLA, MOLA), one of the Earth's models by name (`'ign'`: France, RGE ALTI), or its options\n * (default false; on another body, its `url` is required). Network layers are draped on it */\n terrain?: boolean | TerrainModel | TerrainOptions;\n minZoom?: number;\n maxZoom?: number;\n /** Highest pitch, degrees, up to 85 (default 70) */\n maxPitch?: number;\n /** Sky over the plane, seen when the camera is tilted towards the horizon, and the fog the ground fades into\n * (MapLibre's `setSky`); default none: the background color */\n atmosphere?: AtmosphereOptions;\n /** Mouse, touch and keyboard controls (default true) */\n interactive?: boolean;\n /** Keyboard controls once the map has the focus (it is reached with Tab): arrows pan, Shift + arrows rotate and\n * tilt, + and - zoom (Shift: two levels), 0 faces north and levels the view (default true; none when not\n * `interactive`) */\n keyboard?: boolean;\n /** Accessible name of the map, read by screen readers (default 'Map') */\n ariaLabel?: string;\n /** Where to load the engine with 3D Tiles from (`isard_bg.wasm`), when a bundler does not resolve the default URL.\n * Given without `coreWasmUrl`, maps load this engine from the start */\n wasmUrl?: string | URL;\n /** Where to load the engine without 3D Tiles from (`isard_core_bg.wasm`, a third smaller), when a bundler does not\n * resolve the default URL. Maps load it first, and the engine with 3D Tiles (`wasmUrl`) for their first 3D Tiles\n * layer only */\n coreWasmUrl?: string | URL;\n /** Load the engine with 3D Tiles from the start (default false: it is loaded when the first 3D Tiles layer or glTF\n * model is added, the map then moving its camera and layers onto it, a stall of about a frame or two). For a map that shows 3D Tiles\n * at once: one engine downloaded instead of two. `'preload'`: the map starts on the engine without 3D Tiles and\n * downloads and compiles the other once idle, without running it: its first 3D Tiles layer does not wait for the\n * download (for a map that will show 3D Tiles later, on demand) */\n tiles3d?: boolean | 'preload';\n /** Where to load the vector basemap worker from, when a bundler does not resolve the default URL */\n basemapWorkerUrl?: string | URL;\n /** Texture size of the vector basemap's tiles, pixels (default 512: lines and edges sharp at every zoom on a screen\n * of pixel ratio 1). 256: a quarter of the drawing in the workers, of the uploads and of the GPU memory, for lines\n * and edges a little softer between two zoom levels (the tiles are shown 181 to 362 CSS pixels wide) */\n basemapTileSize?: number;\n /** Glyphs of the symbol layers: a URL with `{fontstack}` and `{range}` (MapLibre's glyph format; default\n * OpenFreeMap's fonts, Noto Sans). A vector basemap's labels take the glyphs of its style */\n glyphs?: string;\n /** Workers decoding 3D Tiles off the main thread: a count, or false to decode on the main thread (default: cores - 1,\n * 1 to 4). False (or 0) also decodes the PNG relief and reprojects the equirectangular rasters on the main thread,\n * else done by the vector basemap's workers */\n workers?: number | false;\n /** Where to load the decoding worker from, when a bundler does not resolve the default URL */\n workerUrl?: string | URL;\n /** Folders of the Draco and Basis Universal decoders, loaded by the workers on first use (default: the official\n * builds on gstatic.com and jsDelivr; self-host them for offline or locked-down networks). They run through\n * `new Function`: a Content Security Policy needs `'unsafe-eval'` (see `DecoderUrls`) */\n decoders?: Partial<DecoderUrls>;\n /** Credits at the bottom right: false for none, or its options (default true: the credits of the basemap,\n * hillshade and relief in use, compact on maps narrower than 640 px) */\n attributionControl?: boolean | AttributionOptions;\n}\n\nexport interface TerrainOptions {\n /** One of the Earth's named models (default `'terrain-tiles'` on the Earth); unused with a `url` */\n model?: TerrainModel;\n /** Altitudes of 256 × 256 tiles in `encoding`: a WMS GetMap URL with {bbox} (EPSG:3857 on the Earth, the body's\n * Mercator metres elsewhere: the sphere of its radius), a tile URL with {z}, {x} and {y}, or an ArcGIS image service\n * (a URL ending in `/ImageServer`), asked for raw altitudes in the body's Mercator (default: the `model`'s; on the\n * Moon and Mars, NASA's Trek LOLA and MOLA models) */\n url?: string;\n /** How the tiles of `url` encode their altitudes (default `'float32'`); `'terrarium'` and `'mapbox'` take a URL with\n * {z}, {x} and {y} */\n encoding?: TerrainEncoding;\n /** Vertical exaggeration, 1 for the true relief (default 1) */\n exaggeration?: number;\n /** Finest level of the relief, up to 15 (default 15; 14 for the Terrain Tiles, 8 for the Moon's and Mars's models). It\n * starts at level 6 on the Earth, coarser on bodies of a larger relief for their size (3 on the Moon and Mars) */\n maxZoom?: number;\n /** Altitudes over mainland France raised by the height of the RAF20 geoid (the French one, 0 away from France), to\n * heights above the ellipsoid (those of 3D Tiles); false keeps the altitudes as served (NGF-IGN69 for the IGN's)\n * (default true for the `'ign'` model, false otherwise) */\n geoid?: boolean;\n}\n\n/** Sky, horizon and fog over the plane, with the names and meanings of MapLibre's `setSky` */\nexport interface AtmosphereOptions {\n /** A CSS color (default `#9cc7ec`) */\n skyColor?: string;\n /** (default `#e8f1f8`) */\n horizonColor?: string;\n /** (default `#f2f5f8`) */\n fogColor?: string;\n /** Blend from the horizon to the sky color, share of the field of view above the horizon, 0-1 (default 0.6) */\n skyHorizonBlend?: number;\n /** Blend from the horizon to the fog color below the horizon, 0-1 (default 0.7) */\n horizonFogBlend?: number;\n /** Share of the distance to the far plane over which the ground fades into the fog, 0-1 (default 0.4) */\n fogGroundBlend?: number;\n}\n\n/** Animation of a camera move */\nexport interface AnimationOptions {\n /** Milliseconds */\n duration?: number;\n /** Progress over time, both 0 to 1 */\n easing?: (t: number) => number;\n}\n\nexport interface FlyToOptions extends AnimationOptions {\n /** How far the flight zooms out on its way, as MapLibre's `curve` (default 1.42) */\n curve?: number;\n /** Average speed in screens per second when `duration` is not given (default 1.2) */\n speed?: number;\n}\n\n/**\n * Tile grid of a raster's URL. 'mercator': Web Mercator (XYZ, WMTS PM), the engine's own. 'equirectangular':\n * longitudes and latitudes (Plate Carrée, EPSG:4326-like), two 256 px tiles side by side at level 0, rows from the\n * north (NASA's Trek WMTS, WorldCRS84Quad). A `TileGrid`: the tile matrices of a WMTS in any CRS (Lambert-93…), or a\n * WMS asked for each tile's box in its CRS. The last two are reprojected into Web Mercator tiles by the map's workers\n * (in the page with `workers: false`).\n */\nexport type RasterGrid = 'mercator' | 'equirectangular' | TileGrid;\n\n/** What `RasterLayer.setStyle` changes */\nexport interface RasterStyle {\n opacity: number;\n /** 0 = greyscale, 1 = original colors */\n saturation: number;\n}\n\nexport interface RasterOptions {\n /** Tile URL with {z}, {x} and {y} (256 px tiles); unused with a `loader` */\n url: string;\n /** Tile grid of `url` (default 'mercator'); with 'equirectangular', `minZoom` and `maxZoom` are levels of that\n * grid; with a `TileGrid`, they are map zooms, by default those its matrices span */\n grid?: RasterGrid;\n minZoom?: number;\n maxZoom?: number;\n opacity?: number;\n /** 0 = greyscale, 1 = original colors */\n saturation?: number;\n /** Side of the tiles' textures, pixels (default 256): more for sharper tiles drawn by a `loader` */\n size?: number;\n /** Draws each tile instead of fetching `url`: an image of `size` × `size`, null for nothing there; a rejection is\n * retried like a network error */\n loader?: (z: number, x: number, y: number, signal: AbortSignal) => Promise<ImageBitmap | null>;\n /** Credits of the tiles, HTML: shown by the attribution control while the layer is on the map */\n attribution?: string;\n}\n\nexport interface NetworkStyle {\n /** Line width, CSS pixels, or zoom stops `[[zoom, width], …]` (default 2) */\n width: Size;\n /** Values above are drawn as unreached (default 1800) */\n max: number;\n /** Darker line every `contour` value units, 0 for none (default 0) */\n contour: number;\n opacity: number;\n /** Width of the halo drawn under the lines, CSS pixels or zoom stops, 0 for none (default 0): wide and faint, the\n * reached streets add up into a heat map that fills the blocks */\n halo: Size;\n /** Opacity of the halo at the middle of a line, fading quadratically to its sides (default 0.11) */\n haloOpacity: number;\n /** Colors from 0 to `max`: `[[fraction of max, color], …]` (default green to red) */\n ramp: Ramp | undefined;\n /** Color of the parts beyond `max` or unreached (default `rgba(140, 140, 140, 0.25)`) */\n unreachedColor: string;\n /** Share of `max` over which the colors fade out before it, 0 to 1 (default 0) */\n fade: number;\n}\n\nexport interface NetworkOptions extends Partial<NetworkStyle> {\n /** Node coordinates in degrees: lon0, lat0, lon1, lat1… */\n nodes: Float64Array;\n /** Edges as node index pairs: a0, b0, a1, b1… */\n edges: Uint32Array;\n /** Line of each edge, from A to B: the points of edge e are `points[start[e] .. start[e + 1]]` (lon, lat pairs,\n * counted in points); with fewer than two points an edge is straight. Default: all straight. */\n lines?: { start: Uint32Array; points: Float64Array };\n /** Per edge, the cost of travelling it from A to B then from B to A, in value units (Infinity: closed that way;\n * closed both ways: not drawn). A point along an edge then takes the quickest way there, min(value(A) + cost from\n * A, value(B) + cost from B), as a travel time does. Without costs, values are interpolated along the edges. */\n costs?: Float32Array;\n /** Width factor of each edge (default 1): rail lines wider than streets */\n edgeWidths?: Float32Array;\n}\n\nexport interface Tiles3dStyle {\n /** Screen-space error (CSS pixels) above which a tile is refined: 16 by default, lower is finer and heavier */\n maxScreenSpaceError: number;\n opacity: number;\n}\n\nexport interface Tiles3dOptions extends Partial<Tiles3dStyle> {\n /** URL of a `tileset.json` (3D Tiles 1.0 b3dm or 1.1 glb meshes, external tilesets) */\n url: string;\n}\n\nexport interface MapPointerEvent {\n point: Point;\n /** Undefined above the horizon */\n lonLat: LonLat | undefined;\n}\n\n/** What 'hoverfeature' found under the pointer */\nexport interface MapHoverFeatureEvent extends MapPointerEvent {\n /** The feature under the pointer (see `GeoMap.pickFeature`), undefined if none */\n hit: FeatureHit | undefined;\n}\n\n/** A picked feature: its layer handle, its index there and, for line, circle and fill layers, the feature itself */\nexport interface FeatureHit {\n layer: Layer;\n index: number;\n feature: Feature | undefined;\n}\n\nexport interface MapEvents {\n /** The camera started moving (a gesture, an animation or `setCamera`) */\n movestart: Camera;\n /** The camera moved */\n move: Camera;\n /** The camera stopped: no gesture held, no animation running */\n moveend: Camera;\n /** The map changed size (CSS pixels) */\n resize: { width: number; height: number };\n /** The pointer moved over the map (at most once per frame, not while dragging) */\n hover: MapPointerEvent;\n /** What is under the pointer, picked without stalling the GPU: a frame or two after 'hover', only while listened to\n * (radius and layers in `GeoMap.hoverPicking`) */\n hoverfeature: MapHoverFeatureEvent;\n /** Click without drag */\n click: MapPointerEvent;\n /** A frame was drawn; duration of the engine call in milliseconds */\n render: { ms: number };\n /** Everything in view is loaded and drawn, nothing moves: the end of a load, once after each change (as MapLibre's\n * `idle`). Tiles requested by the first frame count, so it never fires before they arrive. */\n idle: Record<string, never>;\n /** The pointer left the canvas (a mouse going out of the map, or onto a control or marker) */\n leave: Record<string, never>;\n}\n\n/** What a layer handle needs from its map */\nexport interface LayerHost {\n readonly engine: Engine;\n requestRender(): void;\n /** Forgets a removed layer */\n detach(layer: object): void;\n /** Moves a layer under `before`, or on top */\n moveLayer(layer: object, before: object | undefined): void;\n /** A layer created again in the engine (new id): put at the place of its old id, which is removed */\n replaceLayer(layer: object, old: number): void;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["/** Public types of the `isard` package */\nimport type { AttributionOptions } from './controls.ts';\nimport type { DecoderUrls } from './decoders.ts';\nimport type { Feature, Ramp, Size } from './features.ts';\nimport type { TileGrid } from './grid.ts';\nimport type { Layer } from './layers.ts';\nimport type { Camera, Engine } from './wasm/isard.js';\n\nexport type LonLat = [lon: number, lat: number];\nexport type Point = [x: number, y: number];\n\n/**\n * The named basemaps. OpenFreeMap's vector styles, OpenStreetMap data worldwide, their labels above the other layers:\n * `osm-positron` (light grey, quiet: data over it reads first), `osm-liberty` and `osm-bright` (in colour). The\n * Géoplateforme's (IGN, France): rasters (`ign-plan`, `ign-plan-grey`, `ign-ortho`, the aerial photographs) or vector\n * tiles with their labels (`ign-plan-vector`, `ign-plan-grey-vector`, the PLAN.IGN styles).\n */\nexport type BasemapName =\n | 'osm-positron'\n | 'osm-liberty'\n | 'osm-bright'\n | 'ign-plan'\n | 'ign-plan-grey'\n | 'ign-ortho'\n | 'ign-plan-vector'\n | 'ign-plan-grey-vector'\n | 'none';\n\n/**\n * @deprecated The former names of the Géoplateforme basemaps, still accepted (with a warning): the same names with the\n * `ign-` prefix (`'plan-grey'` is `'ign-plan-grey'`)\n */\nexport type LegacyBasemap = 'plan' | 'plan-grey' | 'plan-vector' | 'plan-grey-vector' | 'ortho';\n\n/** A basemap by name (see `BasemapName`; the former names of `LegacyBasemap` are deprecated) */\nexport type Basemap = BasemapName | LegacyBasemap;\n\n/**\n * The Earth's named terrain models. `'terrain-tiles'`: worldwide, the Terrain Tiles of AWS's open data registry\n * (SRTM, EU-DEM, GMTED… merged by Mapzen, 30 m in most places), the sea floor flattened at sea level. `'ign'`: France,\n * the IGN's RGE ALTI from the Géoplateforme (1 to 5 m), raised by the RAF20 geoid to heights above the ellipsoid.\n */\nexport type TerrainModel = 'terrain-tiles' | 'ign';\n\n/** How tiles encode their altitudes: `'float32'`, raw little-endian floats (`image/x-bil;bits=32`, an ArcGIS raw\n * grid); `'terrarium'`, the colors of a PNG, `R × 256 + G + B / 256 - 32768`; `'mapbox'`, those of Terrain-RGB,\n * `(R × 65536 + G × 256 + B) / 10 - 10000` */\nexport type TerrainEncoding = 'float32' | 'terrarium' | 'mapbox';\n\n/**\n * How tiles load and show. 'immediate' (default): everything visible loads, tiles show as soon as they arrive.\n * 'smooth': during flights the levels flown through are skipped, off-center tiles wait while the camera moves, tiles\n * fade in; fewer downloads, for slow networks or GPUs.\n */\nexport type LoadingMode = 'immediate' | 'smooth';\n\n/** 'globe': a sphere at low zoom, blending into Web Mercator between zooms 5 and 7, up to three levels later under a\n * tilted camera (it sees much farther than its center: the horizon stays curved) */\nexport type Projection = 'globe' | 'mercator';\n\n/** A body to draw the map on, other than the named ones (`CelestialBody`) */\nexport interface BodyOptions {\n /** Equatorial radius, metres */\n radius: number;\n /** Flattening of its ellipsoid, 0 for a sphere (default 0) */\n flattening?: number;\n /** An atmosphere: its halo around the globe, true for the Earth's light blue, or a CSS color (its alpha the\n * halo's strength) (default false) */\n atmosphere?: boolean | string;\n /** Color of the globe where no tile covers it (past the Web Mercator latitudes, 85°), a CSS color (default\n * `#808080`) */\n color?: string;\n /** Lowest and highest altitudes of its ground, metres around the ellipsoid: what its relief may raise into view\n * (default ±1 % of the radius) */\n relief?: [lowest: number, highest: number];\n}\n\n/**\n * The body the map is drawn on: 'earth' (WGS 84, the default), 'moon' (a sphere of 1 737 400 m, no atmosphere),\n * 'mars' (a sphere of 3 396 190 m, its equatorial radius, a thin dusty halo; planetocentric latitudes) or another\n * one. Zoom levels keep their meaning on screen (the Web Mercator tile pyramid), their metres follow the body:\n * altitudes, relief, buildings, 3D Tiles. Off the Earth, the map has none of the Earth's defaults: no basemap, no\n * credits, and space for its background; the Moon and Mars have NASA's relief for `terrain: true`.\n */\nexport type CelestialBody = 'earth' | 'moon' | 'mars' | BodyOptions;\n\nexport interface GeoMapOptions extends Partial<Camera> {\n /** The body the map is drawn on (default 'earth'); set at creation */\n body?: CelestialBody;\n /** Default 'globe' */\n projection?: Projection;\n /** Default 'immediate' */\n loading?: LoadingMode;\n /** The basemap (default 'osm-positron'; 'none' off the Earth) */\n basemap?: Basemap;\n /** Opacity of the IGN hillshade over the basemap (France, Géoplateforme), 0 for none (default 0) */\n hillshade?: number;\n /** Color behind the map (sky of tilted flat views), a CSS color (default `#f2f2f0`; black off the Earth) */\n background?: string;\n /** Space behind the globe: stars and atmosphere halo, fading out as the globe turns flat (default true) */\n sky?: boolean;\n /** Relief under the basemap: true for the body's terrain model (on the Earth the worldwide Terrain Tiles; NASA's on\n * the Moon and Mars: LOLA, MOLA), one of the Earth's models by name (`'ign'`: France, RGE ALTI), or its options\n * (default false; on another body, its `url` is required). Network layers are draped on it */\n terrain?: boolean | TerrainModel | TerrainOptions;\n minZoom?: number;\n maxZoom?: number;\n /** Highest pitch, degrees, up to 85 (default 70) */\n maxPitch?: number;\n /** Sky over the plane, seen when the camera is tilted towards the horizon, and the fog the ground fades into\n * (MapLibre's `setSky`); default none: the background color */\n atmosphere?: AtmosphereOptions;\n /** Mouse, touch and keyboard controls (default true) */\n interactive?: boolean;\n /** Keyboard controls once the map has the focus (it is reached with Tab): arrows pan, Shift + arrows rotate and\n * tilt, + and - zoom (Shift: two levels), 0 faces north and levels the view (default true; none when not\n * `interactive`) */\n keyboard?: boolean;\n /** Accessible name of the map, read by screen readers (default 'Map') */\n ariaLabel?: string;\n /** Where to load the engine with 3D Tiles from (`isard_bg.wasm`), when a bundler does not resolve the default URL.\n * Given without `coreWasmUrl`, maps load this engine from the start */\n wasmUrl?: string | URL;\n /** Where to load the engine without 3D Tiles from (`isard_core_bg.wasm`, a third smaller), when a bundler does not\n * resolve the default URL. Maps load it first, and the engine with 3D Tiles (`wasmUrl`) for their first 3D Tiles\n * layer only */\n coreWasmUrl?: string | URL;\n /** Where the decoding workers load the point cloud module from (`isard_points_bg.wasm`, the LAZ decoder of COPC),\n * when a bundler does not resolve the default URL. Loaded with the first point cloud only */\n pointsWasmUrl?: string | URL;\n /** Load the engine with 3D Tiles from the start (default false: it is loaded when the first 3D Tiles layer or glTF\n * model is added, the map then moving its camera and layers onto it, a stall of about a frame or two). For a map that shows 3D Tiles\n * at once: one engine downloaded instead of two. `'preload'`: the map starts on the engine without 3D Tiles and\n * downloads and compiles the other once idle, without running it: its first 3D Tiles layer does not wait for the\n * download (for a map that will show 3D Tiles later, on demand) */\n tiles3d?: boolean | 'preload';\n /** Where to load the vector basemap worker from, when a bundler does not resolve the default URL */\n basemapWorkerUrl?: string | URL;\n /** Texture size of the vector basemap's tiles, pixels (default 512: lines and edges sharp at every zoom on a screen\n * of pixel ratio 1). 256: a quarter of the drawing in the workers, of the uploads and of the GPU memory, for lines\n * and edges a little softer between two zoom levels (the tiles are shown 181 to 362 CSS pixels wide) */\n basemapTileSize?: number;\n /** Glyphs of the symbol layers: a URL with `{fontstack}` and `{range}` (MapLibre's glyph format; default\n * OpenFreeMap's fonts, Noto Sans). A vector basemap's labels take the glyphs of its style */\n glyphs?: string;\n /** Workers decoding 3D Tiles off the main thread: a count, or false to decode on the main thread (default: cores - 1,\n * 1 to 4). False (or 0) also decodes the PNG relief and reprojects the equirectangular rasters on the main thread,\n * else done by the vector basemap's workers */\n workers?: number | false;\n /** Where to load the decoding worker from, when a bundler does not resolve the default URL */\n workerUrl?: string | URL;\n /** Folders of the Draco and Basis Universal decoders, loaded by the workers on first use (default: the official\n * builds on gstatic.com and jsDelivr; self-host them for offline or locked-down networks). They run through\n * `new Function`: a Content Security Policy needs `'unsafe-eval'` (see `DecoderUrls`) */\n decoders?: Partial<DecoderUrls>;\n /** Credits at the bottom right: false for none, or its options (default true: the credits of the basemap,\n * hillshade and relief in use, compact on maps narrower than 640 px) */\n attributionControl?: boolean | AttributionOptions;\n}\n\nexport interface TerrainOptions {\n /** One of the Earth's named models (default `'terrain-tiles'` on the Earth); unused with a `url` */\n model?: TerrainModel;\n /** Altitudes of 256 × 256 tiles in `encoding`: a WMS GetMap URL with {bbox} (EPSG:3857 on the Earth, the body's\n * Mercator metres elsewhere: the sphere of its radius), a tile URL with {z}, {x} and {y}, or an ArcGIS image service\n * (a URL ending in `/ImageServer`), asked for raw altitudes in the body's Mercator (default: the `model`'s; on the\n * Moon and Mars, NASA's Trek LOLA and MOLA models) */\n url?: string;\n /** How the tiles of `url` encode their altitudes (default `'float32'`); `'terrarium'` and `'mapbox'` take a URL with\n * {z}, {x} and {y} */\n encoding?: TerrainEncoding;\n /** Vertical exaggeration, 1 for the true relief (default 1) */\n exaggeration?: number;\n /** Finest level of the relief, up to 15 (default 15; 14 for the Terrain Tiles, 8 for the Moon's and Mars's models). It\n * starts at level 6 on the Earth, coarser on bodies of a larger relief for their size (3 on the Moon and Mars) */\n maxZoom?: number;\n /** Altitudes over mainland France raised by the height of the RAF20 geoid (the French one, 0 away from France), to\n * heights above the ellipsoid (those of 3D Tiles); false keeps the altitudes as served (NGF-IGN69 for the IGN's)\n * (default true for the `'ign'` model, false otherwise) */\n geoid?: boolean;\n}\n\n/** Sky, horizon and fog over the plane, with the names and meanings of MapLibre's `setSky` */\nexport interface AtmosphereOptions {\n /** A CSS color (default `#9cc7ec`) */\n skyColor?: string;\n /** (default `#e8f1f8`) */\n horizonColor?: string;\n /** (default `#f2f5f8`) */\n fogColor?: string;\n /** Blend from the horizon to the sky color, share of the field of view above the horizon, 0-1 (default 0.6) */\n skyHorizonBlend?: number;\n /** Blend from the horizon to the fog color below the horizon, 0-1 (default 0.7) */\n horizonFogBlend?: number;\n /** Share of the distance to the far plane over which the ground fades into the fog, 0-1 (default 0.4) */\n fogGroundBlend?: number;\n}\n\n/** Animation of a camera move */\nexport interface AnimationOptions {\n /** Milliseconds */\n duration?: number;\n /** Progress over time, both 0 to 1 */\n easing?: (t: number) => number;\n}\n\nexport interface FlyToOptions extends AnimationOptions {\n /** How far the flight zooms out on its way, as MapLibre's `curve` (default 1.42) */\n curve?: number;\n /** Average speed in screens per second when `duration` is not given (default 1.2) */\n speed?: number;\n}\n\n/**\n * Tile grid of a raster's URL. 'mercator': Web Mercator (XYZ, WMTS PM), the engine's own. 'equirectangular':\n * longitudes and latitudes (Plate Carrée, EPSG:4326-like), two 256 px tiles side by side at level 0, rows from the\n * north (NASA's Trek WMTS, WorldCRS84Quad). A `TileGrid`: the tile matrices of a WMTS in any CRS (Lambert-93…), or a\n * WMS asked for each tile's box in its CRS. The last two are reprojected into Web Mercator tiles by the map's workers\n * (in the page with `workers: false`).\n */\nexport type RasterGrid = 'mercator' | 'equirectangular' | TileGrid;\n\n/** What `RasterLayer.setStyle` changes */\nexport interface RasterStyle {\n opacity: number;\n /** 0 = greyscale, 1 = original colors */\n saturation: number;\n}\n\nexport interface RasterOptions {\n /** Tile URL with {z}, {x} and {y} (256 px tiles); unused with a `loader` */\n url: string;\n /** Tile grid of `url` (default 'mercator'); with 'equirectangular', `minZoom` and `maxZoom` are levels of that\n * grid; with a `TileGrid`, they are map zooms, by default those its matrices span */\n grid?: RasterGrid;\n minZoom?: number;\n maxZoom?: number;\n opacity?: number;\n /** 0 = greyscale, 1 = original colors */\n saturation?: number;\n /** Side of the tiles' textures, pixels (default 256): more for sharper tiles drawn by a `loader` */\n size?: number;\n /** Draws each tile instead of fetching `url`: an image of `size` × `size`, null for nothing there; a rejection is\n * retried like a network error */\n loader?: (z: number, x: number, y: number, signal: AbortSignal) => Promise<ImageBitmap | null>;\n /** Credits of the tiles, HTML: shown by the attribution control while the layer is on the map */\n attribution?: string;\n}\n\nexport interface NetworkStyle {\n /** Line width, CSS pixels, or zoom stops `[[zoom, width], …]` (default 2) */\n width: Size;\n /** Values above are drawn as unreached (default 1800) */\n max: number;\n /** Darker line every `contour` value units, 0 for none (default 0) */\n contour: number;\n opacity: number;\n /** Width of the halo drawn under the lines, CSS pixels or zoom stops, 0 for none (default 0): wide and faint, the\n * reached streets add up into a heat map that fills the blocks */\n halo: Size;\n /** Opacity of the halo at the middle of a line, fading quadratically to its sides (default 0.11) */\n haloOpacity: number;\n /** Colors from 0 to `max`: `[[fraction of max, color], …]` (default green to red) */\n ramp: Ramp | undefined;\n /** Color of the parts beyond `max` or unreached (default `rgba(140, 140, 140, 0.25)`) */\n unreachedColor: string;\n /** Share of `max` over which the colors fade out before it, 0 to 1 (default 0) */\n fade: number;\n}\n\nexport interface NetworkOptions extends Partial<NetworkStyle> {\n /** Node coordinates in degrees: lon0, lat0, lon1, lat1… */\n nodes: Float64Array;\n /** Edges as node index pairs: a0, b0, a1, b1… */\n edges: Uint32Array;\n /** Line of each edge, from A to B: the points of edge e are `points[start[e] .. start[e + 1]]` (lon, lat pairs,\n * counted in points); with fewer than two points an edge is straight. Default: all straight. */\n lines?: { start: Uint32Array; points: Float64Array };\n /** Per edge, the cost of travelling it from A to B then from B to A, in value units (Infinity: closed that way;\n * closed both ways: not drawn). A point along an edge then takes the quickest way there, min(value(A) + cost from\n * A, value(B) + cost from B), as a travel time does. Without costs, values are interpolated along the edges. */\n costs?: Float32Array;\n /** Width factor of each edge (default 1): rail lines wider than streets */\n edgeWidths?: Float32Array;\n}\n\nexport interface Tiles3dStyle {\n /** Screen-space error (CSS pixels) above which a tile is refined: 16 by default, lower is finer and heavier */\n maxScreenSpaceError: number;\n opacity: number;\n /** Size of the points of point cloud tiles (`.pnts`, glTF points), CSS pixels: 2 by default */\n pointSize?: number;\n}\n\nexport interface Tiles3dOptions extends Partial<Tiles3dStyle> {\n /** URL of a `tileset.json` (3D Tiles 1.0 b3dm and pnts, 1.1 glb meshes and points, external tilesets) */\n url: string;\n}\n\nexport interface MapPointerEvent {\n point: Point;\n /** Undefined above the horizon */\n lonLat: LonLat | undefined;\n}\n\n/** What 'hoverfeature' found under the pointer */\nexport interface MapHoverFeatureEvent extends MapPointerEvent {\n /** The feature under the pointer (see `GeoMap.pickFeature`), undefined if none */\n hit: FeatureHit | undefined;\n}\n\n/** A picked feature: its layer handle, its index there and, for line, circle and fill layers, the feature itself */\nexport interface FeatureHit {\n layer: Layer;\n index: number;\n feature: Feature | undefined;\n}\n\nexport interface MapEvents {\n /** The camera started moving (a gesture, an animation or `setCamera`) */\n movestart: Camera;\n /** The camera moved */\n move: Camera;\n /** The camera stopped: no gesture held, no animation running */\n moveend: Camera;\n /** The map changed size (CSS pixels) */\n resize: { width: number; height: number };\n /** The pointer moved over the map (at most once per frame, not while dragging) */\n hover: MapPointerEvent;\n /** What is under the pointer, picked without stalling the GPU: a frame or two after 'hover', only while listened to\n * (radius and layers in `GeoMap.hoverPicking`) */\n hoverfeature: MapHoverFeatureEvent;\n /** Click without drag */\n click: MapPointerEvent;\n /** A frame was drawn; duration of the engine call in milliseconds */\n render: { ms: number };\n /** Everything in view is loaded and drawn, nothing moves: the end of a load, once after each change (as MapLibre's\n * `idle`). Tiles requested by the first frame count, so it never fires before they arrive. */\n idle: Record<string, never>;\n /** The pointer left the canvas (a mouse going out of the map, or onto a control or marker) */\n leave: Record<string, never>;\n}\n\n/** What a layer handle needs from its map */\nexport interface LayerHost {\n readonly engine: Engine;\n requestRender(): void;\n /** Forgets a removed layer */\n detach(layer: object): void;\n /** Moves a layer under `before`, or on top */\n moveLayer(layer: object, before: object | undefined): void;\n /** A layer created again in the engine (new id): put at the place of its old id, which is removed */\n replaceLayer(layer: object, old: number): void;\n}\n"]}
|