@nika-js/onlymap 0.6.0 → 0.6.2
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 +63 -1
- package/README.md +39 -14
- package/THIRD-PARTY-LICENSES.md +27 -0
- package/dist/{LercDecode.es-fbo6h5rt.js → LercDecode.es-BOJJr6Gx.js} +1 -1
- package/dist/{basemap-CprSan9q.js → basemap-BofXgXxy.js} +13 -3
- package/dist/basemap.d.ts +10 -1
- package/dist/cityjson-D_V5GY8b.js +332 -0
- package/dist/clip-box-controller.d.ts +94 -0
- package/dist/clip-box.d.ts +109 -0
- package/dist/crs-Ciu7Xs7a.js +108 -0
- package/dist/crs.d.ts +50 -0
- package/dist/ctx.d.ts +8 -1
- package/dist/data-layer.d.ts +11 -3
- package/dist/draw-controller.d.ts +75 -1
- package/dist/draw.d.ts +22 -4
- package/dist/elements/om-map.d.ts +45 -2
- package/dist/elements/om-overlay.d.ts +13 -1
- package/dist/elements/om-widget.d.ts +4 -0
- package/dist/feature-colors.d.ts +41 -0
- package/dist/geodesy.d.ts +29 -3
- package/dist/{geoparquet-Bm8pfxyo.js → geoparquet-DapHATA0.js} +1 -1
- package/dist/html-data.d.ts +2 -2
- package/dist/ifc-Dc-TdSJr.js +877 -0
- package/dist/ifc.d.ts +406 -0
- package/dist/{index-Bz-rbmhj.js → index-7B-6Cbzu.js} +31619 -26565
- package/dist/{index-DSRIZR81.js → index-BF9iO8Tq.js} +1 -1
- package/dist/{index-GOwMjqm6.js → index-BmX6IId3.js} +1 -1
- package/dist/{index-UzmNhuS0.js → index-SPJVn_n_.js} +1 -1
- package/dist/{index-CCQttJzO.js → index-xmJjZxQJ.js} +2 -2
- package/dist/index.d.ts +13 -2
- package/dist/ir-snapshot.d.ts +3 -1
- package/dist/layer-registry.d.ts +14 -0
- package/dist/layers/bim-layer.d.ts +127 -0
- package/dist/layers/feature-mesh-layer.d.ts +288 -0
- package/dist/layers/gltf-scene-walk.d.ts +55 -0
- package/dist/layers/popup-layer.d.ts +13 -0
- package/dist/legend-spec.d.ts +1 -1
- package/dist/{lerc-CuifOkoA.js → lerc-C6k7EzSN.js} +2 -2
- package/dist/license.d.ts +12 -5
- package/dist/measure-controller.d.ts +458 -4
- package/dist/meshopt_simplifier-Co6uRDDA.js +370 -0
- package/dist/onlymap.standalone.js +57077 -50729
- package/dist/onlymapjs.js +72 -69
- package/dist/parse-manifest.d.ts +3 -0
- package/dist/programmatic.d.ts +39 -5
- package/dist/{raster-dysYIQ_k.js → raster-Cuzhibe2.js} +2 -2
- package/dist/{raster-pipeline-ZdCOGfqV.js → raster-pipeline-DLrnJK8y.js} +1 -1
- package/dist/react/om-layer.d.ts +6 -1
- package/dist/react/om-overlay.d.ts +9 -0
- package/dist/react.js +176 -169
- package/dist/region-export-controller.d.ts +37 -0
- package/dist/region-export.d.ts +56 -0
- package/dist/runtime-core.d.ts +260 -3
- package/dist/selection.d.ts +44 -1
- package/dist/site-placement.d.ts +107 -0
- package/dist/snapping.d.ts +88 -0
- package/dist/terrain-heightfield.d.ts +53 -0
- package/dist/terrain-sample.d.ts +30 -0
- package/dist/terrain.d.ts +6 -1
- package/dist/testing.d.ts +6 -2
- package/dist/tile3d-metadata.d.ts +185 -0
- package/dist/units.d.ts +27 -0
- package/dist/version.d.ts +1 -1
- package/dist/volumetrics-run.d.ts +13 -0
- package/dist/volumetrics-worker.d.ts +1 -0
- package/dist/volumetrics.d.ts +201 -0
- package/dist/widget-registry.d.ts +11 -0
- package/dist/widgets/ifc-clash.d.ts +18 -0
- package/dist/widgets/ifc.d.ts +41 -0
- package/dist/{zarr-OewK7k2K.js → zarr-CUzEX8fB.js} +79 -66
- package/docs/3d-assets.md +48 -0
- package/docs/live-data.md +9 -1
- package/docs/testing.md +4 -2
- package/llms.txt +10 -5
- package/onlymapjs.html-data.json +313 -2
- package/package.json +6 -2
- package/skills/onlymapjs/SKILL.md +14 -2
- package/skills/onlymapjs/references/react.md +2 -2
- package/skills/onlymapjs/references/syntax.md +314 -15
- package/dist/cityjson-urQeujQv.js +0 -407
|
@@ -1,407 +0,0 @@
|
|
|
1
|
-
function P(t, e) {
|
|
2
|
-
if (!Array.isArray(t)) return [];
|
|
3
|
-
const n = e?.scale?.[0] ?? 1, o = e?.scale?.[1] ?? 1, s = e?.scale?.[2] ?? 1, a = e?.translate?.[0] ?? 0, i = e?.translate?.[1] ?? 0, c = e?.translate?.[2] ?? 0, r = new Array(t.length);
|
|
4
|
-
for (let f = 0; f < t.length; f++) {
|
|
5
|
-
const l = t[f];
|
|
6
|
-
r[f] = [l[0] * n + a, l[1] * o + i, (l[2] ?? 0) * s + c];
|
|
7
|
-
}
|
|
8
|
-
return r;
|
|
9
|
-
}
|
|
10
|
-
const T = {
|
|
11
|
-
MultiPoint: 1,
|
|
12
|
-
MultiLineString: 2,
|
|
13
|
-
MultiSurface: 3,
|
|
14
|
-
CompositeSurface: 3,
|
|
15
|
-
Solid: 4,
|
|
16
|
-
MultiSolid: 5,
|
|
17
|
-
CompositeSolid: 5
|
|
18
|
-
};
|
|
19
|
-
function J(t, e) {
|
|
20
|
-
let n = t;
|
|
21
|
-
for (let o = 0; o < e; o++) n = n.flat();
|
|
22
|
-
return n;
|
|
23
|
-
}
|
|
24
|
-
function A(t) {
|
|
25
|
-
const e = T[t.type ?? ""];
|
|
26
|
-
return !e || e < 3 || !Array.isArray(t.boundaries) ? [] : J(t.boundaries, e - 3);
|
|
27
|
-
}
|
|
28
|
-
function X(t, e) {
|
|
29
|
-
const n = new Array(e).fill(void 0), o = T[t.type ?? ""], s = t.semantics?.surfaces, a = t.semantics?.values;
|
|
30
|
-
if (!o || !Array.isArray(s) || !Array.isArray(a)) return n;
|
|
31
|
-
const i = J(a, o - 3);
|
|
32
|
-
for (let c = 0; c < e; c++) {
|
|
33
|
-
const r = i[c];
|
|
34
|
-
typeof r == "number" && (n[c] = s[r]?.type);
|
|
35
|
-
}
|
|
36
|
-
return n;
|
|
37
|
-
}
|
|
38
|
-
function L(t) {
|
|
39
|
-
const e = typeof t == "number" ? t : Number.parseFloat(String(t ?? ""));
|
|
40
|
-
return Number.isFinite(e) ? e : -1;
|
|
41
|
-
}
|
|
42
|
-
function q(t, e) {
|
|
43
|
-
if (!Array.isArray(t)) return;
|
|
44
|
-
const n = t.filter((o) => A(o).length > 0);
|
|
45
|
-
if (n.length !== 0) {
|
|
46
|
-
if (e !== void 0) {
|
|
47
|
-
const o = n.find((s) => L(s.lod) === e);
|
|
48
|
-
if (o) return o;
|
|
49
|
-
}
|
|
50
|
-
return n.reduce((o, s) => L(s.lod) > L(o.lod) ? s : o);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
const K = {
|
|
54
|
-
7415: 28992,
|
|
55
|
-
// Amersfoort / RD New + NAP height — the 3DBAG default
|
|
56
|
-
6697: 6668,
|
|
57
|
-
// JGD2011 geographic 3D + height — the PLATEAU default
|
|
58
|
-
5555: 25832,
|
|
59
|
-
// ETRS89 / UTM 32N + DHHN92 height
|
|
60
|
-
5556: 25833
|
|
61
|
-
// ETRS89 / UTM 33N + DHHN92 height
|
|
62
|
-
}, G = [
|
|
63
|
-
[33, 129.5],
|
|
64
|
-
[33, 131],
|
|
65
|
-
[36, 132.166666666667],
|
|
66
|
-
[33, 133.5],
|
|
67
|
-
[36, 134.333333333333],
|
|
68
|
-
[36, 136],
|
|
69
|
-
[36, 137.166666666667],
|
|
70
|
-
[36, 138.5],
|
|
71
|
-
[36, 139.833333333333],
|
|
72
|
-
[40, 140.833333333333],
|
|
73
|
-
[44, 140.25],
|
|
74
|
-
[44, 142.25],
|
|
75
|
-
[44, 144.25],
|
|
76
|
-
[26, 142],
|
|
77
|
-
[26, 127.5],
|
|
78
|
-
[26, 124],
|
|
79
|
-
[26, 131],
|
|
80
|
-
[20, 136],
|
|
81
|
-
[26, 154]
|
|
82
|
-
], j = {
|
|
83
|
-
// Netherlands — Amersfoort / RD New (3DBAG).
|
|
84
|
-
28992: {
|
|
85
|
-
def: "+proj=sterea +lat_0=52.1561605555556 +lon_0=5.38763888888889 +k=0.9999079 +x_0=155000 +y_0=463000 +ellps=bessel +towgs84=565.4171,50.3319,465.5524,-0.398957,0.343988,-1.8774,4.0725 +units=m +no_defs"
|
|
86
|
-
},
|
|
87
|
-
// Switzerland — CH1903+ / LV95.
|
|
88
|
-
2056: {
|
|
89
|
-
def: "+proj=somerc +lat_0=46.9524055555556 +lon_0=7.43958333333333 +k_0=1 +x_0=2600000 +y_0=1200000 +ellps=bessel +towgs84=674.374,15.056,405.346,0,0,0,0 +units=m +no_defs"
|
|
90
|
-
},
|
|
91
|
-
// Germany — ETRS89 / UTM zones 32N and 33N.
|
|
92
|
-
25832: { def: "+proj=utm +zone=32 +ellps=GRS80 +units=m +no_defs" },
|
|
93
|
-
25833: { def: "+proj=utm +zone=33 +ellps=GRS80 +units=m +no_defs" },
|
|
94
|
-
// Plain WGS84 UTM zones 32N/33N (EPSG:326xx) — the generic, non-European-specific
|
|
95
|
-
// code many CityJSON files declare instead of the ETRS89 pair above (e.g.
|
|
96
|
-
// Ingolstadt's own open-data LoD3 export). Numerically near-identical to
|
|
97
|
-
// 25832/25833 at map-rendering precision (WGS84 vs. ETRS89 differ by ~cm in
|
|
98
|
-
// Europe), so no +towgs84 shift is needed — same bare projection string.
|
|
99
|
-
32632: { def: "+proj=utm +zone=32 +datum=WGS84 +units=m +no_defs" },
|
|
100
|
-
32633: { def: "+proj=utm +zone=33 +datum=WGS84 +units=m +no_defs" },
|
|
101
|
-
// Austria — MGI / Austria GK West/Central/East (the national cadastral
|
|
102
|
-
// system's three meridian-strip zones; Vienna sits in GK East). Same
|
|
103
|
-
// Bessel ellipsoid + towgs84 shift and y_0=-5,000,000 false-northing
|
|
104
|
-
// convention across all three — proj4 strings verified against epsg.io,
|
|
105
|
-
// not hand-derived, and cross-checked by reprojecting a real Vienna
|
|
106
|
-
// open-data file's own extent and confirming it lands in Vienna.
|
|
107
|
-
31254: { def: "+proj=tmerc +lat_0=0 +lon_0=10.3333333333333 +k=1 +x_0=0 +y_0=-5000000 +ellps=bessel +towgs84=577.326,90.129,463.919,5.137,1.474,5.297,2.4232 +units=m +no_defs" },
|
|
108
|
-
31255: { def: "+proj=tmerc +lat_0=0 +lon_0=13.3333333333333 +k=1 +x_0=0 +y_0=-5000000 +ellps=bessel +towgs84=577.326,90.129,463.919,5.137,1.474,5.297,2.4232 +units=m +no_defs" },
|
|
109
|
-
31256: { def: "+proj=tmerc +lat_0=0 +lon_0=16.3333333333333 +k=1 +x_0=0 +y_0=-5000000 +ellps=bessel +towgs84=577.326,90.129,463.919,5.137,1.474,5.297,2.4232 +units=m +no_defs" },
|
|
110
|
-
// Singapore — SVY21 / Singapore TM (the national grid; NUS's own Singapore
|
|
111
|
-
// HDB buildings dataset declares this via metadata.referenceSystem
|
|
112
|
-
// directly, unlike the Austria/3DBAG files, which had none). proj4 string
|
|
113
|
-
// verified against epsg.io, cross-checked by reprojecting a real dataset's
|
|
114
|
-
// own extent and confirming it lands in Singapore (103.68-103.99°E,
|
|
115
|
-
// 1.27-1.46°N — matches).
|
|
116
|
-
3414: { def: "+proj=tmerc +lat_0=1.36666666666667 +lon_0=103.833333333333 +k=1 +x_0=28001.642 +y_0=38744.572 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs" },
|
|
117
|
-
// Japan — JGD2011 geographic 2D. EPSG axis order is (lat, lon).
|
|
118
|
-
6668: { def: "+proj=longlat +ellps=GRS80 +no_defs", geographic: !0, swapXY: !0 },
|
|
119
|
-
// WGS 84. Files in the wild store lon/lat despite EPSG's formal (lat, lon).
|
|
120
|
-
4326: { def: "+proj=longlat +datum=WGS84 +no_defs", geographic: !0 },
|
|
121
|
-
3857: { def: "+proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +no_defs" }
|
|
122
|
-
};
|
|
123
|
-
for (let t = 0; t < G.length; t++) {
|
|
124
|
-
const [e, n] = G[t];
|
|
125
|
-
j[6669 + t] = {
|
|
126
|
-
def: `+proj=tmerc +lat_0=${e} +lon_0=${n} +k=0.9999 +x_0=0 +y_0=0 +ellps=GRS80 +units=m +no_defs`,
|
|
127
|
-
swapXY: !0
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
const Q = /EPSG.*?(\d{4,6})\D*$/i;
|
|
131
|
-
function ee(t) {
|
|
132
|
-
if (!t) return;
|
|
133
|
-
const e = Number(Q.exec(t)?.[1]);
|
|
134
|
-
return Number.isFinite(e) ? e : void 0;
|
|
135
|
-
}
|
|
136
|
-
let x = !1;
|
|
137
|
-
async function k(t, e) {
|
|
138
|
-
const n = { toLngLat: (r, f) => [r, f], projected: !1 }, o = ee(t);
|
|
139
|
-
if (o === void 0)
|
|
140
|
-
return x || (x = !0, console.warn(
|
|
141
|
-
`[onlymapjs] data="${e}": CityJSON has no metadata.referenceSystem — assuming coordinates are already WGS84 lon/lat. Add a referenceSystem to the file if they are not.`
|
|
142
|
-
)), n;
|
|
143
|
-
const s = K[o] ?? o, a = j[s];
|
|
144
|
-
if (!a)
|
|
145
|
-
throw new Error(
|
|
146
|
-
`CityJSON declares EPSG:${o}${s === o ? "" : ` (horizontal component EPSG:${s})`}, which is not one of the bundled coordinate systems (${Object.keys(j).join(", ")}). Reproject the file to EPSG:4326 server-side (cjio --reproject 4326), or claim the URL with OmMap.registerFormat() and supply your own projection.`
|
|
147
|
-
);
|
|
148
|
-
if (a.geographic)
|
|
149
|
-
return a.swapXY ? { toLngLat: (r, f) => [f, r], projected: !1 } : n;
|
|
150
|
-
const i = (await import("./index-CW1n5LdO.js")).default, c = i(a.def, "+proj=longlat +datum=WGS84 +no_defs");
|
|
151
|
-
return {
|
|
152
|
-
toLngLat: (r, f) => {
|
|
153
|
-
const [l, p] = c.forward(a.swapXY ? [f, r] : [r, f]);
|
|
154
|
-
return [l, p];
|
|
155
|
-
},
|
|
156
|
-
projected: !0
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
function F(t) {
|
|
160
|
-
let e = 0, n = 0, o = 0;
|
|
161
|
-
for (let s = 0; s < t.length; s++) {
|
|
162
|
-
const a = t[s], i = t[(s + 1) % t.length];
|
|
163
|
-
e += (a[1] - i[1]) * (a[2] + i[2]), n += (a[2] - i[2]) * (a[0] + i[0]), o += (a[0] - i[0]) * (a[1] + i[1]);
|
|
164
|
-
}
|
|
165
|
-
return Math.hypot(e, n, o) / 2;
|
|
166
|
-
}
|
|
167
|
-
function te(t) {
|
|
168
|
-
const e = t.slice().sort((o, s) => o - s), n = e.length >> 1;
|
|
169
|
-
return e.length % 2 ? e[n] : (e[n - 1] + e[n]) / 2;
|
|
170
|
-
}
|
|
171
|
-
function U(t, e, n, o, s) {
|
|
172
|
-
const a = q(e.geometry, s);
|
|
173
|
-
if (!a) return;
|
|
174
|
-
const i = A(a);
|
|
175
|
-
if (i.length === 0) return;
|
|
176
|
-
const c = X(a, i.length), r = i.map(
|
|
177
|
-
(d) => d.map((m) => m.map((u) => n[u]).filter((u) => u !== void 0))
|
|
178
|
-
);
|
|
179
|
-
let f = 1 / 0, l = -1 / 0;
|
|
180
|
-
for (const d of r)
|
|
181
|
-
for (const m of d)
|
|
182
|
-
for (const [, , u] of m)
|
|
183
|
-
u < f && (f = u), u > l && (l = u);
|
|
184
|
-
if (!Number.isFinite(f)) return;
|
|
185
|
-
const p = f, g = c.some((d) => d === "RoofSurface"), y = [];
|
|
186
|
-
let _ = 1 / 0, h = -1 / 0;
|
|
187
|
-
for (let d = 0; d < r.length; d++)
|
|
188
|
-
if (!(g && c[d] !== "RoofSurface"))
|
|
189
|
-
for (const m of r[d])
|
|
190
|
-
for (const [, , u] of m)
|
|
191
|
-
(g || u > p + 0.5) && (y.push(u), u < _ && (_ = u), u > h && (h = u));
|
|
192
|
-
y.length === 0 && (y.push(l), _ = l, h = l);
|
|
193
|
-
let S = c.indexOf("GroundSurface");
|
|
194
|
-
if (S < 0) {
|
|
195
|
-
let d = -1;
|
|
196
|
-
for (let m = 0; m < r.length; m++) {
|
|
197
|
-
const u = r[m][0];
|
|
198
|
-
if (!u || u.length < 3) continue;
|
|
199
|
-
const b = u.every(([, , v]) => v <= p + 0.5), w = F(u) * (b ? 1e3 : 1);
|
|
200
|
-
w > d && (d = w, S = m);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
if (S < 0) return;
|
|
204
|
-
const O = r[S];
|
|
205
|
-
if (!O[0] || O[0].length < 3) return;
|
|
206
|
-
const [, B] = o.toLngLat(O[0][0][0], O[0][0][1]), Z = 111320 * Math.cos(B * Math.PI / 180), W = 110540, Y = (d) => o.projected ? d : d.map(([m, u, b]) => {
|
|
207
|
-
const [w, v] = o.toLngLat(m, u);
|
|
208
|
-
return [w * Z, v * W, b];
|
|
209
|
-
});
|
|
210
|
-
let R = 0, E = 0;
|
|
211
|
-
for (let d = 0; d < r.length; d++) {
|
|
212
|
-
if (g && c[d] !== "RoofSurface") continue;
|
|
213
|
-
const m = r[d][0];
|
|
214
|
-
if (!m || m.length < 3) continue;
|
|
215
|
-
const u = F(Y(m));
|
|
216
|
-
R += u, E += u * (m.reduce((b, [, , w]) => b + w, 0) / m.length);
|
|
217
|
-
}
|
|
218
|
-
const V = R > 0 ? E / R : te(y), H = {
|
|
219
|
-
cityobject_id: t,
|
|
220
|
-
cityobject_type: e.type ?? "Unknown",
|
|
221
|
-
...e.parents?.[0] !== void 0 ? { parent_id: e.parents[0] } : {},
|
|
222
|
-
...a.lod !== void 0 ? { lod: String(a.lod) } : {},
|
|
223
|
-
ground_height: C(p),
|
|
224
|
-
roof_height: C(V - p),
|
|
225
|
-
eaves_height: C(_ - p),
|
|
226
|
-
ridge_height: C(h - p),
|
|
227
|
-
roof_area: C(R),
|
|
228
|
-
surface_count: i.length
|
|
229
|
-
};
|
|
230
|
-
return { faceRings: r, semantics: c, footprintIndex: S, derived: H };
|
|
231
|
-
}
|
|
232
|
-
function ne(t, e, n, o, s, a) {
|
|
233
|
-
const i = U(t, e, n, o, a);
|
|
234
|
-
if (!i) return;
|
|
235
|
-
const r = i.faceRings[i.footprintIndex].filter((f) => f.length >= 3).map((f) => {
|
|
236
|
-
const l = f.map(([p, g]) => o.toLngLat(p, g));
|
|
237
|
-
return l.push(l[0]), l;
|
|
238
|
-
});
|
|
239
|
-
return {
|
|
240
|
-
type: "Feature",
|
|
241
|
-
id: t,
|
|
242
|
-
geometry: { type: "Polygon", coordinates: r },
|
|
243
|
-
// Source attributes first: the derived names are the ones manifests bind
|
|
244
|
-
// to, so they must be deterministic even against a same-named source field.
|
|
245
|
-
properties: { ...s, ...e.attributes, ...i.derived }
|
|
246
|
-
};
|
|
247
|
-
}
|
|
248
|
-
const I = {
|
|
249
|
-
GroundSurface: "#999999",
|
|
250
|
-
WallSurface: "#ffffff",
|
|
251
|
-
RoofSurface: "#ff0000",
|
|
252
|
-
TrafficArea: "#6e6e6e",
|
|
253
|
-
AuxiliaryTrafficArea: "#2c8200",
|
|
254
|
-
Window: "#0059ff",
|
|
255
|
-
Door: "#640000"
|
|
256
|
-
}, M = {
|
|
257
|
-
Building: "#7497df",
|
|
258
|
-
BuildingPart: "#7497df",
|
|
259
|
-
BuildingInstallation: "#7497df",
|
|
260
|
-
Bridge: "#999999",
|
|
261
|
-
BridgePart: "#999999",
|
|
262
|
-
BridgeInstallation: "#999999",
|
|
263
|
-
BridgeConstructiveElement: "#999999",
|
|
264
|
-
CityObjectGroup: "#ffffb3",
|
|
265
|
-
LandUse: "#ffffb3",
|
|
266
|
-
CityFurniture: "#cc0000",
|
|
267
|
-
GenericCityObject: "#cc0000",
|
|
268
|
-
PlantCover: "#39ac39",
|
|
269
|
-
SolitaryVegetationObject: "#39ac39",
|
|
270
|
-
Railway: "#000000",
|
|
271
|
-
Road: "#999999",
|
|
272
|
-
TransportSquare: "#999999",
|
|
273
|
-
TINRelief: "#ffdb99",
|
|
274
|
-
Tunnel: "#999999",
|
|
275
|
-
TunnelPart: "#999999",
|
|
276
|
-
TunnelInstallation: "#999999",
|
|
277
|
-
WaterBody: "#4da6ff"
|
|
278
|
-
}, oe = "#b0b0b0";
|
|
279
|
-
function re(t, e) {
|
|
280
|
-
return t && I[t] ? I[t] : e && M[e] ? M[e] : oe;
|
|
281
|
-
}
|
|
282
|
-
function ie(t, e, n, o, s, a) {
|
|
283
|
-
const i = U(t, e, n, o, a);
|
|
284
|
-
if (!i) return [];
|
|
285
|
-
const c = [];
|
|
286
|
-
for (let r = 0; r < i.faceRings.length; r++) {
|
|
287
|
-
const f = i.faceRings[r], l = f[0];
|
|
288
|
-
if (!l || l.length < 3) continue;
|
|
289
|
-
const p = f.filter((y) => y.length >= 3).map((y) => y.map(([_, h, S]) => [...o.toLngLat(_, h), S])), g = p[0];
|
|
290
|
-
c.push({
|
|
291
|
-
...s,
|
|
292
|
-
...e.attributes,
|
|
293
|
-
...i.derived,
|
|
294
|
-
surface_type: i.semantics[r],
|
|
295
|
-
fill_color: re(i.semantics[r], e.type),
|
|
296
|
-
polygon: p,
|
|
297
|
-
outline: [...g, g[0]]
|
|
298
|
-
});
|
|
299
|
-
}
|
|
300
|
-
return c;
|
|
301
|
-
}
|
|
302
|
-
function C(t) {
|
|
303
|
-
return Number.isFinite(t) ? Math.round(t * 1e3) / 1e3 : 0;
|
|
304
|
-
}
|
|
305
|
-
function D(t, e, n, o, s = "footprint") {
|
|
306
|
-
if (!t) return [];
|
|
307
|
-
const a = (c) => Array.isArray(c.children) && c.children.some((r) => {
|
|
308
|
-
const f = t[r];
|
|
309
|
-
return f?.type === `${c.type}Part` && (f.geometry?.some((l) => A(l).length > 0) ?? !1);
|
|
310
|
-
}), i = [];
|
|
311
|
-
for (const [c, r] of Object.entries(t)) {
|
|
312
|
-
if (!r || typeof r != "object" || a(r)) continue;
|
|
313
|
-
const l = (r.parents?.[0] ? t[r.parents[0]] : void 0)?.attributes ?? {};
|
|
314
|
-
if (s === "surfaces")
|
|
315
|
-
i.push(...ie(c, r, e, n, l, o));
|
|
316
|
-
else {
|
|
317
|
-
const p = ne(c, r, e, n, l, o);
|
|
318
|
-
p && i.push(p);
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
return i;
|
|
322
|
-
}
|
|
323
|
-
function N(t, e, n) {
|
|
324
|
-
if (t?.type !== n)
|
|
325
|
-
throw new Error(
|
|
326
|
-
`expected a ${n} object but found type="${t?.type ?? "undefined"}" — this does not look like CityJSON. If it is a different newline-delimited format, claim the URL with OmMap.registerFormat().`
|
|
327
|
-
);
|
|
328
|
-
}
|
|
329
|
-
function $(t) {
|
|
330
|
-
const e = /[?&]om-lod=([^&#]+)/.exec(t)?.[1];
|
|
331
|
-
if (e === void 0) return;
|
|
332
|
-
const n = Number.parseFloat(decodeURIComponent(e));
|
|
333
|
-
if (!Number.isFinite(n)) {
|
|
334
|
-
console.warn(`[onlymapjs] om-lod="${e}" is not a number — ignoring and using the highest available LoD.`);
|
|
335
|
-
return;
|
|
336
|
-
}
|
|
337
|
-
return n;
|
|
338
|
-
}
|
|
339
|
-
function z(t) {
|
|
340
|
-
const e = /[?&]om-surfaces=([^&#]+)/.exec(t)?.[1];
|
|
341
|
-
if (e === void 0) return !1;
|
|
342
|
-
const n = decodeURIComponent(e).toLowerCase();
|
|
343
|
-
return n === "1" || n === "true";
|
|
344
|
-
}
|
|
345
|
-
async function ce(t, e) {
|
|
346
|
-
const n = await t.json();
|
|
347
|
-
N(n, e, "CityJSON");
|
|
348
|
-
const o = await k(n.metadata?.referenceSystem, e), s = P(n.vertices, n.transform), a = z(e) ? "surfaces" : "footprint";
|
|
349
|
-
return D(n.CityObjects, s, o, $(e), a);
|
|
350
|
-
}
|
|
351
|
-
const se = 250, ae = 512;
|
|
352
|
-
async function* fe(t) {
|
|
353
|
-
if (!t.body) {
|
|
354
|
-
for (const s of (await t.text()).split(`
|
|
355
|
-
`)) yield s;
|
|
356
|
-
return;
|
|
357
|
-
}
|
|
358
|
-
const e = t.body.getReader(), n = new TextDecoder();
|
|
359
|
-
let o = "";
|
|
360
|
-
for (; ; ) {
|
|
361
|
-
const { done: s, value: a } = await e.read();
|
|
362
|
-
if (s) break;
|
|
363
|
-
o += n.decode(a, { stream: !0 });
|
|
364
|
-
let i;
|
|
365
|
-
for (; (i = o.indexOf(`
|
|
366
|
-
`)) >= 0; )
|
|
367
|
-
yield o.slice(0, i), o = o.slice(i + 1);
|
|
368
|
-
}
|
|
369
|
-
o += n.decode(), o.length > 0 && (yield o);
|
|
370
|
-
}
|
|
371
|
-
async function le(t, e, n) {
|
|
372
|
-
const o = $(e), s = z(e) ? "surfaces" : "footprint";
|
|
373
|
-
let a, i, c = !1;
|
|
374
|
-
const r = [];
|
|
375
|
-
let f = 0, l = 0;
|
|
376
|
-
for await (const p of fe(t)) {
|
|
377
|
-
const g = p.trim();
|
|
378
|
-
if (g.length === 0) continue;
|
|
379
|
-
const y = JSON.parse(g);
|
|
380
|
-
if (c)
|
|
381
|
-
N(y, e, "CityJSONFeature");
|
|
382
|
-
else if (N(y, e, "CityJSON"), i = y.transform, a = await k(y.metadata?.referenceSystem, e), c = !0, y.CityObjects && Object.keys(y.CityObjects).length === 0) continue;
|
|
383
|
-
const _ = P(y.vertices, i);
|
|
384
|
-
r.push(...D(y.CityObjects, _, a, o, s)), f++;
|
|
385
|
-
const h = performance.now();
|
|
386
|
-
(f >= ae || h - l >= se) && (f = 0, l = h, n(r.slice()));
|
|
387
|
-
}
|
|
388
|
-
if (!c)
|
|
389
|
-
throw new Error(
|
|
390
|
-
'CityJSONSeq file is empty or has no header line — the first line must be a CityJSON object carrying "transform" and "metadata", followed by one CityJSONFeature per line.'
|
|
391
|
-
);
|
|
392
|
-
return r;
|
|
393
|
-
}
|
|
394
|
-
export {
|
|
395
|
-
q as chooseGeometry,
|
|
396
|
-
D as decodeCityObjects,
|
|
397
|
-
P as decompressVertices,
|
|
398
|
-
re as defaultFillColor,
|
|
399
|
-
X as faceSemantics,
|
|
400
|
-
A as flattenToFaces,
|
|
401
|
-
ce as parseCityJsonDocument,
|
|
402
|
-
le as parseCityJsonSeq,
|
|
403
|
-
ee as parseEpsgCode,
|
|
404
|
-
$ as parseLodPin,
|
|
405
|
-
z as parseSurfacesFlag,
|
|
406
|
-
k as resolveCrs
|
|
407
|
-
};
|