@math.gl/geospatial 5.0.0-beta.11 → 5.0.0-beta.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/index.cjs +725 -229
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/projection/experimental/core.cjs.map +1 -1
- package/dist/projection/experimental/crs/spatial-reference.d.ts.map +1 -1
- package/dist/projection/experimental/crs/spatial-reference.js.map +1 -1
- package/dist/projection/experimental/crs/types.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/aea.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/aea.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/aea.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/aea.js +4 -1
- package/dist/projection/experimental/lazy-projections/aea.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/bonne.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/bonne.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/bonne.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/bonne.js +4 -1
- package/dist/projection/experimental/lazy-projections/bonne.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/cass.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/cass.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/cass.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/cass.js +4 -1
- package/dist/projection/experimental/lazy-projections/cass.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/eck6.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/eck6.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/eck6.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/eck6.js +4 -1
- package/dist/projection/experimental/lazy-projections/eck6.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/eqdc.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/eqdc.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/eqdc.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/eqdc.js +4 -1
- package/dist/projection/experimental/lazy-projections/eqdc.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/eqearth.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/eqearth.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/eqearth.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/eqearth.js +4 -1
- package/dist/projection/experimental/lazy-projections/eqearth.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/equi.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/equi.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/equi.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/equi.js +4 -1
- package/dist/projection/experimental/lazy-projections/equi.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/geocent.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/geocent.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/geocent.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/geocent.js +4 -1
- package/dist/projection/experimental/lazy-projections/geocent.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/geos.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/geos.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/geos.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/geos.js +4 -1
- package/dist/projection/experimental/lazy-projections/geos.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/gnom.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/gnom.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/gnom.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/gnom.js +4 -1
- package/dist/projection/experimental/lazy-projections/gnom.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/index.cjs +92 -23
- package/dist/projection/experimental/lazy-projections/index.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/krovak.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/krovak.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/krovak.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/krovak.js +4 -1
- package/dist/projection/experimental/lazy-projections/krovak.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/merc.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/merc.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/merc.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/merc.js +4 -1
- package/dist/projection/experimental/lazy-projections/merc.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/mill.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/mill.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/mill.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/mill.js +4 -1
- package/dist/projection/experimental/lazy-projections/mill.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/moll.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/moll.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/moll.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/moll.js +4 -1
- package/dist/projection/experimental/lazy-projections/moll.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/nzmg.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/nzmg.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/nzmg.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/nzmg.js +4 -1
- package/dist/projection/experimental/lazy-projections/nzmg.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/omerc.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/omerc.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/omerc.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/omerc.js +4 -1
- package/dist/projection/experimental/lazy-projections/omerc.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/ortho.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/ortho.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/ortho.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/ortho.js +4 -1
- package/dist/projection/experimental/lazy-projections/ortho.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/poly.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/poly.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/poly.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/poly.js +4 -1
- package/dist/projection/experimental/lazy-projections/poly.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/robin.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/robin.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/robin.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/robin.js +4 -1
- package/dist/projection/experimental/lazy-projections/robin.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/sinu.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/sinu.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/sinu.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/sinu.js +4 -1
- package/dist/projection/experimental/lazy-projections/sinu.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/stere.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/stere.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/stere.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/stere.js +4 -1
- package/dist/projection/experimental/lazy-projections/stere.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/tpers.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/tpers.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/tpers.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/tpers.js +4 -1
- package/dist/projection/experimental/lazy-projections/tpers.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/vandg.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/vandg.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/vandg.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/vandg.js +4 -1
- package/dist/projection/experimental/lazy-projections/vandg.js.map +1 -1
- package/dist/projection/index.cjs.map +1 -1
- package/dist/projection/index.d.ts.map +1 -1
- package/dist/projection/index.js.map +1 -1
- package/dist/projection/lib/projection.js.map +1 -1
- package/dist/projection/pipeline.cjs.map +1 -1
- package/dist/projection/transform-analysis.cjs.map +1 -1
- package/dist/tasks/index.cjs.map +1 -1
- package/dist/terrain/cutout-polygons.d.ts +21 -0
- package/dist/terrain/cutout-polygons.d.ts.map +1 -0
- package/dist/terrain/cutout-polygons.js +172 -0
- package/dist/terrain/cutout-polygons.js.map +1 -0
- package/dist/terrain/cutout-region.d.ts +34 -0
- package/dist/terrain/cutout-region.d.ts.map +1 -0
- package/dist/terrain/cutout-region.js +33 -0
- package/dist/terrain/cutout-region.js.map +1 -0
- package/dist/terrain/geographic-cutout.d.ts +38 -0
- package/dist/terrain/geographic-cutout.d.ts.map +1 -0
- package/dist/terrain/geographic-cutout.js +120 -0
- package/dist/terrain/geographic-cutout.js.map +1 -0
- package/dist/terrain/index.cjs +532 -36
- package/dist/terrain/index.cjs.map +3 -3
- package/dist/terrain/index.d.ts +5 -0
- package/dist/terrain/index.d.ts.map +1 -1
- package/dist/terrain/index.js +4 -0
- package/dist/terrain/index.js.map +1 -1
- package/dist/terrain/mesh-cutout.d.ts +10 -5
- package/dist/terrain/mesh-cutout.d.ts.map +1 -1
- package/dist/terrain/mesh-cutout.js +62 -20
- package/dist/terrain/mesh-cutout.js.map +1 -1
- package/dist/terrain/tile-cutout-update.d.ts +73 -0
- package/dist/terrain/tile-cutout-update.d.ts.map +1 -0
- package/dist/terrain/tile-cutout-update.js +181 -0
- package/dist/terrain/tile-cutout-update.js.map +1 -0
- package/dist/terrain/tile-cutout.d.ts +33 -0
- package/dist/terrain/tile-cutout.d.ts.map +1 -0
- package/dist/terrain/tile-cutout.js +93 -0
- package/dist/terrain/tile-cutout.js.map +1 -0
- package/dist/turf/expressions.cjs +4 -4
- package/dist/turf/expressions.cjs.map +2 -2
- package/dist/turf/expressions.d.ts +1 -1
- package/dist/turf/expressions.d.ts.map +1 -1
- package/dist/turf/expressions.js +2 -2
- package/dist/turf/expressions.js.map +1 -1
- package/dist/turf.cjs +25 -25
- package/dist/turf.cjs.map +2 -2
- package/dist/turf.d.ts +1 -1
- package/dist/turf.d.ts.map +1 -1
- package/dist/turf.js +2 -2
- package/dist/turf.js.map +1 -1
- package/dist/web-mercator/assert.d.ts +2 -0
- package/dist/web-mercator/assert.d.ts.map +1 -0
- package/dist/web-mercator/assert.js +12 -0
- package/dist/web-mercator/assert.js.map +1 -0
- package/dist/web-mercator/fit-bounds.d.ts +52 -0
- package/dist/web-mercator/fit-bounds.d.ts.map +1 -0
- package/dist/web-mercator/fit-bounds.js +70 -0
- package/dist/web-mercator/fit-bounds.js.map +1 -0
- package/dist/web-mercator/fly-to-viewport.d.ts +19 -0
- package/dist/web-mercator/fly-to-viewport.d.ts.map +1 -0
- package/dist/web-mercator/fly-to-viewport.js +94 -0
- package/dist/web-mercator/fly-to-viewport.js.map +1 -0
- package/dist/web-mercator/get-bounds.d.ts +3 -0
- package/dist/web-mercator/get-bounds.d.ts.map +1 -0
- package/dist/web-mercator/get-bounds.js +56 -0
- package/dist/web-mercator/get-bounds.js.map +1 -0
- package/dist/web-mercator/index.cjs +705 -0
- package/dist/web-mercator/index.cjs.map +6 -0
- package/dist/web-mercator/index.d.ts +14 -0
- package/dist/web-mercator/index.d.ts.map +1 -0
- package/dist/web-mercator/index.js +14 -0
- package/dist/web-mercator/index.js.map +1 -0
- package/dist/web-mercator/math-utils.d.ts +7 -0
- package/dist/web-mercator/math-utils.d.ts.map +1 -0
- package/dist/web-mercator/math-utils.js +30 -0
- package/dist/web-mercator/math-utils.js.map +1 -0
- package/dist/web-mercator/mercator-meters.d.ts +29 -0
- package/dist/web-mercator/mercator-meters.d.ts.map +1 -0
- package/dist/web-mercator/mercator-meters.js +61 -0
- package/dist/web-mercator/mercator-meters.js.map +1 -0
- package/dist/web-mercator/normalize-viewport-props.d.ts +16 -0
- package/dist/web-mercator/normalize-viewport-props.d.ts.map +1 -0
- package/dist/web-mercator/normalize-viewport-props.js +45 -0
- package/dist/web-mercator/normalize-viewport-props.js.map +1 -0
- package/dist/web-mercator/web-mercator-utils.d.ts +192 -0
- package/dist/web-mercator/web-mercator-utils.d.ts.map +1 -0
- package/dist/web-mercator/web-mercator-utils.js +321 -0
- package/dist/web-mercator/web-mercator-utils.js.map +1 -0
- package/dist/web-mercator/web-mercator-viewport.d.ts +177 -0
- package/dist/web-mercator/web-mercator-viewport.d.ts.map +1 -0
- package/dist/web-mercator/web-mercator-viewport.js +276 -0
- package/dist/web-mercator/web-mercator-viewport.js.map +1 -0
- package/dist/web-mercator.d.ts +1 -1
- package/dist/web-mercator.d.ts.map +1 -1
- package/dist/web-mercator.js +1 -1
- package/dist/web-mercator.js.map +1 -1
- package/package.json +19 -458
- package/src/index.ts +36 -5
- package/src/projection/experimental/crs/spatial-reference.ts +1 -6
- package/src/projection/experimental/crs/types.ts +1 -1
- package/src/projection/experimental/crs/wkt.ts +1 -1
- package/src/projection/experimental/crs-descriptor.ts +1 -1
- package/src/projection/experimental/lazy-projections/aea.ts +4 -1
- package/src/projection/experimental/lazy-projections/bonne.ts +4 -1
- package/src/projection/experimental/lazy-projections/cass.ts +4 -1
- package/src/projection/experimental/lazy-projections/eck6.ts +4 -1
- package/src/projection/experimental/lazy-projections/eqdc.ts +4 -1
- package/src/projection/experimental/lazy-projections/eqearth.ts +4 -1
- package/src/projection/experimental/lazy-projections/equi.ts +4 -1
- package/src/projection/experimental/lazy-projections/geocent.ts +4 -1
- package/src/projection/experimental/lazy-projections/geos.ts +4 -1
- package/src/projection/experimental/lazy-projections/gnom.ts +4 -1
- package/src/projection/experimental/lazy-projections/krovak.ts +4 -1
- package/src/projection/experimental/lazy-projections/merc.ts +4 -1
- package/src/projection/experimental/lazy-projections/mill.ts +4 -1
- package/src/projection/experimental/lazy-projections/moll.ts +4 -1
- package/src/projection/experimental/lazy-projections/nzmg.ts +4 -1
- package/src/projection/experimental/lazy-projections/omerc.ts +4 -1
- package/src/projection/experimental/lazy-projections/ortho.ts +4 -1
- package/src/projection/experimental/lazy-projections/poly.ts +4 -1
- package/src/projection/experimental/lazy-projections/robin.ts +4 -1
- package/src/projection/experimental/lazy-projections/sinu.ts +4 -1
- package/src/projection/experimental/lazy-projections/stere.ts +4 -1
- package/src/projection/experimental/lazy-projections/tpers.ts +4 -1
- package/src/projection/experimental/lazy-projections/vandg.ts +4 -1
- package/src/projection/index.ts +1 -1
- package/src/projection/lib/projection.ts +1 -1
- package/src/terrain/cutout-polygons.ts +202 -0
- package/src/terrain/cutout-region.ts +54 -0
- package/src/terrain/geographic-cutout.ts +154 -0
- package/src/terrain/index.ts +24 -0
- package/src/terrain/mesh-cutout.ts +85 -23
- package/src/terrain/tile-cutout-update.ts +293 -0
- package/src/terrain/tile-cutout.ts +123 -0
- package/src/turf/expressions.ts +2 -2
- package/src/turf.ts +3 -7
- package/src/web-mercator/assert.ts +11 -0
- package/src/web-mercator/fit-bounds.ts +132 -0
- package/src/web-mercator/fly-to-viewport.ts +157 -0
- package/src/web-mercator/get-bounds.ts +62 -0
- package/src/web-mercator/index.ts +49 -0
- package/src/web-mercator/math-utils.ts +35 -0
- package/src/web-mercator/mercator-meters.ts +83 -0
- package/src/web-mercator/normalize-viewport-props.ts +58 -0
- package/src/web-mercator/web-mercator-utils.ts +468 -0
- package/src/web-mercator/web-mercator-viewport.ts +406 -0
- package/src/web-mercator.ts +1 -1
- package/dist/projection/experimental/index.cjs +0 -11707
- package/dist/projection/experimental/index.cjs.map +0 -6
package/dist/index.cjs
CHANGED
|
@@ -98,6 +98,7 @@ __export(index_exports, {
|
|
|
98
98
|
createCRSProjectionDomain: () => createCRSProjectionDomain,
|
|
99
99
|
createCRSResolver: () => createCRSResolver,
|
|
100
100
|
createDelatinTerrainMesh: () => createDelatinTerrainMesh,
|
|
101
|
+
createGeographicTerrainCutoutFrame: () => createGeographicTerrainCutoutFrame,
|
|
101
102
|
createMartiniTerrainMesh: () => createMartiniTerrainMesh,
|
|
102
103
|
createOctahedralCutAtlas: () => createOctahedralCutAtlas,
|
|
103
104
|
createOctahedralCutGraph: () => createOctahedralCutGraph,
|
|
@@ -182,6 +183,8 @@ __export(index_exports, {
|
|
|
182
183
|
parsePROJString: () => parsePROJString,
|
|
183
184
|
parseWKTCRS: () => parseWKTCRS,
|
|
184
185
|
pixelsToWorld: () => web_mercator_exports.pixelsToWorld,
|
|
186
|
+
prepareTerrainCutoutPolygons: () => prepareTerrainCutoutPolygons,
|
|
187
|
+
projectGeographicTerrainCutout: () => projectGeographicTerrainCutout,
|
|
185
188
|
projectGrid: () => projectGrid,
|
|
186
189
|
reconcileTerrainVertexTiles: () => reconcileTerrainVertexTiles,
|
|
187
190
|
resolveTileIndex: () => resolveTileIndex,
|
|
@@ -196,6 +199,7 @@ __export(index_exports, {
|
|
|
196
199
|
splitGlobeBounds: () => splitGlobeBounds,
|
|
197
200
|
splitTerrainBreaklines: () => splitTerrainBreaklines,
|
|
198
201
|
splitTerrainMesh: () => splitTerrainMesh,
|
|
202
|
+
splitTerrainMeshTiles: () => splitTerrainMeshTiles,
|
|
199
203
|
standardGridZone: () => standardGridZone,
|
|
200
204
|
stitchTerrainContourTiles: () => stitchTerrainContourTiles,
|
|
201
205
|
stitchTerrainContours: () => stitchTerrainContours,
|
|
@@ -220,6 +224,7 @@ __export(index_exports, {
|
|
|
220
224
|
transferGrid: () => transferGrid,
|
|
221
225
|
unitsPerMeter: () => web_mercator_exports.unitsPerMeter,
|
|
222
226
|
unpackTerrainHeightField: () => unpackTerrainHeightField,
|
|
227
|
+
unprojectGeographicTerrainCutout: () => unprojectGeographicTerrainCutout,
|
|
223
228
|
unprojectGrid: () => unprojectGrid,
|
|
224
229
|
updateTerrainBounds: () => updateTerrainBounds,
|
|
225
230
|
updateTerrainBoundsRegions: () => updateTerrainBoundsRegions,
|
|
@@ -233,6 +238,7 @@ __export(index_exports, {
|
|
|
233
238
|
updateTerrainMixedVertexTileHalos: () => updateTerrainMixedVertexTileHalos,
|
|
234
239
|
updateTerrainPersistentBounds: () => updateTerrainPersistentBounds,
|
|
235
240
|
updateTerrainPersistentGradients: () => updateTerrainPersistentGradients,
|
|
241
|
+
updateTerrainTileCutouts: () => updateTerrainTileCutouts,
|
|
236
242
|
updateTerrainValidDomainMeshRegions: () => updateTerrainValidDomainMeshRegions,
|
|
237
243
|
updateTerrainVertexTileHalos: () => updateTerrainVertexTileHalos,
|
|
238
244
|
validateTileMatrix: () => validateTileMatrix,
|
|
@@ -299,9 +305,9 @@ function fromCartographic(cartographic, result = [], map = identity) {
|
|
|
299
305
|
function fromCartographicToRadians(cartographic, vector2 = []) {
|
|
300
306
|
return fromCartographic(cartographic, vector2, import_core.config._cartographicRadians ? identity : import_core.toRadians);
|
|
301
307
|
}
|
|
302
|
-
function toCartographicFromRadiansComponents(longitude,
|
|
308
|
+
function toCartographicFromRadiansComponents(longitude, latitude2, height, cartographic) {
|
|
303
309
|
const map = import_core.config._cartographicRadians ? identity : import_core.toDegrees;
|
|
304
|
-
const mappedLongitude = map(longitude), mappedLatitude = map(
|
|
310
|
+
const mappedLongitude = map(longitude), mappedLatitude = map(latitude2);
|
|
305
311
|
if ("longitude" in cartographic) {
|
|
306
312
|
cartographic.longitude = mappedLongitude;
|
|
307
313
|
cartographic.latitude = mappedLatitude;
|
|
@@ -619,12 +625,12 @@ var Ellipsoid = class _Ellipsoid {
|
|
|
619
625
|
}
|
|
620
626
|
cartographicToCartesian(cartographic, result = [0, 0, 0]) {
|
|
621
627
|
const llh = fromCartographicToRadians(cartographic, scratchCartesian);
|
|
622
|
-
const longitude = llh[0],
|
|
623
|
-
if (!Number.isFinite(longitude) || !Number.isFinite(
|
|
628
|
+
const longitude = llh[0], latitude2 = llh[1], height = llh[2];
|
|
629
|
+
if (!Number.isFinite(longitude) || !Number.isFinite(latitude2) || !Number.isFinite(height) || !(this.minimumRadius > 0) || !Number.isFinite(this.maximumRadius * this.maximumRadius))
|
|
624
630
|
return void 0;
|
|
625
|
-
if (this.spheroidGeometry && (import_core3.config._cartographicRadians || Math.abs(
|
|
631
|
+
if (this.spheroidGeometry && (import_core3.config._cartographicRadians || Math.abs(latitude2) <= Math.PI / 4)) {
|
|
626
632
|
spheroidScratch.x = longitude;
|
|
627
|
-
spheroidScratch.y =
|
|
633
|
+
spheroidScratch.y = latitude2;
|
|
628
634
|
spheroidScratch.z = height;
|
|
629
635
|
if (!(0, import_core4.spheroidToCartesian)(spheroidScratch, this.spheroidGeometry))
|
|
630
636
|
return void 0;
|
|
@@ -675,9 +681,9 @@ var Ellipsoid = class _Ellipsoid {
|
|
|
675
681
|
return void 0;
|
|
676
682
|
const nx = gx / length, ny = gy / length, nz = gz / length;
|
|
677
683
|
const longitude = Math.atan2(ny, nx);
|
|
678
|
-
const
|
|
684
|
+
const latitude2 = Math.atan2(nz, Math.hypot(nx, ny));
|
|
679
685
|
const height = (x - point2[0]) * nx + (y - point2[1]) * ny + (z - point2[2]) * nz;
|
|
680
|
-
return toCartographicFromRadiansComponents(longitude,
|
|
686
|
+
return toCartographicFromRadiansComponents(longitude, latitude2, height, result);
|
|
681
687
|
}
|
|
682
688
|
geocentricSurfaceNormal(cartesian, result = [0, 0, 0]) {
|
|
683
689
|
fromCartographic(cartesian, scratchVector2);
|
|
@@ -687,11 +693,11 @@ var Ellipsoid = class _Ellipsoid {
|
|
|
687
693
|
geodeticSurfaceNormalCartographic(cartographic, result = [0, 0, 0]) {
|
|
688
694
|
const point2 = fromCartographic(cartographic, scratchCartesian);
|
|
689
695
|
const longitude = import_core3.config._cartographicRadians ? point2[0] : point2[0] * Math.PI / 180;
|
|
690
|
-
const
|
|
696
|
+
const latitude2 = import_core3.config._cartographicRadians ? point2[1] : point2[1] * Math.PI / 180;
|
|
691
697
|
const polarDegrees = !import_core3.config._cartographicRadians && Math.abs(point2[1]) > 45;
|
|
692
698
|
const complement = (90 - Math.abs(point2[1])) * Math.PI / 180;
|
|
693
|
-
const cosLatitude = polarDegrees ? Math.sin(complement) : Math.abs(
|
|
694
|
-
const sinLatitude = polarDegrees ? Math.sign(point2[1]) * Math.cos(complement) : Math.sin(
|
|
699
|
+
const cosLatitude = polarDegrees ? Math.sin(complement) : Math.abs(latitude2) === Math.PI / 2 ? 0 : Math.cos(latitude2);
|
|
700
|
+
const sinLatitude = polarDegrees ? Math.sign(point2[1]) * Math.cos(complement) : Math.sin(latitude2);
|
|
695
701
|
return normalResult(cosLatitude * Math.cos(longitude), cosLatitude * Math.sin(longitude), sinLatitude, result);
|
|
696
702
|
}
|
|
697
703
|
geodeticSurfaceNormal(cartesian, result = [0, 0, 0]) {
|
|
@@ -2445,17 +2451,17 @@ var EllipsoidGeodesic = class {
|
|
|
2445
2451
|
validatePoint(lat2, lon2);
|
|
2446
2452
|
return this.engine.Inverse(lat1, lon1, lat2, lon2, outputMask(options));
|
|
2447
2453
|
}
|
|
2448
|
-
direct(
|
|
2449
|
-
return this.line(
|
|
2454
|
+
direct(latitude2, longitude, azimuth, distance, options = {}) {
|
|
2455
|
+
return this.line(latitude2, longitude, azimuth, options).position(distance);
|
|
2450
2456
|
}
|
|
2451
|
-
arcDirect(
|
|
2452
|
-
return this.line(
|
|
2457
|
+
arcDirect(latitude2, longitude, azimuth, arc, options = {}) {
|
|
2458
|
+
return this.line(latitude2, longitude, azimuth, options).arcPosition(arc);
|
|
2453
2459
|
}
|
|
2454
|
-
line(
|
|
2455
|
-
validatePoint(
|
|
2460
|
+
line(latitude2, longitude, azimuth, options = {}) {
|
|
2461
|
+
validatePoint(latitude2, longitude);
|
|
2456
2462
|
validateFinite(azimuth);
|
|
2457
2463
|
const selectedMask = outputMask(options);
|
|
2458
|
-
const line = this.engine.Line(
|
|
2464
|
+
const line = this.engine.Line(latitude2, longitude, azimuth, selectedMask | library.DISTANCE_IN);
|
|
2459
2465
|
return {
|
|
2460
2466
|
// Fourth argument is an internal result request; ordinary Array.map arguments remain ignored.
|
|
2461
2467
|
position(distance, _index, _array, output2) {
|
|
@@ -2469,8 +2475,8 @@ var EllipsoidGeodesic = class {
|
|
|
2469
2475
|
};
|
|
2470
2476
|
}
|
|
2471
2477
|
};
|
|
2472
|
-
function validatePoint(
|
|
2473
|
-
if (!(Number.isFinite(
|
|
2478
|
+
function validatePoint(latitude2, longitude) {
|
|
2479
|
+
if (!(Number.isFinite(latitude2) && Math.abs(latitude2) <= 90 && Number.isFinite(longitude))) {
|
|
2474
2480
|
throw new Error("Invalid geodesic coordinates");
|
|
2475
2481
|
}
|
|
2476
2482
|
}
|
|
@@ -2728,36 +2734,36 @@ var EllipsoidMetrics = class {
|
|
|
2728
2734
|
}
|
|
2729
2735
|
Object.freeze(this);
|
|
2730
2736
|
}
|
|
2731
|
-
meridianDistance(
|
|
2732
|
-
validateLatitude(
|
|
2733
|
-
return Math.sign(
|
|
2737
|
+
meridianDistance(latitude2) {
|
|
2738
|
+
validateLatitude(latitude2);
|
|
2739
|
+
return Math.sign(latitude2) * this.semiMajorAxis * this.meridian(Math.abs(latitude2));
|
|
2734
2740
|
}
|
|
2735
|
-
meridionalCurvatureRadius(
|
|
2736
|
-
validateLatitude(
|
|
2737
|
-
return this.semiMajorAxis * this.meridianIntegrand(
|
|
2741
|
+
meridionalCurvatureRadius(latitude2) {
|
|
2742
|
+
validateLatitude(latitude2);
|
|
2743
|
+
return this.semiMajorAxis * this.meridianIntegrand(latitude2 * DEG);
|
|
2738
2744
|
}
|
|
2739
|
-
transverseCurvatureRadius(
|
|
2740
|
-
validateLatitude(
|
|
2741
|
-
const [s, c] = sincos(
|
|
2745
|
+
transverseCurvatureRadius(latitude2) {
|
|
2746
|
+
validateLatitude(latitude2);
|
|
2747
|
+
const [s, c] = sincos(latitude2);
|
|
2742
2748
|
return this.semiMajorAxis / Math.hypot(c, this.ratio * s);
|
|
2743
2749
|
}
|
|
2744
|
-
normalCurvatureRadius(
|
|
2750
|
+
normalCurvatureRadius(latitude2, azimuth) {
|
|
2745
2751
|
if (!Number.isFinite(azimuth))
|
|
2746
2752
|
throw new Error("Azimuth must be finite");
|
|
2747
2753
|
const [s, c] = sincos(azimuth % 180);
|
|
2748
|
-
return 1 / (c * c / this.meridionalCurvatureRadius(
|
|
2754
|
+
return 1 / (c * c / this.meridionalCurvatureRadius(latitude2) + s * s / this.transverseCurvatureRadius(latitude2));
|
|
2749
2755
|
}
|
|
2750
|
-
latitudeToAuxiliary(
|
|
2756
|
+
latitudeToAuxiliary(latitude2, kind) {
|
|
2751
2757
|
validateKind(kind);
|
|
2752
|
-
validateLatitude(
|
|
2753
|
-
if (
|
|
2754
|
-
return
|
|
2755
|
-
if (Math.abs(
|
|
2756
|
-
return kind === "isometric" ? Math.sign(
|
|
2758
|
+
validateLatitude(latitude2);
|
|
2759
|
+
if (latitude2 === 0)
|
|
2760
|
+
return latitude2;
|
|
2761
|
+
if (Math.abs(latitude2) === 90)
|
|
2762
|
+
return kind === "isometric" ? Math.sign(latitude2) * Infinity : latitude2;
|
|
2757
2763
|
if (this.ratio === 1 && kind !== "isometric")
|
|
2758
|
-
return
|
|
2759
|
-
const sign2 = Math.sign(
|
|
2760
|
-
const phi = Math.abs(
|
|
2764
|
+
return latitude2;
|
|
2765
|
+
const sign2 = Math.sign(latitude2);
|
|
2766
|
+
const phi = Math.abs(latitude2);
|
|
2761
2767
|
const [s, c] = sincos(phi);
|
|
2762
2768
|
switch (kind) {
|
|
2763
2769
|
case "geocentric":
|
|
@@ -2784,21 +2790,21 @@ var EllipsoidMetrics = class {
|
|
|
2784
2790
|
}
|
|
2785
2791
|
}
|
|
2786
2792
|
}
|
|
2787
|
-
latitudeFromAuxiliary(
|
|
2793
|
+
latitudeFromAuxiliary(latitude2, kind) {
|
|
2788
2794
|
validateKind(kind);
|
|
2789
|
-
if (kind === "isometric" && Math.abs(
|
|
2790
|
-
return Math.sign(
|
|
2795
|
+
if (kind === "isometric" && Math.abs(latitude2) === Infinity)
|
|
2796
|
+
return Math.sign(latitude2) * 90;
|
|
2791
2797
|
if (kind !== "isometric")
|
|
2792
|
-
validateLatitude(
|
|
2793
|
-
else if (!Number.isFinite(
|
|
2798
|
+
validateLatitude(latitude2);
|
|
2799
|
+
else if (!Number.isFinite(latitude2))
|
|
2794
2800
|
throw new Error("Isometric latitude must be finite or a pole infinity");
|
|
2795
|
-
if (
|
|
2796
|
-
return
|
|
2797
|
-
if (kind !== "isometric" && Math.abs(
|
|
2798
|
-
return
|
|
2801
|
+
if (latitude2 === 0)
|
|
2802
|
+
return latitude2;
|
|
2803
|
+
if (kind !== "isometric" && Math.abs(latitude2) === 90)
|
|
2804
|
+
return latitude2;
|
|
2799
2805
|
if (this.ratio === 1 && kind !== "isometric")
|
|
2800
|
-
return
|
|
2801
|
-
const sign2 = Math.sign(
|
|
2806
|
+
return latitude2;
|
|
2807
|
+
const sign2 = Math.sign(latitude2), target = Math.abs(latitude2);
|
|
2802
2808
|
if (kind === "geocentric" || kind === "parametric") {
|
|
2803
2809
|
const [s, c] = sincos(target);
|
|
2804
2810
|
return sign2 * angle(s, c * (kind === "geocentric" ? this.ratio ** 2 : this.ratio));
|
|
@@ -2885,12 +2891,12 @@ var SurfacePolygon = class {
|
|
|
2885
2891
|
this.area = new Accumulator();
|
|
2886
2892
|
return this;
|
|
2887
2893
|
}
|
|
2888
|
-
addPoint(
|
|
2889
|
-
if (!(Number.isFinite(
|
|
2894
|
+
addPoint(latitude2, longitude, options = {}) {
|
|
2895
|
+
if (!(Number.isFinite(latitude2) && Math.abs(latitude2) <= 90 && Number.isFinite(longitude))) {
|
|
2890
2896
|
throw new Error("Polygon point requires finite longitude and latitude in [-90, 90]");
|
|
2891
2897
|
}
|
|
2892
2898
|
if (this.count) {
|
|
2893
|
-
const edge2 = this.geodesic.inverse(this.lastLat, this.lastLon,
|
|
2899
|
+
const edge2 = this.geodesic.inverse(this.lastLat, this.lastLon, latitude2, longitude, {
|
|
2894
2900
|
area: !this.polyline,
|
|
2895
2901
|
longitudeTurns: options.longitudeTurns,
|
|
2896
2902
|
unrollLongitude: Boolean(options.longitudeTurns)
|
|
@@ -2900,10 +2906,10 @@ var SurfacePolygon = class {
|
|
|
2900
2906
|
this.crossings = (this.crossings + (options.longitudeTurns ? transitDirect(this.lastLon, edge2.lon2) : transit(this.lastLon, longitude))) % 2;
|
|
2901
2907
|
}
|
|
2902
2908
|
} else {
|
|
2903
|
-
this.firstLat =
|
|
2909
|
+
this.firstLat = latitude2;
|
|
2904
2910
|
this.firstLon = longitude;
|
|
2905
2911
|
}
|
|
2906
|
-
this.lastLat =
|
|
2912
|
+
this.lastLat = latitude2;
|
|
2907
2913
|
this.lastLon = longitude;
|
|
2908
2914
|
++this.count;
|
|
2909
2915
|
return this;
|
|
@@ -2957,8 +2963,8 @@ var SurfacePolygon = class {
|
|
|
2957
2963
|
return { number: this.count, perimeter: this.perimeter.Sum(edge2.s12), area: 0 + total.Sum() };
|
|
2958
2964
|
}
|
|
2959
2965
|
/** Nonmutating preview, with the same compensated arithmetic as insertion. */
|
|
2960
|
-
testPoint(
|
|
2961
|
-
return this.copy().addPoint(
|
|
2966
|
+
testPoint(latitude2, longitude, options = {}) {
|
|
2967
|
+
return this.copy().addPoint(latitude2, longitude, options).compute(options);
|
|
2962
2968
|
}
|
|
2963
2969
|
testEdge(azimuth, distance, options = {}) {
|
|
2964
2970
|
return this.copy().addEdge(azimuth, distance).compute(options);
|
|
@@ -2996,8 +3002,8 @@ var GeodesicPolygon = class extends SurfacePolygon {
|
|
|
2996
3002
|
constructor(parameters, options = {}) {
|
|
2997
3003
|
super(new EllipsoidGeodesic(parameters), options);
|
|
2998
3004
|
}
|
|
2999
|
-
addPoint(
|
|
3000
|
-
return super.addPoint(
|
|
3005
|
+
addPoint(latitude2, longitude) {
|
|
3006
|
+
return super.addPoint(latitude2, longitude);
|
|
3001
3007
|
}
|
|
3002
3008
|
};
|
|
3003
3009
|
|
|
@@ -3028,13 +3034,13 @@ function sc(x) {
|
|
|
3028
3034
|
}
|
|
3029
3035
|
return [s, c];
|
|
3030
3036
|
}
|
|
3031
|
-
function remainingPoleDistance(a, b,
|
|
3037
|
+
function remainingPoleDistance(a, b, latitude2, azimuth, distance, sign2) {
|
|
3032
3038
|
const unit3 = 2 ** Math.floor(Math.log2(a));
|
|
3033
3039
|
a /= unit3;
|
|
3034
3040
|
b /= unit3;
|
|
3035
3041
|
distance /= unit3;
|
|
3036
3042
|
const ratio2 = div(exact(b), exact(a));
|
|
3037
|
-
const theta = mul(90n * Q - BigInt(sign2) * exact(
|
|
3043
|
+
const theta = mul(90n * Q - BigInt(sign2) * exact(latitude2), PI) / 180n;
|
|
3038
3044
|
const [s, c] = sc(theta), prolate = ratio2 > Q;
|
|
3039
3045
|
const square = mul(ratio2, ratio2);
|
|
3040
3046
|
const k = prolate ? Q - div(Q, square) : Q - square;
|
|
@@ -3106,11 +3112,11 @@ var EllipsoidRhumb = class {
|
|
|
3106
3112
|
throw new RangeError("Unrepresentable rhumb distance");
|
|
3107
3113
|
return result;
|
|
3108
3114
|
}
|
|
3109
|
-
direct(
|
|
3110
|
-
return this.line(
|
|
3115
|
+
direct(latitude2, longitude, azimuth, distance, options = {}) {
|
|
3116
|
+
return this.line(latitude2, longitude, azimuth, options).position(distance);
|
|
3111
3117
|
}
|
|
3112
|
-
line(
|
|
3113
|
-
validateRhumbPoint(
|
|
3118
|
+
line(latitude2, longitude, azimuth, options = {}) {
|
|
3119
|
+
validateRhumbPoint(latitude2, longitude);
|
|
3114
3120
|
if (!Number.isFinite(azimuth))
|
|
3115
3121
|
throw new RangeError("Rhumb azimuth must be finite");
|
|
3116
3122
|
const [sa, ca] = sincosDegrees(azimuth);
|
|
@@ -3125,26 +3131,26 @@ var EllipsoidRhumb = class {
|
|
|
3125
3131
|
const north = delta * ca;
|
|
3126
3132
|
let poleDistance;
|
|
3127
3133
|
if (north !== 0) {
|
|
3128
|
-
const gap = north > 0 ? this.meridianDelta(
|
|
3134
|
+
const gap = north > 0 ? this.meridianDelta(latitude2, 90) : this.meridianDelta(-90, latitude2);
|
|
3129
3135
|
poleDistance = gap - Math.abs(north);
|
|
3130
3136
|
if (Math.abs(poleDistance) < 1e-4 * gap)
|
|
3131
|
-
poleDistance = remainingPoleDistance(this.a, this.b,
|
|
3137
|
+
poleDistance = remainingPoleDistance(this.a, this.b, latitude2, azimuth, distance, Math.sign(north));
|
|
3132
3138
|
if (poleDistance < 0)
|
|
3133
3139
|
throw new RhumbDomainError("pole-crossing");
|
|
3134
3140
|
if (poleDistance === 0)
|
|
3135
3141
|
throw new RhumbDomainError("pole");
|
|
3136
3142
|
}
|
|
3137
|
-
const polar = north === 0 ? void 0 : this.polarEndpoint(
|
|
3138
|
-
const lat2 = north === 0 ?
|
|
3143
|
+
const polar = north === 0 ? void 0 : this.polarEndpoint(latitude2, north, poleDistance);
|
|
3144
|
+
const lat2 = north === 0 ? latitude2 : (polar == null ? void 0 : polar.latitude) ?? this.inverseMeridian(latitude2, north);
|
|
3139
3145
|
if (Math.abs(lat2) === 90)
|
|
3140
3146
|
throw new RhumbDomainError("pole");
|
|
3141
|
-
const [meanM, meanP] = (polar == null ? void 0 : polar.means) ?? this.means(
|
|
3147
|
+
const [meanM, meanP] = (polar == null ? void 0 : polar.means) ?? this.means(latitude2, lat2);
|
|
3142
3148
|
const dlon = delta * sa * meanP / meanM / DEG2;
|
|
3143
3149
|
const lon2 = unroll ? longitude + dlon : normalize(normalize(longitude) + dlon);
|
|
3144
3150
|
if (!Number.isFinite(lon2))
|
|
3145
3151
|
throw new RangeError("Unrepresentable rhumb longitude");
|
|
3146
3152
|
const result = output2 ?? {};
|
|
3147
|
-
result.lat1 =
|
|
3153
|
+
result.lat1 = latitude2;
|
|
3148
3154
|
result.lon1 = longitude;
|
|
3149
3155
|
result.lat2 = lat2;
|
|
3150
3156
|
result.lon2 = lon2;
|
|
@@ -3153,7 +3159,7 @@ var EllipsoidRhumb = class {
|
|
|
3153
3159
|
if (!area)
|
|
3154
3160
|
delete result.S12;
|
|
3155
3161
|
if (area)
|
|
3156
|
-
result.S12 = this.area(
|
|
3162
|
+
result.S12 = this.area(latitude2, lat2, dlon * DEG2, polar == null ? void 0 : polar.psi);
|
|
3157
3163
|
return result;
|
|
3158
3164
|
};
|
|
3159
3165
|
return { position: evaluate2 };
|
|
@@ -3169,14 +3175,14 @@ var EllipsoidRhumb = class {
|
|
|
3169
3175
|
}, -1, 1) / 2 : (this.psi(lat2) - this.psi(lat1)) / d;
|
|
3170
3176
|
return [meanM, meanP];
|
|
3171
3177
|
}
|
|
3172
|
-
psi(
|
|
3173
|
-
return this.metrics.latitudeToAuxiliary(
|
|
3178
|
+
psi(latitude2) {
|
|
3179
|
+
return this.metrics.latitudeToAuxiliary(latitude2, "isometric") * DEG2;
|
|
3174
3180
|
}
|
|
3175
|
-
polarEndpoint(
|
|
3176
|
-
const sign2 = Math.abs(
|
|
3181
|
+
polarEndpoint(latitude2, north, poleDistance) {
|
|
3182
|
+
const sign2 = Math.abs(latitude2) > 80 && Math.abs(north) < Math.abs(this.meridianDelta(0, latitude2)) ? Math.sign(latitude2) : Math.sign(north), theta1 = (90 - sign2 * latitude2) * DEG2, limit = 10 * DEG2;
|
|
3177
3183
|
const density = (theta2) => this.r ** 2 / Math.hypot(Math.sin(theta2), this.r * Math.cos(theta2)) ** 3;
|
|
3178
3184
|
const gap = (theta2) => integrate(density, 0, theta2);
|
|
3179
|
-
const target = sign2 === Math.sign(north) ? poleDistance : this.meridianDelta(sign2 > 0 ?
|
|
3185
|
+
const target = sign2 === Math.sign(north) ? poleDistance : this.meridianDelta(sign2 > 0 ? latitude2 : -90, sign2 > 0 ? 90 : latitude2) - sign2 * north;
|
|
3180
3186
|
if (!(target > 0 && target < gap(limit)))
|
|
3181
3187
|
return void 0;
|
|
3182
3188
|
let lo = 0, hi = limit, theta = target * this.r;
|
|
@@ -3272,8 +3278,8 @@ var EllipsoidRhumb = class {
|
|
|
3272
3278
|
}
|
|
3273
3279
|
throw new Error("Rhumb isometric inversion did not converge");
|
|
3274
3280
|
}
|
|
3275
|
-
potential(
|
|
3276
|
-
const [s, c] = latitudeSinCos(
|
|
3281
|
+
potential(latitude2) {
|
|
3282
|
+
const [s, c] = latitudeSinCos(latitude2), e2 = (1 - this.r) * (1 + this.r), e = Math.sqrt(Math.abs(e2));
|
|
3277
3283
|
const I = e === 0 ? s : (e2 > 0 ? Math.atanh(e * s) : Math.atan(e * s)) / e;
|
|
3278
3284
|
return this.r ** 2 * (s / (c * c + (this.r * s) ** 2) + I) / 2;
|
|
3279
3285
|
}
|
|
@@ -3297,10 +3303,10 @@ var EllipsoidRhumb = class {
|
|
|
3297
3303
|
return value3;
|
|
3298
3304
|
}
|
|
3299
3305
|
};
|
|
3300
|
-
function validateRhumbPoint(
|
|
3301
|
-
if (!(Number.isFinite(
|
|
3306
|
+
function validateRhumbPoint(latitude2, longitude) {
|
|
3307
|
+
if (!(Number.isFinite(latitude2) && Math.abs(latitude2) <= 90 && Number.isFinite(longitude)))
|
|
3302
3308
|
throw new RangeError("Rhumb coordinates require finite longitude and latitude in [-90,90]");
|
|
3303
|
-
if (Math.abs(
|
|
3309
|
+
if (Math.abs(latitude2) === 90)
|
|
3304
3310
|
throw new RhumbDomainError("pole");
|
|
3305
3311
|
}
|
|
3306
3312
|
function latitudeSinCos(phi) {
|
|
@@ -3346,11 +3352,11 @@ var RhumbPolygon = class extends SurfacePolygon {
|
|
|
3346
3352
|
constructor(parameters, options = {}) {
|
|
3347
3353
|
super(new EllipsoidRhumb(parameters), options);
|
|
3348
3354
|
}
|
|
3349
|
-
addPoint(
|
|
3350
|
-
validateRhumbPoint(
|
|
3355
|
+
addPoint(latitude2, longitude, options = {}) {
|
|
3356
|
+
validateRhumbPoint(latitude2, longitude);
|
|
3351
3357
|
if (!Number.isSafeInteger(options.longitudeTurns ?? 0))
|
|
3352
3358
|
throw new RangeError("Rhumb longitudeTurns must be a safe integer");
|
|
3353
|
-
return super.addPoint(
|
|
3359
|
+
return super.addPoint(latitude2, longitude, options);
|
|
3354
3360
|
}
|
|
3355
3361
|
};
|
|
3356
3362
|
|
|
@@ -3383,8 +3389,8 @@ var IntersectionBounds = class {
|
|
|
3383
3389
|
}
|
|
3384
3390
|
throw new Error("Conjugate distance did not converge");
|
|
3385
3391
|
}
|
|
3386
|
-
polarDistance(
|
|
3387
|
-
return this.conjugate(this.solver.line(
|
|
3392
|
+
polarDistance(latitude2, ratio2) {
|
|
3393
|
+
return this.conjugate(this.solver.line(latitude2, 0, 0), (1 + (1 - ratio2) / 2) * Math.PI / 2, true);
|
|
3388
3394
|
}
|
|
3389
3395
|
polarMinimum(ratio2) {
|
|
3390
3396
|
let lat0 = 63, lat1 = 65, lat2 = 64;
|
|
@@ -3451,7 +3457,7 @@ var GeodesicIntersections = class {
|
|
|
3451
3457
|
seeds.push([x + spacing * (i + j) / 2, y + spacing * (i - j) / 2, spacing, 0]);
|
|
3452
3458
|
let failed = 0, unresolved = 0;
|
|
3453
3459
|
const isolated = [], lines = [];
|
|
3454
|
-
const
|
|
3460
|
+
const equal2 = (p, q) => Math.abs(p.x - q.x) + Math.abs(p.y - q.y) <= this.bounds.margin;
|
|
3455
3461
|
const canonical = (p, c) => {
|
|
3456
3462
|
const shift2 = (x + c * y - (p.x + c * p.y)) / 2;
|
|
3457
3463
|
return { ...p, x: p.x + shift2, y: p.y + c * shift2, c };
|
|
@@ -3483,14 +3489,14 @@ var GeodesicIntersections = class {
|
|
|
3483
3489
|
retry(seed);
|
|
3484
3490
|
continue;
|
|
3485
3491
|
}
|
|
3486
|
-
if (!lines.some((p) => p.c === q.c &&
|
|
3492
|
+
if (!lines.some((p) => p.c === q.c && equal2(p, q)))
|
|
3487
3493
|
lines.push(q);
|
|
3488
|
-
} else if (!isolated.some((p) =>
|
|
3494
|
+
} else if (!isolated.some((p) => equal2(p, root2)))
|
|
3489
3495
|
isolated.push(root2);
|
|
3490
3496
|
}
|
|
3491
3497
|
const roots2 = [], coincidences = [];
|
|
3492
3498
|
for (const p of isolated) {
|
|
3493
|
-
if (lines.some((q) =>
|
|
3499
|
+
if (lines.some((q) => equal2(canonical(p, q.c), q)))
|
|
3494
3500
|
continue;
|
|
3495
3501
|
if (Math.abs(p.x - x) + Math.abs(p.y - y) > d + this.tolerance)
|
|
3496
3502
|
continue;
|
|
@@ -3546,13 +3552,13 @@ var GeodesicIntersections = class {
|
|
|
3546
3552
|
/** Global next crossing, excluding the shared parameter origin. For a
|
|
3547
3553
|
* coincident continuum use GeographicLib's nearest-conjugate convention.
|
|
3548
3554
|
*/
|
|
3549
|
-
next(
|
|
3550
|
-
const a = { latitude, longitude, azimuth: azimuthA }, b = { latitude, longitude, azimuth: azimuthB };
|
|
3555
|
+
next(latitude2, longitude, azimuthA, azimuthB, maxDistance) {
|
|
3556
|
+
const a = { latitude: latitude2, longitude, azimuth: azimuthA }, b = { latitude: latitude2, longitude, azimuth: azimuthB };
|
|
3551
3557
|
const bound = maxDistance === void 0 ? 4 * this.bounds.halfCircumference : maxDistance / this.a;
|
|
3552
3558
|
const search = this.search(a, b, { maxDistance: maxDistance ?? bound }, maxDistance === void 0);
|
|
3553
3559
|
search.intersections = search.intersections.filter((p) => Math.abs(p.s / this.a) + Math.abs(p.t / this.a) > this.bounds.margin);
|
|
3554
3560
|
const candidates = [...search.intersections];
|
|
3555
|
-
const A3 = this.solver.line(
|
|
3561
|
+
const A3 = this.solver.line(latitude2, longitude, azimuthA);
|
|
3556
3562
|
for (const c of search.coincidences) {
|
|
3557
3563
|
if (Math.abs(c.s / this.a) + Math.abs(c.t / this.a) > this.bounds.margin) {
|
|
3558
3564
|
const point2 = this.coincidencePoint(a, b, c);
|
|
@@ -3848,24 +3854,24 @@ var GeodesicPath = class {
|
|
|
3848
3854
|
if (result.length !== this.size)
|
|
3849
3855
|
throw new RangeError("Invalid geodesic sample output length");
|
|
3850
3856
|
let longitude;
|
|
3851
|
-
let
|
|
3857
|
+
let latitude2;
|
|
3852
3858
|
if (fraction === 0 || this.length === 0) {
|
|
3853
3859
|
longitude = this.first[0];
|
|
3854
|
-
|
|
3860
|
+
latitude2 = this.first[1];
|
|
3855
3861
|
} else if (fraction === 1) {
|
|
3856
3862
|
longitude = this.last[0];
|
|
3857
|
-
|
|
3863
|
+
latitude2 = this.last[1];
|
|
3858
3864
|
} else {
|
|
3859
3865
|
const value3 = this.line.position(this.length * fraction);
|
|
3860
3866
|
longitude = value3.lon2;
|
|
3861
|
-
|
|
3867
|
+
latitude2 = value3.lat2;
|
|
3862
3868
|
}
|
|
3863
3869
|
const height = this.size === 3 ? this.first[2] * (1 - fraction) + this.last[2] * fraction : 0;
|
|
3864
|
-
if (![longitude,
|
|
3870
|
+
if (![longitude, latitude2, height].every(Number.isFinite) || result instanceof Float32Array && ![longitude, latitude2, height].every((value3) => Number.isFinite(Math.fround(value3)))) {
|
|
3865
3871
|
throw new RangeError("Unrepresentable geodesic sample");
|
|
3866
3872
|
}
|
|
3867
3873
|
result[0] = longitude;
|
|
3868
|
-
result[1] =
|
|
3874
|
+
result[1] = latitude2;
|
|
3869
3875
|
if (this.size === 3)
|
|
3870
3876
|
result[2] = height;
|
|
3871
3877
|
return result;
|
|
@@ -3943,21 +3949,21 @@ var RhumbPath = class {
|
|
|
3943
3949
|
throw new RangeError("Rhumb fraction must be in [0, 1]");
|
|
3944
3950
|
if (result.length !== this.size || ArrayBuffer.isView(result) && !(result instanceof Float32Array) && !(result instanceof Float64Array))
|
|
3945
3951
|
throw new RangeError("Expected a floating rhumb output with matching dimensions");
|
|
3946
|
-
let longitude = this.first[0],
|
|
3952
|
+
let longitude = this.first[0], latitude2 = this.first[1];
|
|
3947
3953
|
if (fraction === 1) {
|
|
3948
3954
|
longitude = this.last[0];
|
|
3949
|
-
|
|
3955
|
+
latitude2 = this.last[1];
|
|
3950
3956
|
} else if (fraction !== 0 && this.length !== 0) {
|
|
3951
3957
|
const p = this.line.position(this.length * fraction);
|
|
3952
3958
|
longitude = p.lon2;
|
|
3953
|
-
|
|
3959
|
+
latitude2 = p.lat2;
|
|
3954
3960
|
}
|
|
3955
3961
|
const height = this.size === 3 ? this.first[2] * (1 - fraction) + this.last[2] * fraction : 0;
|
|
3956
|
-
const values = [longitude,
|
|
3962
|
+
const values = [longitude, latitude2, height];
|
|
3957
3963
|
if (!values.every(Number.isFinite) || result instanceof Float32Array && !values.every((x) => Number.isFinite(Math.fround(x))))
|
|
3958
3964
|
throw new RangeError("Unrepresentable rhumb sample");
|
|
3959
3965
|
result[0] = longitude;
|
|
3960
|
-
result[1] =
|
|
3966
|
+
result[1] = latitude2;
|
|
3961
3967
|
if (this.size === 3)
|
|
3962
3968
|
result[2] = height;
|
|
3963
3969
|
return result;
|
|
@@ -4153,9 +4159,9 @@ var LngLatRectangle = class {
|
|
|
4153
4159
|
east += import_core11._MathUtils.TWO_PI;
|
|
4154
4160
|
}
|
|
4155
4161
|
const longitude = (0, import_core11.normalizeAngle)((west + east) * 0.5, "negative-pi-to-pi");
|
|
4156
|
-
const
|
|
4162
|
+
const latitude2 = (rectangle.south + rectangle.north) * 0.5;
|
|
4157
4163
|
result.x = longitude;
|
|
4158
|
-
result.y =
|
|
4164
|
+
result.y = latitude2;
|
|
4159
4165
|
result.z = 0;
|
|
4160
4166
|
return result;
|
|
4161
4167
|
}
|
|
@@ -4348,10 +4354,10 @@ function applyTransform(obb, transform) {
|
|
|
4348
4354
|
obb.halfAxes = new import_core12.Matrix3().set(halfSize.x, 0, 0, 0, halfSize.y, 0, 0, 0, halfSize.z);
|
|
4349
4355
|
return obb;
|
|
4350
4356
|
}
|
|
4351
|
-
function latitudeZExtent(ellipsoid,
|
|
4357
|
+
function latitudeZExtent(ellipsoid, latitude2, height, maximum) {
|
|
4352
4358
|
let extent = maximum ? -Infinity : Infinity;
|
|
4353
4359
|
for (const longitude of [0, 90, 180, 270]) {
|
|
4354
|
-
const z = ellipsoid.cartographicToCartesian([longitude,
|
|
4360
|
+
const z = ellipsoid.cartographicToCartesian([longitude, latitude2, height], scratchMaxY).z;
|
|
4355
4361
|
extent = maximum ? Math.max(extent, z) : Math.min(extent, z);
|
|
4356
4362
|
}
|
|
4357
4363
|
return extent;
|
|
@@ -4492,16 +4498,16 @@ function getGlobeHorizonBounds(camera, radius) {
|
|
|
4492
4498
|
throw new RangeError("Camera magnitude must be finite");
|
|
4493
4499
|
if (distance <= radius)
|
|
4494
4500
|
return void 0;
|
|
4495
|
-
const
|
|
4501
|
+
const latitude2 = Math.atan2(camera[2], Math.hypot(camera[0], camera[1]));
|
|
4496
4502
|
const longitude = Math.atan2(camera[1], camera[0]);
|
|
4497
4503
|
const angle3 = Math.acos(radius / distance);
|
|
4498
4504
|
const degrees2 = 180 / Math.PI;
|
|
4499
4505
|
const padding = 1e-10;
|
|
4500
|
-
const south = Math.max(-90, (
|
|
4501
|
-
const north = Math.min(90, (
|
|
4502
|
-
if (Math.abs(
|
|
4506
|
+
const south = Math.max(-90, (latitude2 - angle3) * degrees2 - padding);
|
|
4507
|
+
const north = Math.min(90, (latitude2 + angle3) * degrees2 + padding);
|
|
4508
|
+
if (Math.abs(latitude2) + angle3 >= Math.PI / 2 - 1e-12)
|
|
4503
4509
|
return [-180, south, 180, north];
|
|
4504
|
-
const extent = Math.asin(Math.min(1, Math.sin(angle3) / Math.cos(
|
|
4510
|
+
const extent = Math.asin(Math.min(1, Math.sin(angle3) / Math.cos(latitude2))) * degrees2 + padding;
|
|
4505
4511
|
return [wrap(longitude * degrees2 - extent), south, wrap(longitude * degrees2 + extent), north];
|
|
4506
4512
|
}
|
|
4507
4513
|
function splitGlobeBounds(bounds2) {
|
|
@@ -4858,11 +4864,11 @@ function createEdges(start, end, originalStart, edgeIndex, ringIndex, turns, con
|
|
|
4858
4864
|
}
|
|
4859
4865
|
const c1 = Math.cos(inverse4.azi1 * Math.PI / 180), c2 = Math.cos(inverse4.azi2 * Math.PI / 180);
|
|
4860
4866
|
if (path.length > 0 && oppositeMeridians(originalStart[0], end[0]) && (inverse4.azi1 === 0 || Math.abs(inverse4.azi1) === 180) && Math.abs(first[1]) !== 90 && Math.abs(last[1]) !== 90) {
|
|
4861
|
-
const
|
|
4867
|
+
const latitude2 = c1 > 0 ? 90 : -90;
|
|
4862
4868
|
context.tick(2);
|
|
4863
|
-
const fraction = solver.inverse(start[1], start[0],
|
|
4864
|
-
if (fraction > 0 && fraction < 1 && Math.abs(path.sample(fraction)[1] -
|
|
4865
|
-
pole = { fraction, latitude };
|
|
4869
|
+
const fraction = solver.inverse(start[1], start[0], latitude2, start[0]).s12 / path.length;
|
|
4870
|
+
if (fraction > 0 && fraction < 1 && Math.abs(path.sample(fraction)[1] - latitude2) < ANGULAR_TOLERANCE)
|
|
4871
|
+
pole = { fraction, latitude: latitude2 };
|
|
4866
4872
|
} else if (splitLatitude && c1 * c2 < 0 && path.length > 0) {
|
|
4867
4873
|
context.tick();
|
|
4868
4874
|
const line = solver.line(originalStart[1], originalStart[0], inverse4.azi1, {
|
|
@@ -4972,13 +4978,13 @@ function readLatitudeRange(value3) {
|
|
|
4972
4978
|
}
|
|
4973
4979
|
function clipLatitudeEdge(edge2, range, context) {
|
|
4974
4980
|
const fractions = [0, 1], events = /* @__PURE__ */ new Map();
|
|
4975
|
-
for (const
|
|
4976
|
-
if (
|
|
4977
|
-
const t = root(edge2, 1,
|
|
4978
|
-
if (events.has(t) && events.get(t) !==
|
|
4981
|
+
for (const latitude2 of range)
|
|
4982
|
+
if (latitude2 > Math.min(edge2.a[1], edge2.b[1]) && latitude2 < Math.max(edge2.a[1], edge2.b[1])) {
|
|
4983
|
+
const t = root(edge2, 1, latitude2, context);
|
|
4984
|
+
if (events.has(t) && events.get(t) !== latitude2)
|
|
4979
4985
|
throw new GeographicSeamError("precision", "Unresolvable latitude events");
|
|
4980
4986
|
fractions.push(t);
|
|
4981
|
-
events.set(t,
|
|
4987
|
+
events.set(t, latitude2);
|
|
4982
4988
|
}
|
|
4983
4989
|
fractions.sort((a, b) => a - b);
|
|
4984
4990
|
const result = [];
|
|
@@ -5091,8 +5097,8 @@ function prepare(input, index, context) {
|
|
|
5091
5097
|
throw new GeographicSeamError("topology", "Polar rings require an explicit pole and monotone longitude winding");
|
|
5092
5098
|
if (poleAttributes.length !== context.size - 2 || !poleAttributes.every(Number.isFinite))
|
|
5093
5099
|
throw new GeographicSeamError("input", "Explicit poleAttributes are required for polar attributes");
|
|
5094
|
-
const
|
|
5095
|
-
const a = [cursor[0],
|
|
5100
|
+
const latitude2 = input.pole === "north" ? 90 : -90;
|
|
5101
|
+
const a = [cursor[0], latitude2, ...poleAttributes], b = [first[0], latitude2, ...poleAttributes];
|
|
5096
5102
|
membership.push(straight(cursor, a), straight(a, b), straight(b, first));
|
|
5097
5103
|
} else if (input.pole !== void 0 || poleAttributes.length) {
|
|
5098
5104
|
throw new GeographicSeamError("input", "Pole selection applies only to once-winding polar rings");
|
|
@@ -5240,13 +5246,13 @@ function processPolygon(inputs, options, latitudeRange) {
|
|
|
5240
5246
|
piece.b[1] = latitudes.get(fractions[i]);
|
|
5241
5247
|
if (fractions.length > 2)
|
|
5242
5248
|
context.addVertices(2);
|
|
5243
|
-
const x = piece.a[0],
|
|
5249
|
+
const x = piece.a[0], latitude2 = (piece.a[1] + piece.b[1]) / 2;
|
|
5244
5250
|
const seam = x === context.left;
|
|
5245
5251
|
const ring = piece.source && rings[piece.source.ringIndex];
|
|
5246
|
-
if (ring && ring.max - ring.min >= 360 - ANGULAR_TOLERANCE && contains(ring, [x,
|
|
5252
|
+
if (ring && ring.max - ring.min >= 360 - ANGULAR_TOLERANCE && contains(ring, [x, latitude2], context, seam ? "right" : "left") && contains(ring, [seam ? context.right : x, latitude2], context, seam ? "left" : "right"))
|
|
5247
5253
|
continue;
|
|
5248
|
-
const left = filled(rings, [x,
|
|
5249
|
-
const right = filled(rings, [seam ? context.right : x,
|
|
5254
|
+
const left = filled(rings, [x, latitude2], context, seam ? "right" : "left");
|
|
5255
|
+
const right = filled(rings, [seam ? context.right : x, latitude2], context, seam ? "left" : "right");
|
|
5250
5256
|
if (left && right)
|
|
5251
5257
|
continue;
|
|
5252
5258
|
if (!left && !right)
|
|
@@ -5266,20 +5272,20 @@ function processPolygon(inputs, options, latitudeRange) {
|
|
|
5266
5272
|
}
|
|
5267
5273
|
const pole = rings[0].pole;
|
|
5268
5274
|
if (pole && !rings.slice(1).some((r) => r.pole === pole)) {
|
|
5269
|
-
const
|
|
5270
|
-
add4(straight([context.left,
|
|
5275
|
+
const latitude2 = pole === "north" ? 90 : -90;
|
|
5276
|
+
add4(straight([context.left, latitude2, ...rings[0].poleAttributes], [context.right, latitude2, ...rings[0].poleAttributes]));
|
|
5271
5277
|
}
|
|
5272
5278
|
for (const boundary of [context.left, context.right]) {
|
|
5273
5279
|
const boundaryNodes = Array.from(nodes.values()).filter((n) => n.p[0] === boundary).sort((a, b) => a.p[1] - b.p[1]);
|
|
5274
5280
|
const aligned = graph.filter((e) => e.a[0] === boundary && e.b[0] === boundary);
|
|
5275
5281
|
for (let i = 1; i < boundaryNodes.length; i++) {
|
|
5276
5282
|
context.tick();
|
|
5277
|
-
const a = boundaryNodes[i - 1].p, b = boundaryNodes[i].p,
|
|
5278
|
-
if (
|
|
5283
|
+
const a = boundaryNodes[i - 1].p, b = boundaryNodes[i].p, latitude2 = (a[1] + b[1]) / 2;
|
|
5284
|
+
if (latitude2 === a[1] || latitude2 === b[1])
|
|
5279
5285
|
throw new GeographicSeamError("precision", "Unresolvable seam event separation");
|
|
5280
|
-
if (filled(rings, [boundary,
|
|
5286
|
+
if (filled(rings, [boundary, latitude2], context, boundary === context.left ? "right" : "left") && !aligned.some((e) => {
|
|
5281
5287
|
context.tick();
|
|
5282
|
-
return
|
|
5288
|
+
return latitude2 > Math.min(e.a[1], e.b[1]) && latitude2 < Math.max(e.a[1], e.b[1]);
|
|
5283
5289
|
}))
|
|
5284
5290
|
add4(straight(a, b));
|
|
5285
5291
|
}
|
|
@@ -5419,13 +5425,13 @@ function getGeographicTileBounds(tile) {
|
|
|
5419
5425
|
90 - 180 * tile.y / size
|
|
5420
5426
|
];
|
|
5421
5427
|
}
|
|
5422
|
-
function getGeographicTile(longitude,
|
|
5428
|
+
function getGeographicTile(longitude, latitude2, level) {
|
|
5423
5429
|
const size = gridSize(level);
|
|
5424
|
-
if (!Number.isFinite(longitude) || longitude < -180 || longitude > 180 || !Number.isFinite(
|
|
5430
|
+
if (!Number.isFinite(longitude) || longitude < -180 || longitude > 180 || !Number.isFinite(latitude2) || latitude2 < -90 || latitude2 > 90)
|
|
5425
5431
|
throw new RangeError("Expected longitude in [-180, 180] and latitude in [-90, 90]");
|
|
5426
5432
|
return {
|
|
5427
5433
|
x: Math.min(size - 1, Math.floor((longitude + 180) / 360 * size)),
|
|
5428
|
-
y: Math.min(size - 1, Math.floor((90 -
|
|
5434
|
+
y: Math.min(size - 1, Math.floor((90 - latitude2) / 180 * size)),
|
|
5429
5435
|
level
|
|
5430
5436
|
};
|
|
5431
5437
|
}
|
|
@@ -6969,7 +6975,7 @@ function requireValue(condition, field) {
|
|
|
6969
6975
|
|
|
6970
6976
|
// dist/web-mercator.js
|
|
6971
6977
|
var web_mercator_exports = {};
|
|
6972
|
-
__reExport(web_mercator_exports, require("@math.gl/web-mercator"));
|
|
6978
|
+
__reExport(web_mercator_exports, require("@math.gl/geospatial/web-mercator"));
|
|
6973
6979
|
|
|
6974
6980
|
// dist/expressions.js
|
|
6975
6981
|
var import_core14 = require("@math.gl/core");
|
|
@@ -7760,11 +7766,11 @@ var GeographicCutAtlas = class {
|
|
|
7760
7766
|
}
|
|
7761
7767
|
return this.clip(sources, context);
|
|
7762
7768
|
}
|
|
7763
|
-
clip(sources, context,
|
|
7769
|
+
clip(sources, context, contains3, sign2 = 1) {
|
|
7764
7770
|
const registry = /* @__PURE__ */ new Map(), events = new Map(this.boundaries.map((c) => [c.id, /* @__PURE__ */ new Set()]));
|
|
7765
7771
|
let serial = 0;
|
|
7766
7772
|
const node = (n, attributes, source = false) => {
|
|
7767
|
-
const k = key(n) + (!
|
|
7773
|
+
const k = key(n) + (!contains3 && source ? "|" + attributes.join(",") : ""), previous = registry.get(k);
|
|
7768
7774
|
if (previous) {
|
|
7769
7775
|
if (source && previous.source && attributes.some((x, i) => x !== previous.p[i + 2]))
|
|
7770
7776
|
throw new GeographicSeamError("topology", "Shared source vertex attributes disagree");
|
|
@@ -7841,7 +7847,7 @@ var GeographicCutAtlas = class {
|
|
|
7841
7847
|
if (value(b, v.n) === 0)
|
|
7842
7848
|
on2(v, b);
|
|
7843
7849
|
}
|
|
7844
|
-
if (!
|
|
7850
|
+
if (!contains3 && Math.hypot(...endpoints[0].n.map((x, i) => x - endpoints[1].n[i])) === 0 && curve.speed > ANGULAR) {
|
|
7845
7851
|
const steps = Math.max(4, Math.ceil(curve.speed / (Math.PI / 2)));
|
|
7846
7852
|
if (steps > context.maxVertices)
|
|
7847
7853
|
throw new GeographicSeamError("limit", "Too many closed-line samples");
|
|
@@ -7906,12 +7912,12 @@ var GeographicCutAtlas = class {
|
|
|
7906
7912
|
const n = normal(arc.curve.sample(0.5));
|
|
7907
7913
|
if (!accepts(cell, n, arc.coincident))
|
|
7908
7914
|
continue;
|
|
7909
|
-
if (
|
|
7915
|
+
if (contains3 && cell.cuts.some((r) => {
|
|
7910
7916
|
var _a;
|
|
7911
7917
|
return ((_a = arc.coincident) == null ? void 0 : _a.has(r.circle.id)) && r.side * dot2(r.circle.normal, cross3(n, arc.curve.derivative(0.5))) < 0;
|
|
7912
7918
|
}))
|
|
7913
7919
|
continue;
|
|
7914
|
-
if (!
|
|
7920
|
+
if (!contains3) {
|
|
7915
7921
|
const coincident = cell.cuts.filter((r) => {
|
|
7916
7922
|
var _a;
|
|
7917
7923
|
return (_a = arc.coincident) == null ? void 0 : _a.has(r.circle.id);
|
|
@@ -7924,7 +7930,7 @@ var GeographicCutAtlas = class {
|
|
|
7924
7930
|
}
|
|
7925
7931
|
arcs.push(arc);
|
|
7926
7932
|
}
|
|
7927
|
-
if (!
|
|
7933
|
+
if (!contains3) {
|
|
7928
7934
|
const parts = [];
|
|
7929
7935
|
for (const e of arcs) {
|
|
7930
7936
|
context.tick();
|
|
@@ -7957,7 +7963,7 @@ var GeographicCutAtlas = class {
|
|
|
7957
7963
|
continue;
|
|
7958
7964
|
}
|
|
7959
7965
|
const midpoint = onCircle(b, (a.angle + hi) / 2), known = /* @__PURE__ */ new Set([b.id]);
|
|
7960
|
-
if (!accepts(cell, midpoint, known) || !
|
|
7966
|
+
if (!accepts(cell, midpoint, known) || !contains3(midpoint))
|
|
7961
7967
|
continue;
|
|
7962
7968
|
if (sourceArcs.some((e) => {
|
|
7963
7969
|
var _a;
|
|
@@ -8241,12 +8247,12 @@ var GeodesicPolygonExact = class extends SurfacePolygon {
|
|
|
8241
8247
|
direct: (a, b, c, d, opts) => solver.direct(a, b % 720, c, d, opts)
|
|
8242
8248
|
}, options);
|
|
8243
8249
|
}
|
|
8244
|
-
addPoint(
|
|
8250
|
+
addPoint(latitude2, longitude, options = {}) {
|
|
8245
8251
|
if (Math.abs(longitude) > 1e6)
|
|
8246
8252
|
throw new RangeError("Exact polygon longitude exceeds input profile");
|
|
8247
8253
|
if (options.longitudeTurns !== void 0 && options.longitudeTurns !== 0)
|
|
8248
8254
|
throw new RangeError("Exact geodesic point insertion does not select winding routes; use addEdge");
|
|
8249
|
-
return super.addPoint(
|
|
8255
|
+
return super.addPoint(latitude2, longitude);
|
|
8250
8256
|
}
|
|
8251
8257
|
};
|
|
8252
8258
|
|
|
@@ -8532,11 +8538,11 @@ var TriaxialEllipsoid = class {
|
|
|
8532
8538
|
}
|
|
8533
8539
|
throw new RangeError("Surface sampling work limit exceeded");
|
|
8534
8540
|
}
|
|
8535
|
-
toCartesian(
|
|
8541
|
+
toCartesian(latitude2, longitude, coordinates = "geodetic") {
|
|
8536
8542
|
system(coordinates);
|
|
8537
|
-
if (!Number.isFinite(
|
|
8543
|
+
if (!Number.isFinite(latitude2) || Math.abs(latitude2) > 90 || !Number.isFinite(longitude))
|
|
8538
8544
|
throw new RangeError("Invalid triaxial latitude/longitude");
|
|
8539
|
-
const p = trig(
|
|
8545
|
+
const p = trig(latitude2), l = trig(longitude), n = [p.c * l.c, p.c * l.s, p.s], r = this.axes;
|
|
8540
8546
|
if (coordinates === "parametric")
|
|
8541
8547
|
return n.map((x, i) => x * this.radii[i]);
|
|
8542
8548
|
const denominator = coordinates === "geodetic" ? Math.hypot(...n.map((x, i) => x * r[i])) : Math.hypot(...n.map((x, i) => x / r[i]));
|
|
@@ -8686,8 +8692,8 @@ function parseGeographicCoordinates(text, options = {}) {
|
|
|
8686
8692
|
longitude: parseAngle(lon, "longitude")
|
|
8687
8693
|
};
|
|
8688
8694
|
}
|
|
8689
|
-
function formatGeographicCoordinates(
|
|
8690
|
-
const lat = formatAngle(
|
|
8695
|
+
function formatGeographicCoordinates(latitude2, longitude, options = {}) {
|
|
8696
|
+
const lat = formatAngle(latitude2, { ...options, axis: "latitude" }), lon = formatAngle(longitude, { ...options, axis: "longitude" });
|
|
8691
8697
|
return (options.longitudeFirst ? [lon, lat] : [lat, lon]).join(", ");
|
|
8692
8698
|
}
|
|
8693
8699
|
|
|
@@ -8830,13 +8836,13 @@ function intersectGeographicBounds(a, b) {
|
|
|
8830
8836
|
}
|
|
8831
8837
|
function clampGeographicPoint(bounds2, point2) {
|
|
8832
8838
|
let longitude = normalizeLongitude2(point2[0]);
|
|
8833
|
-
const
|
|
8834
|
-
if (!containsGeographicPoint(bounds2, [longitude,
|
|
8839
|
+
const latitude2 = Math.max(bounds2[1], Math.min(bounds2[3], point2[1]));
|
|
8840
|
+
if (!containsGeographicPoint(bounds2, [longitude, latitude2])) {
|
|
8835
8841
|
const westDistance = Math.abs(normalizeLongitude2(longitude - bounds2[0]));
|
|
8836
8842
|
const eastDistance = Math.abs(normalizeLongitude2(longitude - bounds2[2]));
|
|
8837
8843
|
longitude = westDistance <= eastDistance ? bounds2[0] : bounds2[2];
|
|
8838
8844
|
}
|
|
8839
|
-
return [longitude,
|
|
8845
|
+
return [longitude, latitude2];
|
|
8840
8846
|
}
|
|
8841
8847
|
function getAngularRanges(bounds2, primeMeridian = 0, origin = 0) {
|
|
8842
8848
|
const width = getLongitudeSpan(bounds2);
|
|
@@ -9096,10 +9102,10 @@ function bindKernel(name, state, forward4, inverse4, adapt = createProjection) {
|
|
|
9096
9102
|
function guardAzimuthalDomain(base, implementation) {
|
|
9097
9103
|
const forward4 = projectionOperation(implementation, false);
|
|
9098
9104
|
return createProjection((point2) => {
|
|
9099
|
-
const longitude = point2.x,
|
|
9105
|
+
const longitude = point2.x, latitude2 = point2.y;
|
|
9100
9106
|
const delta = Math.atan2(Math.sin(longitude - base.long0), Math.cos(longitude - base.long0));
|
|
9101
9107
|
const polar = Math.abs(Math.abs(base.lat0) - Math.PI / 2) < 1e-10;
|
|
9102
|
-
if (Math.abs(
|
|
9108
|
+
if (Math.abs(latitude2 + base.lat0) < 1e-10 && (polar || Math.abs(Math.abs(delta) - Math.PI) < 1e-10))
|
|
9103
9109
|
throw new Error("Azimuthal projection is undefined at the antipode");
|
|
9104
9110
|
forward4(point2);
|
|
9105
9111
|
}, projectionOperation(implementation, true));
|
|
@@ -9628,11 +9634,11 @@ var universalTransverseMercator = {
|
|
|
9628
9634
|
};
|
|
9629
9635
|
|
|
9630
9636
|
// dist/projection/experimental/rendering-profile/spherical-rendering-domain.js
|
|
9631
|
-
function geographicVector(longitude,
|
|
9637
|
+
function geographicVector(longitude, latitude2) {
|
|
9632
9638
|
return [
|
|
9633
|
-
Math.cos(
|
|
9634
|
-
Math.cos(
|
|
9635
|
-
Math.sin(
|
|
9639
|
+
Math.cos(latitude2) * Math.cos(longitude),
|
|
9640
|
+
Math.cos(latitude2) * Math.sin(longitude),
|
|
9641
|
+
Math.sin(latitude2)
|
|
9636
9642
|
];
|
|
9637
9643
|
}
|
|
9638
9644
|
var dot3 = (a, b) => a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
|
|
@@ -9657,38 +9663,38 @@ function sphericalExtremum(vector2, parameters, domain, maximize = true) {
|
|
|
9657
9663
|
const limit = domain ? Math.cos(domain.distance) : -1;
|
|
9658
9664
|
let best = maximize ? -Infinity : Infinity;
|
|
9659
9665
|
let point2 = [NaN, NaN];
|
|
9660
|
-
const consider = (longitude,
|
|
9666
|
+
const consider = (longitude, latitude2) => {
|
|
9661
9667
|
longitude = center + wrapLongitude(longitude - center);
|
|
9662
|
-
if (longitude < west - 1e-12 || longitude > east + 1e-12 ||
|
|
9668
|
+
if (longitude < west - 1e-12 || longitude > east + 1e-12 || latitude2 < south - 1e-12 || latitude2 > north + 1e-12)
|
|
9663
9669
|
return;
|
|
9664
|
-
const position2 = geographicVector(longitude,
|
|
9670
|
+
const position2 = geographicVector(longitude, latitude2);
|
|
9665
9671
|
if (domain && dot3(axis, position2) < limit - 1e-13)
|
|
9666
9672
|
return;
|
|
9667
9673
|
const value3 = dot3(vector2, position2);
|
|
9668
9674
|
if (maximize ? value3 > best : value3 < best) {
|
|
9669
9675
|
best = value3;
|
|
9670
|
-
point2 = [longitude,
|
|
9676
|
+
point2 = [longitude, latitude2];
|
|
9671
9677
|
}
|
|
9672
9678
|
};
|
|
9673
9679
|
const longitudes = [west, east, ...trigonometricRoots(-vector2[1], vector2[0], 0, west, east)];
|
|
9674
9680
|
for (const longitude of longitudes) {
|
|
9675
9681
|
const coefficient = vector2[0] * Math.cos(longitude) + vector2[1] * Math.sin(longitude);
|
|
9676
|
-
for (const
|
|
9682
|
+
for (const latitude2 of [
|
|
9677
9683
|
south,
|
|
9678
9684
|
north,
|
|
9679
9685
|
...trigonometricRoots(vector2[2], -coefficient, 0, south, north)
|
|
9680
9686
|
])
|
|
9681
|
-
consider(longitude,
|
|
9687
|
+
consider(longitude, latitude2);
|
|
9682
9688
|
}
|
|
9683
9689
|
if (domain) {
|
|
9684
9690
|
const [a, , c] = axis;
|
|
9685
|
-
for (const
|
|
9686
|
-
for (const longitude of trigonometricRoots(a * Math.cos(
|
|
9687
|
-
consider(longitude,
|
|
9691
|
+
for (const latitude2 of [south, north]) {
|
|
9692
|
+
for (const longitude of trigonometricRoots(a * Math.cos(latitude2), 0, limit - c * Math.sin(latitude2), west, east))
|
|
9693
|
+
consider(longitude, latitude2);
|
|
9688
9694
|
}
|
|
9689
9695
|
for (const longitude of [west, east]) {
|
|
9690
|
-
for (const
|
|
9691
|
-
consider(longitude,
|
|
9696
|
+
for (const latitude2 of trigonometricRoots(a * Math.cos(longitude), c, limit, south, north))
|
|
9697
|
+
consider(longitude, latitude2);
|
|
9692
9698
|
}
|
|
9693
9699
|
const parallel = dot3(vector2, axis);
|
|
9694
9700
|
let tangent = vector2.map((value3, index) => value3 - parallel * axis[index]);
|
|
@@ -9756,10 +9762,10 @@ function createAngularRenderingProfile(base, maximumDistance, resolveBounds2, ho
|
|
|
9756
9762
|
const angle3 = base.lat0 + domain.distance;
|
|
9757
9763
|
const center = (local[0][0] + local[1][0]) / 2;
|
|
9758
9764
|
const longitude = center + wrapLongitude((Math.cos(angle3) < 0 ? Math.PI : 0) - center);
|
|
9759
|
-
const
|
|
9760
|
-
if (longitude >= local[0][0] && longitude <= local[1][0] &&
|
|
9765
|
+
const latitude2 = Math.atan2(Math.sin(angle3), Math.abs(Math.cos(angle3)));
|
|
9766
|
+
if (longitude >= local[0][0] && longitude <= local[1][0] && latitude2 >= local[0][1] && latitude2 <= local[1][1]) {
|
|
9761
9767
|
point2.x = longitude + base.long0;
|
|
9762
|
-
point2.y =
|
|
9768
|
+
point2.y = latitude2;
|
|
9763
9769
|
return;
|
|
9764
9770
|
}
|
|
9765
9771
|
}
|
|
@@ -10019,7 +10025,7 @@ var stereographic = {
|
|
|
10019
10025
|
const base = kernelParameters(context);
|
|
10020
10026
|
const state = createState3(base);
|
|
10021
10027
|
const projection2 = guardAzimuthalDomain(base, bindKernel("stere", state, forward3, inverse3));
|
|
10022
|
-
return withAngularRenderingProfile(projection2, base, 150 * Math.PI / 180, (region, domain) => state.sphere ? sphericalAzimuthalBounds(state, region, domain, "stere") : ellipsoidalStereographicBounds(state, (
|
|
10028
|
+
return withAngularRenderingProfile(projection2, base, 150 * Math.PI / 180, (region, domain) => state.sphere ? sphericalAzimuthalBounds(state, region, domain, "stere") : ellipsoidalStereographicBounds(state, (latitude2) => 2 * Math.atan(Math.tan(Math.PI / 4 + latitude2 / 2) * Math.pow((1 - state.e * Math.sin(latitude2)) / (1 + state.e * Math.sin(latitude2)), state.e / 2)) - Math.PI / 2, state.X0, 2 * state.a * state.k0 * (Math.abs(state.coslat0) < 1e-10 ? 1 / state.cons : state.ms1 / state.cosX0), region, domain));
|
|
10023
10029
|
}
|
|
10024
10030
|
};
|
|
10025
10031
|
|
|
@@ -10027,16 +10033,16 @@ var stereographic = {
|
|
|
10027
10033
|
var DEG5 = Math.PI / 180;
|
|
10028
10034
|
var A2 = 6378137;
|
|
10029
10035
|
var F = 1 / 298.257223563;
|
|
10030
|
-
function standardGridZone(
|
|
10031
|
-
if (!Number.isFinite(
|
|
10036
|
+
function standardGridZone(latitude2, longitude) {
|
|
10037
|
+
if (!Number.isFinite(latitude2) || Math.abs(latitude2) > 90 || !Number.isFinite(longitude) || Math.abs(longitude) > 180)
|
|
10032
10038
|
throw new RangeError("Expected latitude/longitude degrees in [-90,90]/[-180,180]");
|
|
10033
|
-
if (
|
|
10039
|
+
if (latitude2 < -80 || latitude2 >= 84)
|
|
10034
10040
|
return 0;
|
|
10035
10041
|
const lon = longitude === 180 ? -180 : longitude;
|
|
10036
10042
|
let zone = Math.floor((Math.floor(lon) + 186) / 6);
|
|
10037
|
-
if (
|
|
10043
|
+
if (latitude2 >= 56 && latitude2 < 64 && lon >= 3 && lon < 12)
|
|
10038
10044
|
zone = 32;
|
|
10039
|
-
if (
|
|
10045
|
+
if (latitude2 >= 72 && lon >= 0 && lon < 42)
|
|
10040
10046
|
zone = 2 * Math.floor((Math.floor(lon) + 183) / 12) + 1;
|
|
10041
10047
|
return zone;
|
|
10042
10048
|
}
|
|
@@ -10061,16 +10067,16 @@ function projection(zone, north) {
|
|
|
10061
10067
|
prepared.set(key3, result);
|
|
10062
10068
|
return result;
|
|
10063
10069
|
}
|
|
10064
|
-
function projectGrid(
|
|
10065
|
-
const standard = standardGridZone(
|
|
10070
|
+
function projectGrid(latitude2, longitude, options = {}) {
|
|
10071
|
+
const standard = standardGridZone(latitude2, longitude), zone = options.zone ?? standard, naturalNorth = !(latitude2 < 0 || Object.is(latitude2, -0)), north = options.north ?? naturalNorth;
|
|
10066
10072
|
validateZone(zone, north);
|
|
10067
|
-
if (zone === 0 && (Math.abs(
|
|
10073
|
+
if (zone === 0 && (Math.abs(latitude2) < 70 || north !== naturalNorth))
|
|
10068
10074
|
throw new RangeError("UPS requires its matching polar hemisphere");
|
|
10069
10075
|
if (zone && Math.abs((longitude - (6 * zone - 183) + 540) % 360 - 180) > 60)
|
|
10070
10076
|
throw new RangeError("Longitude too far from UTM central meridian");
|
|
10071
|
-
if (zone === 0 && Math.abs(
|
|
10077
|
+
if (zone === 0 && Math.abs(latitude2) === 90)
|
|
10072
10078
|
return { zone, north, easting: 2e6, northing: 2e6 };
|
|
10073
|
-
const p = projection(zone, north).forward(longitude * DEG5,
|
|
10079
|
+
const p = projection(zone, north).forward(longitude * DEG5, latitude2 * DEG5);
|
|
10074
10080
|
if (zone === 0) {
|
|
10075
10081
|
if (longitude % 180 === 0)
|
|
10076
10082
|
p[0] = 2e6;
|
|
@@ -10135,17 +10141,17 @@ function utmRow(band, column, row) {
|
|
|
10135
10141
|
}
|
|
10136
10142
|
return row;
|
|
10137
10143
|
}
|
|
10138
|
-
function formatMGRS(
|
|
10144
|
+
function formatMGRS(latitude2, longitude, precision = 5, options = {}) {
|
|
10139
10145
|
if (!Number.isInteger(precision) || precision < 0 || precision > 11)
|
|
10140
10146
|
throw new RangeError("MGRS precision must be in [0,11]");
|
|
10141
|
-
const grid = projectGrid(
|
|
10147
|
+
const grid = projectGrid(latitude2, longitude, options), { zone, north, easting: x } = grid;
|
|
10142
10148
|
let y = grid.northing;
|
|
10143
10149
|
if (zone && !north && y === 1e7)
|
|
10144
10150
|
y -= 2 ** -28;
|
|
10145
10151
|
const column = Math.floor(x / TILE), row = Math.floor(y / TILE);
|
|
10146
10152
|
let prefix;
|
|
10147
10153
|
if (zone) {
|
|
10148
|
-
const band = Math.abs(
|
|
10154
|
+
const band = Math.abs(latitude2) < 2 ** -46 ? north ? 0 : -1 : Math.max(-10, Math.min(9, Math.floor((Math.floor(latitude2) + 80) / 8) - 10));
|
|
10149
10155
|
if (column < 1 || column > 8 || utmRow(band, column - 1, row % 20) !== row - (north ? 0 : 100))
|
|
10150
10156
|
throw new RangeError("Grid outside MGRS domain");
|
|
10151
10157
|
prefix = String(zone).padStart(2, "0") + BANDS[band + 10] + COLUMNS[(zone - 1) % 3][column - 1] + ROWS[(row + ((zone - 1) % 2 ? 5 : 0)) % 20];
|
|
@@ -10217,8 +10223,8 @@ function parseMGRSZone(text) {
|
|
|
10217
10223
|
band
|
|
10218
10224
|
};
|
|
10219
10225
|
}
|
|
10220
|
-
function formatMGRSZone(
|
|
10221
|
-
const cell = formatMGRS(
|
|
10226
|
+
function formatMGRSZone(latitude2, longitude, options = {}) {
|
|
10227
|
+
const cell = formatMGRS(latitude2, longitude, 0, options);
|
|
10222
10228
|
return cell.slice(0, cell.length - 2);
|
|
10223
10229
|
}
|
|
10224
10230
|
|
|
@@ -11006,17 +11012,17 @@ var GeographicHeightField = class {
|
|
|
11006
11012
|
});
|
|
11007
11013
|
}
|
|
11008
11014
|
/** Longitude must use the bounds' unwrapped interval; no implicit wrapping or clamping. */
|
|
11009
|
-
sample(longitude,
|
|
11010
|
-
const valid = Number.isFinite(longitude) && Number.isFinite(
|
|
11011
|
-
const inside = valid && longitude >= this.bounds[0] && longitude <= this.bounds[2] &&
|
|
11012
|
-
const sample = this.field.sample(inside ? this.projectX(longitude) : NaN, inside ? this.projectY(
|
|
11015
|
+
sample(longitude, latitude2, options, result) {
|
|
11016
|
+
const valid = Number.isFinite(longitude) && Number.isFinite(latitude2);
|
|
11017
|
+
const inside = valid && longitude >= this.bounds[0] && longitude <= this.bounds[2] && latitude2 >= this.bounds[1] && latitude2 <= this.bounds[3];
|
|
11018
|
+
const sample = this.field.sample(inside ? this.projectX(longitude) : NaN, inside ? this.projectY(latitude2) : NaN, options, result);
|
|
11013
11019
|
if (!inside) {
|
|
11014
11020
|
sample.status = sample.gradientStatus = valid ? TerrainSampleStatus.OUTSIDE_DOMAIN : TerrainSampleStatus.INVALID_INPUT;
|
|
11015
11021
|
return sample;
|
|
11016
11022
|
}
|
|
11017
11023
|
if (sample.gradientStatus !== TerrainSampleStatus.VALID)
|
|
11018
11024
|
return sample;
|
|
11019
|
-
const phi =
|
|
11025
|
+
const phi = latitude2 * RADIANS2;
|
|
11020
11026
|
const denominator = 1 - ECCENTRICITY_SQUARED * Math.sin(phi) ** 2;
|
|
11021
11027
|
const n = RADIUS / Math.sqrt(denominator);
|
|
11022
11028
|
const m = RADIUS * (1 - ECCENTRICITY_SQUARED) / denominator ** 1.5;
|
|
@@ -11040,8 +11046,8 @@ var GeographicHeightField = class {
|
|
|
11040
11046
|
projectX(longitude) {
|
|
11041
11047
|
return this.projection === "web-mercator" ? RADIUS * longitude * RADIANS2 : longitude;
|
|
11042
11048
|
}
|
|
11043
|
-
projectY(
|
|
11044
|
-
return this.projection === "web-mercator" ? RADIUS * Math.asinh(Math.tan(
|
|
11049
|
+
projectY(latitude2) {
|
|
11050
|
+
return this.projection === "web-mercator" ? RADIUS * Math.asinh(Math.tan(latitude2 * RADIANS2)) : latitude2;
|
|
11045
11051
|
}
|
|
11046
11052
|
};
|
|
11047
11053
|
|
|
@@ -16174,8 +16180,8 @@ function createBreaklineTerrainMesh(field, options) {
|
|
|
16174
16180
|
continue;
|
|
16175
16181
|
}
|
|
16176
16182
|
const r = points[c], s = points[d];
|
|
16177
|
-
const
|
|
16178
|
-
if (
|
|
16183
|
+
const intersects3 = Math.sign(cross4(p, q, r)) * Math.sign(cross4(p, q, s)) < 0 && Math.sign(cross4(r, s, p)) * Math.sign(cross4(r, s, q)) < 0;
|
|
16184
|
+
if (intersects3 || c !== a && c !== b && onSegment(p, q, r) || d !== a && d !== b && onSegment(p, q, s) || a !== c && a !== d && onSegment(r, s, p) || b !== c && b !== d && onSegment(r, s, q)) {
|
|
16179
16185
|
throw new Error("Breaklines and domain edges must meet only at shared endpoints");
|
|
16180
16186
|
}
|
|
16181
16187
|
}
|
|
@@ -16408,21 +16414,21 @@ function wrapTerrainLongitude(longitude, west, east) {
|
|
|
16408
16414
|
function measureGeographicTerrainSeam(a, b, probes, options = {}) {
|
|
16409
16415
|
if (a && b && a.heightReference !== b.heightReference)
|
|
16410
16416
|
throw new Error("Terrain seam height references differ");
|
|
16411
|
-
const sample = (field, longitude,
|
|
16417
|
+
const sample = (field, longitude, latitude2) => {
|
|
16412
16418
|
if (!field || !Number.isFinite(longitude))
|
|
16413
|
-
return field == null ? void 0 : field.sample(longitude,
|
|
16419
|
+
return field == null ? void 0 : field.sample(longitude, latitude2, options);
|
|
16414
16420
|
const mapped = wrapTerrainLongitude(longitude, field.bounds[0], field.bounds[2]);
|
|
16415
|
-
return field.sample(mapped ?? longitude,
|
|
16421
|
+
return field.sample(mapped ?? longitude, latitude2, options);
|
|
16416
16422
|
};
|
|
16417
|
-
return probes.map(([longitude,
|
|
16418
|
-
const left = sample(a, longitude,
|
|
16419
|
-
const right = sample(b, longitude,
|
|
16423
|
+
return probes.map(([longitude, latitude2]) => {
|
|
16424
|
+
const left = sample(a, longitude, latitude2);
|
|
16425
|
+
const right = sample(b, longitude, latitude2);
|
|
16420
16426
|
const valid = (left == null ? void 0 : left.status) === TerrainSampleStatus.VALID && (right == null ? void 0 : right.status) === TerrainSampleStatus.VALID;
|
|
16421
16427
|
const derivatives = (left == null ? void 0 : left.gradientStatus) === TerrainSampleStatus.VALID && (right == null ? void 0 : right.gradientStatus) === TerrainSampleStatus.VALID;
|
|
16422
16428
|
const normalAngle = derivatives ? Math.atan2(Math.hypot(left.normalY * right.normalZ - left.normalZ * right.normalY, left.normalZ * right.normalX - left.normalX * right.normalZ, left.normalX * right.normalY - left.normalY * right.normalX), left.normalX * right.normalX + left.normalY * right.normalY + left.normalZ * right.normalZ) : null;
|
|
16423
16429
|
return {
|
|
16424
16430
|
longitude,
|
|
16425
|
-
latitude,
|
|
16431
|
+
latitude: latitude2,
|
|
16426
16432
|
statusA: (left == null ? void 0 : left.status) ?? TerrainSampleStatus.NOT_RESIDENT,
|
|
16427
16433
|
statusB: (right == null ? void 0 : right.status) ?? TerrainSampleStatus.NOT_RESIDENT,
|
|
16428
16434
|
gradientStatusA: (left == null ? void 0 : left.gradientStatus) ?? TerrainSampleStatus.NOT_RESIDENT,
|
|
@@ -17458,11 +17464,11 @@ function discoverGeographicTerrainLodSeams(cut2) {
|
|
|
17458
17464
|
|
|
17459
17465
|
// dist/terrain/geographic-poles.js
|
|
17460
17466
|
function discoverGeographicTerrainPoles(cut2) {
|
|
17461
|
-
function collect(
|
|
17467
|
+
function collect(latitude2, edge2) {
|
|
17462
17468
|
const incident = [];
|
|
17463
17469
|
for (let tile = 0; tile < cut2.length; tile++) {
|
|
17464
17470
|
const [west, south, east, north] = getGeographicTileBounds(cut2[tile]);
|
|
17465
|
-
if ((edge2 === "north" ? north : south) ===
|
|
17471
|
+
if ((edge2 === "north" ? north : south) === latitude2)
|
|
17466
17472
|
incident.push({ tile, edge: edge2, longitude: [west, east] });
|
|
17467
17473
|
}
|
|
17468
17474
|
incident.sort((a, b) => a.longitude[0] - b.longitude[0]);
|
|
@@ -17477,7 +17483,7 @@ function discoverGeographicTerrainPoles(cut2) {
|
|
|
17477
17483
|
}
|
|
17478
17484
|
if (cursor < 180)
|
|
17479
17485
|
gaps.push([cursor, 180]);
|
|
17480
|
-
return { latitude, incident, gaps };
|
|
17486
|
+
return { latitude: latitude2, incident, gaps };
|
|
17481
17487
|
}
|
|
17482
17488
|
return { north: collect(90, "north"), south: collect(-90, "south") };
|
|
17483
17489
|
}
|
|
@@ -17848,6 +17854,29 @@ function fillTerrainDepressions(field, { outlets, maxCells = 4194304 }) {
|
|
|
17848
17854
|
};
|
|
17849
17855
|
}
|
|
17850
17856
|
|
|
17857
|
+
// dist/terrain/cutout-region.js
|
|
17858
|
+
var PLAN = /* @__PURE__ */ Symbol.for("@math.gl/geospatial/terrain-cutout-polygons/v1");
|
|
17859
|
+
function createTerrainCutoutPlan(plan) {
|
|
17860
|
+
return Object.freeze({ [PLAN]: Object.freeze(plan) });
|
|
17861
|
+
}
|
|
17862
|
+
function getTerrainCutoutPlan(region) {
|
|
17863
|
+
if (Array.isArray(region))
|
|
17864
|
+
return void 0;
|
|
17865
|
+
const plan = region == null ? void 0 : region[PLAN];
|
|
17866
|
+
if (!plan)
|
|
17867
|
+
throw new RangeError("Invalid prepared terrain cutout polygons");
|
|
17868
|
+
return plan;
|
|
17869
|
+
}
|
|
17870
|
+
function copyTerrainCutoutRegion(region) {
|
|
17871
|
+
return getTerrainCutoutPlan(region) ? region : region.map((p) => [p[0], p[1]]);
|
|
17872
|
+
}
|
|
17873
|
+
function sameTerrainCutoutRegion(a, b) {
|
|
17874
|
+
if (getTerrainCutoutPlan(a) || getTerrainCutoutPlan(b))
|
|
17875
|
+
return a === b;
|
|
17876
|
+
const aa = a, bb = b;
|
|
17877
|
+
return aa.length === bb.length && aa.every((p, i) => bb[i].length === 2 && p[0] === bb[i][0] && p[1] === bb[i][1]);
|
|
17878
|
+
}
|
|
17879
|
+
|
|
17851
17880
|
// dist/terrain/mesh-cutout.js
|
|
17852
17881
|
function splitTerrainMesh(mesh, polygon2, { maxWork = 4e6, maxVertices = 5e5, maxTriangles = 5e5 } = {}) {
|
|
17853
17882
|
if (![maxWork, maxVertices, maxTriangles].every((n) => Number.isSafeInteger(n) && n >= 0) || maxVertices > 4294967295 || maxTriangles > 4294967295 || !(mesh.positions instanceof Float32Array || mesh.positions instanceof Float64Array) || !(mesh.indices instanceof Uint16Array || mesh.indices instanceof Uint32Array) || mesh.positions.length % 3 || mesh.indices.length % 3 || mesh.positions.length / 3 > maxVertices || mesh.indices.length / 3 > maxTriangles || !mesh.positions.every(Number.isFinite))
|
|
@@ -17858,7 +17887,9 @@ function splitTerrainMesh(mesh, polygon2, { maxWork = 4e6, maxVertices = 5e5, ma
|
|
|
17858
17887
|
if (work > maxWork)
|
|
17859
17888
|
throw new RangeError("Terrain cutout work budget exceeded");
|
|
17860
17889
|
}
|
|
17861
|
-
const
|
|
17890
|
+
const prepared2 = getTerrainCutoutPlan(polygon2);
|
|
17891
|
+
const ring = prepared2 ? void 0 : validatePolygon(polygon2, charge);
|
|
17892
|
+
const lines = (prepared2 == null ? void 0 : prepared2.lines) ?? ring.map((p, i) => [p, ring[(i + 1) % ring.length]]);
|
|
17862
17893
|
const vertices = [];
|
|
17863
17894
|
for (let i = 0; i < mesh.positions.length; i += 3)
|
|
17864
17895
|
vertices.push([mesh.positions[i], mesh.positions[i + 1], mesh.positions[i + 2]]);
|
|
@@ -17873,7 +17904,7 @@ function splitTerrainMesh(mesh, polygon2, { maxWork = 4e6, maxVertices = 5e5, ma
|
|
|
17873
17904
|
validateTopology(vertices, faces, charge);
|
|
17874
17905
|
const patch = createPiece();
|
|
17875
17906
|
const remainder = createPiece();
|
|
17876
|
-
const intersections2 =
|
|
17907
|
+
const intersections2 = lines.map(() => /* @__PURE__ */ new Map());
|
|
17877
17908
|
let fragmentCount = 0;
|
|
17878
17909
|
function addVertex(vertex) {
|
|
17879
17910
|
if (vertices.length >= maxVertices || !vertex.every(Number.isFinite))
|
|
@@ -17886,6 +17917,11 @@ function splitTerrainMesh(mesh, polygon2, { maxWork = 4e6, maxVertices = 5e5, ma
|
|
|
17886
17917
|
const saved = cache.get(key3);
|
|
17887
17918
|
if (saved !== void 0)
|
|
17888
17919
|
return saved;
|
|
17920
|
+
const pa = vertices[a], pb = vertices[b];
|
|
17921
|
+
if (pa[0] > pb[0] || pa[0] === pb[0] && (pa[1] > pb[1] || pa[1] === pb[1] && pa[2] > pb[2])) {
|
|
17922
|
+
[a, b] = [b, a];
|
|
17923
|
+
[da, db] = [db, da];
|
|
17924
|
+
}
|
|
17889
17925
|
const t = Math.abs(da) / (Math.abs(da) + Math.abs(db));
|
|
17890
17926
|
if (!(t > 0 && t < 1))
|
|
17891
17927
|
throw new RangeError("Unrepresentable terrain cut intersection");
|
|
@@ -17901,10 +17937,9 @@ function splitTerrainMesh(mesh, polygon2, { maxWork = 4e6, maxVertices = 5e5, ma
|
|
|
17901
17937
|
}
|
|
17902
17938
|
for (let source = 0; source < faces.length; source++) {
|
|
17903
17939
|
let fragments = [{ ids: faces[source], inside: true }];
|
|
17904
|
-
for (let line = 0; line <
|
|
17940
|
+
for (let line = 0; line < lines.length; line++) {
|
|
17905
17941
|
const next = [];
|
|
17906
|
-
const a =
|
|
17907
|
-
const b = ring[(line + 1) % ring.length];
|
|
17942
|
+
const [a, b] = lines[line];
|
|
17908
17943
|
for (const fragment of fragments) {
|
|
17909
17944
|
const { ids } = fragment;
|
|
17910
17945
|
charge(ids.length);
|
|
@@ -17941,22 +17976,26 @@ function splitTerrainMesh(mesh, polygon2, { maxWork = 4e6, maxVertices = 5e5, ma
|
|
|
17941
17976
|
}
|
|
17942
17977
|
fragmentCount += fragments.length;
|
|
17943
17978
|
for (const { ids, inside } of fragments) {
|
|
17944
|
-
|
|
17945
|
-
if (ids.length
|
|
17946
|
-
|
|
17947
|
-
else {
|
|
17948
|
-
const center = [...vertices[ids[0]]];
|
|
17979
|
+
let center;
|
|
17980
|
+
if (prepared2 || ids.length > 3) {
|
|
17981
|
+
center = [...vertices[ids[0]]];
|
|
17949
17982
|
for (const id of ids) {
|
|
17950
17983
|
for (let k = 0; k < 3; k++)
|
|
17951
17984
|
center[k] += (vertices[id][k] - vertices[ids[0]][k]) / ids.length;
|
|
17952
17985
|
}
|
|
17986
|
+
}
|
|
17987
|
+
const polygonIndex = prepared2 ? prepared2.classify([center[0], center[1]], charge) : inside ? 0 : -1;
|
|
17988
|
+
const piece = polygonIndex >= 0 ? patch : remainder;
|
|
17989
|
+
if (ids.length === 3)
|
|
17990
|
+
emit(piece, ids, source, polygonIndex);
|
|
17991
|
+
else {
|
|
17953
17992
|
const hub = addVertex(center);
|
|
17954
17993
|
for (let i = 0; i < ids.length; i++)
|
|
17955
|
-
emit(piece, [ids[i], ids[(i + 1) % ids.length], hub], source);
|
|
17994
|
+
emit(piece, [ids[i], ids[(i + 1) % ids.length], hub], source, polygonIndex);
|
|
17956
17995
|
}
|
|
17957
17996
|
}
|
|
17958
17997
|
}
|
|
17959
|
-
function emit(piece, face, source) {
|
|
17998
|
+
function emit(piece, face, source, polygonIndex) {
|
|
17960
17999
|
if (patch.sourceFaces.length + remainder.sourceFaces.length >= maxTriangles)
|
|
17961
18000
|
throw new RangeError("Terrain cutout triangle budget exceeded");
|
|
17962
18001
|
checkTriangle(vertices[face[0]], vertices[face[1]], vertices[face[2]]);
|
|
@@ -17974,9 +18013,10 @@ function splitTerrainMesh(mesh, polygon2, { maxWork = 4e6, maxVertices = 5e5, ma
|
|
|
17974
18013
|
piece.sourceWeights.push(cross6(b, c, p) / area, cross6(c, a, p) / area, cross6(a, b, p) / area);
|
|
17975
18014
|
}
|
|
17976
18015
|
piece.indices.push(piece.ids.get(id));
|
|
17977
|
-
addEdge(piece.boundary, id, face[(i + 1) % 3]);
|
|
18016
|
+
addEdge(piece.boundary, id, face[(i + 1) % 3], polygonIndex);
|
|
17978
18017
|
}
|
|
17979
18018
|
piece.sourceFaces.push(source);
|
|
18019
|
+
piece.polygonIndices.push(polygonIndex);
|
|
17980
18020
|
}
|
|
17981
18021
|
for (const [key3, inside] of patch.boundary) {
|
|
17982
18022
|
const outside = remainder.boundary.get(key3);
|
|
@@ -17987,6 +18027,8 @@ function splitTerrainMesh(mesh, polygon2, { maxWork = 4e6, maxVertices = 5e5, ma
|
|
|
17987
18027
|
throw new Error("Nonconforming terrain cut boundary");
|
|
17988
18028
|
patch.cutEdges.push(patch.ids.get(a), patch.ids.get(b));
|
|
17989
18029
|
remainder.cutEdges.push(remainder.ids.get(b), remainder.ids.get(a));
|
|
18030
|
+
patch.cutPolygonIndices.push(inside.polygon);
|
|
18031
|
+
remainder.cutPolygonIndices.push(inside.polygon);
|
|
17990
18032
|
}
|
|
17991
18033
|
return { patch: finish(patch), remainder: finish(remainder) };
|
|
17992
18034
|
}
|
|
@@ -18067,11 +18109,11 @@ function checkJunctions(a, b, vertices) {
|
|
|
18067
18109
|
throw new RangeError("Terrain cut input has an unwelded shared edge");
|
|
18068
18110
|
}
|
|
18069
18111
|
}
|
|
18070
|
-
function addEdge(edges2, a, b) {
|
|
18112
|
+
function addEdge(edges2, a, b, polygon2 = -1) {
|
|
18071
18113
|
const key3 = edgeKey2(a, b);
|
|
18072
18114
|
const entry = edges2.get(key3);
|
|
18073
18115
|
if (!entry)
|
|
18074
|
-
edges2.set(key3, { edge: [a, b], count: 1 });
|
|
18116
|
+
edges2.set(key3, { edge: [a, b], count: 1, polygon: polygon2 });
|
|
18075
18117
|
else {
|
|
18076
18118
|
if (entry.count !== 1 || entry.edge[0] !== b)
|
|
18077
18119
|
throw new RangeError("Terrain cut mesh has inconsistent or nonmanifold edges");
|
|
@@ -18093,7 +18135,9 @@ function createPiece() {
|
|
|
18093
18135
|
sourceWeights: [],
|
|
18094
18136
|
sourceFaces: [],
|
|
18095
18137
|
boundary: /* @__PURE__ */ new Map(),
|
|
18096
|
-
cutEdges: []
|
|
18138
|
+
cutEdges: [],
|
|
18139
|
+
polygonIndices: [],
|
|
18140
|
+
cutPolygonIndices: []
|
|
18097
18141
|
};
|
|
18098
18142
|
}
|
|
18099
18143
|
function finish(piece) {
|
|
@@ -18103,9 +18147,25 @@ function finish(piece) {
|
|
|
18103
18147
|
sourceTriangles: Uint32Array.from(piece.sourceTriangles),
|
|
18104
18148
|
sourceWeights: Float64Array.from(piece.sourceWeights),
|
|
18105
18149
|
sourceFaces: Uint32Array.from(piece.sourceFaces),
|
|
18106
|
-
cutEdges: Uint32Array.from(piece.cutEdges)
|
|
18150
|
+
cutEdges: Uint32Array.from(piece.cutEdges),
|
|
18151
|
+
polygonIndices: Uint32Array.from(piece.polygonIndices),
|
|
18152
|
+
cutPolygonIndices: Uint32Array.from(piece.cutPolygonIndices)
|
|
18107
18153
|
};
|
|
18108
18154
|
}
|
|
18155
|
+
function validateTerrainCutoutTopology(mesh, maxWork) {
|
|
18156
|
+
const vertices = [];
|
|
18157
|
+
const faces = [];
|
|
18158
|
+
for (let i = 0; i < mesh.positions.length; i += 3)
|
|
18159
|
+
vertices.push([mesh.positions[i], mesh.positions[i + 1], mesh.positions[i + 2]]);
|
|
18160
|
+
for (let i = 0; i < mesh.indices.length; i += 3)
|
|
18161
|
+
faces.push([mesh.indices[i], mesh.indices[i + 1], mesh.indices[i + 2]]);
|
|
18162
|
+
let work = 0;
|
|
18163
|
+
validateTopology(vertices, faces, (amount) => {
|
|
18164
|
+
work += amount;
|
|
18165
|
+
if (work > maxWork)
|
|
18166
|
+
throw new RangeError("Terrain cutout topology work budget exceeded");
|
|
18167
|
+
});
|
|
18168
|
+
}
|
|
18109
18169
|
|
|
18110
18170
|
// dist/terrain/cutout-skirts.js
|
|
18111
18171
|
function createTerrainCutoutSkirts(cutout, { lift = 0, patch, remainder }) {
|
|
@@ -18175,4 +18235,440 @@ function accumulateTerrainWatersheds(receiver, { maxCells = 4194304 } = {}) {
|
|
|
18175
18235
|
}
|
|
18176
18236
|
return { terminal, contributingCells };
|
|
18177
18237
|
}
|
|
18238
|
+
|
|
18239
|
+
// dist/terrain/tile-cutout.js
|
|
18240
|
+
function splitTerrainMeshTiles(tiles, polygon2, options = {}) {
|
|
18241
|
+
const assembled = assembleTerrainCutoutTiles(tiles, options);
|
|
18242
|
+
return {
|
|
18243
|
+
...splitTerrainMesh(assembled.mesh, polygon2, { ...options, maxWork: assembled.remainingWork }),
|
|
18244
|
+
sourceTiles: assembled.sourceTiles,
|
|
18245
|
+
sourceTileFaces: assembled.sourceTileFaces
|
|
18246
|
+
};
|
|
18247
|
+
}
|
|
18248
|
+
function assembleTerrainCutoutTiles(tiles, options = {}) {
|
|
18249
|
+
const maxVertices = options.maxVertices ?? 5e5;
|
|
18250
|
+
const maxTriangles = options.maxTriangles ?? 5e5;
|
|
18251
|
+
const maxWork = options.maxWork ?? 4e6;
|
|
18252
|
+
if (![maxVertices, maxTriangles, maxWork].every((n) => Number.isSafeInteger(n) && n >= 0) || maxVertices > 4294967295 || maxTriangles > 4294967295)
|
|
18253
|
+
throw new RangeError("Invalid terrain tile cutout limits");
|
|
18254
|
+
let vertexCount = 0;
|
|
18255
|
+
let faceCount = 0;
|
|
18256
|
+
let work = 0;
|
|
18257
|
+
for (const tile of tiles) {
|
|
18258
|
+
if (!(tile.positions instanceof Float32Array || tile.positions instanceof Float64Array) || !(tile.indices instanceof Uint16Array || tile.indices instanceof Uint32Array) || tile.positions.length % 3 || tile.indices.length % 3)
|
|
18259
|
+
throw new RangeError("Invalid terrain tile cutout mesh");
|
|
18260
|
+
vertexCount += tile.positions.length / 3;
|
|
18261
|
+
faceCount += tile.indices.length / 3;
|
|
18262
|
+
work += 1 + tile.positions.length / 3 + tile.indices.length;
|
|
18263
|
+
if (vertexCount > maxVertices || faceCount > maxTriangles || work > maxWork)
|
|
18264
|
+
throw new RangeError("Terrain tile cutout input budget exceeded");
|
|
18265
|
+
}
|
|
18266
|
+
const positions = new Float64Array(vertexCount * 3);
|
|
18267
|
+
const indices = new Uint32Array(faceCount * 3);
|
|
18268
|
+
const sourceTiles = new Uint32Array(faceCount);
|
|
18269
|
+
const sourceTileFaces = new Uint32Array(faceCount);
|
|
18270
|
+
const vertices = /* @__PURE__ */ new Map();
|
|
18271
|
+
let vertexOffset = 0;
|
|
18272
|
+
let faceOffset = 0;
|
|
18273
|
+
for (let tileIndex = 0; tileIndex < tiles.length; tileIndex++) {
|
|
18274
|
+
const tile = tiles[tileIndex];
|
|
18275
|
+
const remap = new Uint32Array(tile.positions.length / 3);
|
|
18276
|
+
for (let i = 0; i < remap.length; i++) {
|
|
18277
|
+
const x = tile.positions[i * 3];
|
|
18278
|
+
const y = tile.positions[i * 3 + 1];
|
|
18279
|
+
const z = tile.positions[i * 3 + 2];
|
|
18280
|
+
if (!Number.isFinite(x) || !Number.isFinite(y) || !Number.isFinite(z))
|
|
18281
|
+
throw new RangeError("Invalid terrain tile cutout coordinate");
|
|
18282
|
+
const key3 = `${x},${y},${z}`;
|
|
18283
|
+
let id = vertices.get(key3);
|
|
18284
|
+
if (id === void 0) {
|
|
18285
|
+
id = vertexOffset++;
|
|
18286
|
+
vertices.set(key3, id);
|
|
18287
|
+
positions[id * 3] = x;
|
|
18288
|
+
positions[id * 3 + 1] = y;
|
|
18289
|
+
positions[id * 3 + 2] = z;
|
|
18290
|
+
}
|
|
18291
|
+
remap[i] = id;
|
|
18292
|
+
}
|
|
18293
|
+
for (let i = 0; i < tile.indices.length; i++) {
|
|
18294
|
+
const id = tile.indices[i];
|
|
18295
|
+
if (id >= remap.length)
|
|
18296
|
+
throw new RangeError("Invalid terrain tile cutout index");
|
|
18297
|
+
indices[faceOffset * 3 + i] = remap[id];
|
|
18298
|
+
}
|
|
18299
|
+
for (let i = 0; i < tile.indices.length / 3; i++) {
|
|
18300
|
+
sourceTiles[faceOffset + i] = tileIndex;
|
|
18301
|
+
sourceTileFaces[faceOffset + i] = i;
|
|
18302
|
+
}
|
|
18303
|
+
faceOffset += tile.indices.length / 3;
|
|
18304
|
+
}
|
|
18305
|
+
return {
|
|
18306
|
+
mesh: { positions: positions.subarray(0, vertexOffset * 3), indices },
|
|
18307
|
+
sourceTiles,
|
|
18308
|
+
sourceTileFaces,
|
|
18309
|
+
remainingWork: maxWork - work
|
|
18310
|
+
};
|
|
18311
|
+
}
|
|
18312
|
+
|
|
18313
|
+
// dist/terrain/tile-cutout-update.js
|
|
18314
|
+
var CACHE = /* @__PURE__ */ Symbol("terrain-cutout-cache");
|
|
18315
|
+
function updateTerrainTileCutouts(residents, polygon2, previous, options = {}) {
|
|
18316
|
+
const limits = {
|
|
18317
|
+
maxTiles: options.maxTiles ?? 512,
|
|
18318
|
+
maxPairChecks: options.maxPairChecks ?? 131072,
|
|
18319
|
+
maxBoundaryEdges: options.maxBoundaryEdges ?? 1e6,
|
|
18320
|
+
maxWork: options.maxWork ?? 4e6,
|
|
18321
|
+
maxVertices: options.maxVertices ?? 5e5,
|
|
18322
|
+
maxTriangles: options.maxTriangles ?? 5e5
|
|
18323
|
+
};
|
|
18324
|
+
if (Object.values(limits).some((n) => !Number.isSafeInteger(n) || n < 0) || limits.maxVertices > 4294967295 || limits.maxTriangles > 4294967295 || residents.length > limits.maxTiles)
|
|
18325
|
+
throw new RangeError("Invalid terrain cutout update limits");
|
|
18326
|
+
const prior = previous == null ? void 0 : previous[CACHE];
|
|
18327
|
+
const compatible = prior && sameTerrainCutoutRegion(prior.polygon, polygon2) && Object.keys(limits).every((key3) => prior.options[key3] === limits[key3]);
|
|
18328
|
+
if (!compatible)
|
|
18329
|
+
splitTerrainMesh({ positions: new Float64Array(), indices: new Uint32Array() }, polygon2, limits);
|
|
18330
|
+
const entries = /* @__PURE__ */ new Map();
|
|
18331
|
+
const rebuilt = [];
|
|
18332
|
+
let boundaryCount = 0;
|
|
18333
|
+
for (const resident of residents) {
|
|
18334
|
+
if (!resident.id || typeof resident.id !== "string" || entries.has(resident.id) || !Number.isSafeInteger(resident.revision) || resident.revision < 0)
|
|
18335
|
+
throw new RangeError("Invalid or duplicate terrain cutout resident");
|
|
18336
|
+
const old = compatible ? prior.entries.get(resident.id) : void 0;
|
|
18337
|
+
let entry;
|
|
18338
|
+
if (old && old.resident.mesh === resident.mesh && old.resident.revision === resident.revision)
|
|
18339
|
+
entry = old;
|
|
18340
|
+
else {
|
|
18341
|
+
const split = splitTerrainMesh(resident.mesh, polygon2, limits);
|
|
18342
|
+
const edges2 = [...boundaryEdges(split.patch, 0), ...boundaryEdges(split.remainder, 1)];
|
|
18343
|
+
const bounds2 = [Infinity, Infinity, -Infinity, -Infinity];
|
|
18344
|
+
for (const id of resident.mesh.indices) {
|
|
18345
|
+
const x = resident.mesh.positions[id * 3], y = resident.mesh.positions[id * 3 + 1];
|
|
18346
|
+
bounds2[0] = Math.min(bounds2[0], x);
|
|
18347
|
+
bounds2[1] = Math.min(bounds2[1], y);
|
|
18348
|
+
bounds2[2] = Math.max(bounds2[2], x);
|
|
18349
|
+
bounds2[3] = Math.max(bounds2[3], y);
|
|
18350
|
+
}
|
|
18351
|
+
entry = { resident: { ...resident }, split, displayed: split, bounds: bounds2, edges: edges2 };
|
|
18352
|
+
rebuilt.push(resident.id);
|
|
18353
|
+
}
|
|
18354
|
+
boundaryCount += entry.edges.length;
|
|
18355
|
+
if (boundaryCount > limits.maxBoundaryEdges)
|
|
18356
|
+
throw new RangeError("Terrain cutout boundary budget exceeded");
|
|
18357
|
+
entries.set(resident.id, entry);
|
|
18358
|
+
}
|
|
18359
|
+
const values = [...entries.values()];
|
|
18360
|
+
let pairs = 0;
|
|
18361
|
+
for (let i = 0; i < values.length; i++)
|
|
18362
|
+
for (let j = i + 1; j < values.length; j++) {
|
|
18363
|
+
if (++pairs > limits.maxPairChecks)
|
|
18364
|
+
throw new RangeError("Terrain cutout pair budget exceeded");
|
|
18365
|
+
const a = values[i], b = values[j];
|
|
18366
|
+
if (a.bounds[2] < b.bounds[0] || b.bounds[2] < a.bounds[0] || a.bounds[3] < b.bounds[1] || b.bounds[3] < a.bounds[1])
|
|
18367
|
+
continue;
|
|
18368
|
+
if (compatible && prior.entries.get(a.resident.id) === a && prior.entries.get(b.resident.id) === b)
|
|
18369
|
+
continue;
|
|
18370
|
+
const combined = assembleTerrainCutoutTiles([a.resident.mesh, b.resident.mesh], limits);
|
|
18371
|
+
validateTerrainCutoutTopology(combined.mesh, combined.remainingWork);
|
|
18372
|
+
}
|
|
18373
|
+
const boundaries = /* @__PURE__ */ new Map();
|
|
18374
|
+
const cutKeys = /* @__PURE__ */ new Map();
|
|
18375
|
+
for (let tile = 0; tile < values.length; tile++)
|
|
18376
|
+
for (const edge2 of values[tile].edges) {
|
|
18377
|
+
const other = boundaries.get(edge2.key);
|
|
18378
|
+
if (!other) {
|
|
18379
|
+
boundaries.set(edge2.key, { edge: edge2, paired: false });
|
|
18380
|
+
continue;
|
|
18381
|
+
}
|
|
18382
|
+
if (other.paired || other.edge.start !== edge2.end || other.edge.end !== edge2.start)
|
|
18383
|
+
throw new RangeError("Nonconforming terrain cutout tile boundary");
|
|
18384
|
+
other.paired = true;
|
|
18385
|
+
if (other.edge.side !== edge2.side) {
|
|
18386
|
+
cutKeys.set(edge2.key, edge2.side === 0 ? edge2.polygon : other.edge.polygon);
|
|
18387
|
+
}
|
|
18388
|
+
}
|
|
18389
|
+
const tiles = /* @__PURE__ */ new Map();
|
|
18390
|
+
const changed = [];
|
|
18391
|
+
for (let i = 0; i < values.length; i++) {
|
|
18392
|
+
const entry = values[i];
|
|
18393
|
+
const old = prior == null ? void 0 : prior.entries.get(entry.resident.id);
|
|
18394
|
+
const cuts = [[], []];
|
|
18395
|
+
const polygons2 = [[], []];
|
|
18396
|
+
for (const edge2 of entry.edges) {
|
|
18397
|
+
const polygonIndex = cutKeys.get(edge2.key);
|
|
18398
|
+
if (polygonIndex !== void 0) {
|
|
18399
|
+
cuts[edge2.side].push(edge2.a, edge2.b);
|
|
18400
|
+
polygons2[edge2.side].push(polygonIndex);
|
|
18401
|
+
}
|
|
18402
|
+
}
|
|
18403
|
+
const patch = withEdges(entry.split.patch, cuts[0], polygons2[0], old == null ? void 0 : old.displayed.patch);
|
|
18404
|
+
const remainder = withEdges(entry.split.remainder, cuts[1], polygons2[1], old == null ? void 0 : old.displayed.remainder);
|
|
18405
|
+
const displayed = old && patch === old.displayed.patch && remainder === old.displayed.remainder ? old.displayed : { patch, remainder };
|
|
18406
|
+
if (displayed !== (old == null ? void 0 : old.displayed))
|
|
18407
|
+
changed.push(entry.resident.id);
|
|
18408
|
+
entries.set(entry.resident.id, displayed === entry.displayed ? entry : { ...entry, displayed });
|
|
18409
|
+
tiles.set(entry.resident.id, displayed);
|
|
18410
|
+
}
|
|
18411
|
+
return {
|
|
18412
|
+
cache: { [CACHE]: { polygon: copyTerrainCutoutRegion(polygon2), options: limits, entries } },
|
|
18413
|
+
tiles,
|
|
18414
|
+
changed,
|
|
18415
|
+
rebuilt,
|
|
18416
|
+
removed: prior ? [...prior.entries.keys()].filter((id) => !entries.has(id)) : []
|
|
18417
|
+
};
|
|
18418
|
+
}
|
|
18419
|
+
function withEdges(piece, edges2, polygons2, old) {
|
|
18420
|
+
const same2 = old && old.positions === piece.positions && old.cutEdges.length === edges2.length && old.cutEdges.every((id, i) => id === edges2[i]) && old.cutPolygonIndices.every((id, i) => id === polygons2[i]);
|
|
18421
|
+
return same2 ? old : { ...piece, cutEdges: Uint32Array.from(edges2), cutPolygonIndices: Uint32Array.from(polygons2) };
|
|
18422
|
+
}
|
|
18423
|
+
function boundaryEdges(piece, side) {
|
|
18424
|
+
const edges2 = /* @__PURE__ */ new Map();
|
|
18425
|
+
for (let i = 0; i < piece.indices.length; i += 3)
|
|
18426
|
+
for (let j = 0; j < 3; j++) {
|
|
18427
|
+
const a = piece.indices[i + j], b = piece.indices[i + (j + 1) % 3];
|
|
18428
|
+
const key3 = a < b ? `${a},${b}` : `${b},${a}`;
|
|
18429
|
+
const old = edges2.get(key3);
|
|
18430
|
+
if (old)
|
|
18431
|
+
old.count++;
|
|
18432
|
+
else
|
|
18433
|
+
edges2.set(key3, { a, b, count: 1, polygon: piece.polygonIndices[i / 3] });
|
|
18434
|
+
}
|
|
18435
|
+
const result = [];
|
|
18436
|
+
const point2 = (id) => `${piece.positions[id * 3]},${piece.positions[id * 3 + 1]},${piece.positions[id * 3 + 2]}`;
|
|
18437
|
+
for (const { a, b, count, polygon: polygon2 } of edges2.values())
|
|
18438
|
+
if (count === 1) {
|
|
18439
|
+
const start = point2(a), end = point2(b);
|
|
18440
|
+
result.push({
|
|
18441
|
+
polygon: polygon2,
|
|
18442
|
+
a,
|
|
18443
|
+
b,
|
|
18444
|
+
side,
|
|
18445
|
+
start,
|
|
18446
|
+
end,
|
|
18447
|
+
key: start < end ? `${start}/${end}` : `${end}/${start}`
|
|
18448
|
+
});
|
|
18449
|
+
}
|
|
18450
|
+
return result;
|
|
18451
|
+
}
|
|
18452
|
+
|
|
18453
|
+
// dist/terrain/geographic-cutout.js
|
|
18454
|
+
var RAD = Math.PI / 180;
|
|
18455
|
+
function createGeographicTerrainCutoutFrame(options) {
|
|
18456
|
+
if (options.center.length !== 2)
|
|
18457
|
+
throw new RangeError("Invalid geographic terrain cutout center");
|
|
18458
|
+
const frame2 = {
|
|
18459
|
+
center: [wrap2(options.center[0]), options.center[1]],
|
|
18460
|
+
radius: options.radius ?? 6378137,
|
|
18461
|
+
maxAngularRadius: options.maxAngularRadius ?? 30
|
|
18462
|
+
};
|
|
18463
|
+
validateFrame(frame2);
|
|
18464
|
+
return Object.freeze({ ...frame2, center: Object.freeze(frame2.center) });
|
|
18465
|
+
}
|
|
18466
|
+
function projectGeographicTerrainCutout(positions, frame2) {
|
|
18467
|
+
var _a;
|
|
18468
|
+
validateFrame(frame2);
|
|
18469
|
+
validatePositions(positions);
|
|
18470
|
+
const result = new Float64Array(positions.length);
|
|
18471
|
+
const [sin0, cos0] = latitude(frame2.center[1]);
|
|
18472
|
+
const maximum = chartLimit(frame2);
|
|
18473
|
+
for (let i = 0; i < positions.length; i += 3) {
|
|
18474
|
+
const lon = positions[i], lat = positions[i + 1];
|
|
18475
|
+
if (lat < -90 || lat > 90)
|
|
18476
|
+
throw new RangeError("Invalid geographic terrain latitude");
|
|
18477
|
+
const sin = Math.sin(lat * RAD);
|
|
18478
|
+
const cos = Math.abs(lat) === 90 ? 0 : Math.cos(lat * RAD);
|
|
18479
|
+
const delta = wrap2(wrap2(lon) - frame2.center[0]) * RAD;
|
|
18480
|
+
const dot5 = sin0 * sin + cos0 * cos * Math.cos(delta);
|
|
18481
|
+
const x = cos * Math.sin(delta) / dot5;
|
|
18482
|
+
const y = (cos0 * sin - sin0 * cos * Math.cos(delta)) / dot5;
|
|
18483
|
+
if (!(dot5 > 0) || Math.hypot(x, y) > maximum)
|
|
18484
|
+
throw new RangeError("Terrain coordinate exceeds geographic cutout chart");
|
|
18485
|
+
result[i] = frame2.radius * x;
|
|
18486
|
+
result[i + 1] = frame2.radius * y;
|
|
18487
|
+
result[i] || (result[i] = 0);
|
|
18488
|
+
result[_a = i + 1] || (result[_a] = 0);
|
|
18489
|
+
result[i + 2] = positions[i + 2];
|
|
18490
|
+
}
|
|
18491
|
+
if (!result.every(Number.isFinite))
|
|
18492
|
+
throw new RangeError("Geographic terrain projection overflow");
|
|
18493
|
+
return result;
|
|
18494
|
+
}
|
|
18495
|
+
function unprojectGeographicTerrainCutout(positions, frame2) {
|
|
18496
|
+
validateFrame(frame2);
|
|
18497
|
+
validatePositions(positions);
|
|
18498
|
+
const result = new Float64Array(positions.length);
|
|
18499
|
+
const [sin0, cos0] = latitude(frame2.center[1]);
|
|
18500
|
+
const maximum = chartLimit(frame2);
|
|
18501
|
+
for (let i = 0; i < positions.length; i += 3) {
|
|
18502
|
+
const x = positions[i] / frame2.radius, y = positions[i + 1] / frame2.radius;
|
|
18503
|
+
const distance = Math.hypot(x, y);
|
|
18504
|
+
if (!Number.isFinite(distance) || distance > maximum)
|
|
18505
|
+
throw new RangeError("Terrain coordinate exceeds geographic cutout chart");
|
|
18506
|
+
const horizontal = cos0 - y * sin0;
|
|
18507
|
+
const vertical = sin0 + y * cos0;
|
|
18508
|
+
const lat = Math.atan2(vertical, Math.hypot(horizontal, x)) / RAD;
|
|
18509
|
+
result[i] = Math.abs(lat) === 90 ? frame2.center[0] : wrap2(frame2.center[0] + Math.atan2(x, horizontal) / RAD);
|
|
18510
|
+
result[i + 1] = lat;
|
|
18511
|
+
result[i + 2] = positions[i + 2];
|
|
18512
|
+
}
|
|
18513
|
+
return result;
|
|
18514
|
+
}
|
|
18515
|
+
function wrap2(longitude) {
|
|
18516
|
+
const result = longitude % 360;
|
|
18517
|
+
return result >= 180 ? result - 360 : result < -180 ? result + 360 : result;
|
|
18518
|
+
}
|
|
18519
|
+
function latitude(degrees2) {
|
|
18520
|
+
return [Math.sin(degrees2 * RAD), Math.abs(degrees2) === 90 ? 0 : Math.cos(degrees2 * RAD)];
|
|
18521
|
+
}
|
|
18522
|
+
function validateFrame(frame2) {
|
|
18523
|
+
if (frame2.center.length !== 2 || !frame2.center.every(Number.isFinite) || frame2.center[0] < -180 || frame2.center[0] >= 180 || Math.abs(frame2.center[1]) > 90 || !Number.isFinite(frame2.radius) || frame2.radius <= 0 || !Number.isFinite(frame2.maxAngularRadius) || frame2.maxAngularRadius <= 0 || frame2.maxAngularRadius > 80)
|
|
18524
|
+
throw new RangeError("Invalid geographic terrain cutout frame");
|
|
18525
|
+
}
|
|
18526
|
+
function validatePositions(positions) {
|
|
18527
|
+
if (!(positions instanceof Float32Array || positions instanceof Float64Array) || positions.length % 3 || !positions.every(Number.isFinite))
|
|
18528
|
+
throw new RangeError("Invalid geographic terrain cutout positions");
|
|
18529
|
+
}
|
|
18530
|
+
function chartLimit(frame2) {
|
|
18531
|
+
const distance = Math.tan(frame2.maxAngularRadius * RAD);
|
|
18532
|
+
return distance + 16 * Number.EPSILON * (1 + distance);
|
|
18533
|
+
}
|
|
18534
|
+
|
|
18535
|
+
// dist/terrain/cutout-polygons.js
|
|
18536
|
+
function prepareTerrainCutoutPolygons(polygons2, { maxEdges = 2048, maxWork = 4e6 } = {}) {
|
|
18537
|
+
if (![maxEdges, maxWork].every((n) => Number.isSafeInteger(n) && n >= 0) || !polygons2.length)
|
|
18538
|
+
throw new RangeError("Invalid terrain cutout polygon limits or empty set");
|
|
18539
|
+
let work = 0, edgeCount = 0;
|
|
18540
|
+
const charge = (amount) => {
|
|
18541
|
+
work += amount;
|
|
18542
|
+
if (work > maxWork)
|
|
18543
|
+
throw new RangeError("Terrain cutout polygon work budget exceeded");
|
|
18544
|
+
};
|
|
18545
|
+
if (polygons2.length > Math.floor(maxEdges / 3))
|
|
18546
|
+
throw new RangeError("Terrain cutout polygon edge budget exceeded");
|
|
18547
|
+
const regions = polygons2.map((p) => {
|
|
18548
|
+
var _a;
|
|
18549
|
+
if (1 + (((_a = p.holes) == null ? void 0 : _a.length) ?? 0) > Math.floor((maxEdges - edgeCount) / 3))
|
|
18550
|
+
throw new RangeError("Terrain cutout polygon edge budget exceeded");
|
|
18551
|
+
return [p.outer, ...p.holes ?? []].map((ring) => {
|
|
18552
|
+
edgeCount += ring.length;
|
|
18553
|
+
if (edgeCount > maxEdges)
|
|
18554
|
+
throw new RangeError("Terrain cutout polygon edge budget exceeded");
|
|
18555
|
+
charge(ring.length);
|
|
18556
|
+
if (ring.length < 3 || ring.some((p2) => p2.length !== 2 || !p2.every(Number.isFinite)))
|
|
18557
|
+
throw new RangeError("Invalid terrain cutout polygon ring");
|
|
18558
|
+
return ring.map((p2) => Object.freeze([p2[0], p2[1]]));
|
|
18559
|
+
});
|
|
18560
|
+
});
|
|
18561
|
+
const rings = regions.flat();
|
|
18562
|
+
for (const ring of rings) {
|
|
18563
|
+
let area = 0;
|
|
18564
|
+
for (let i = 0; i < ring.length; i++) {
|
|
18565
|
+
charge(1);
|
|
18566
|
+
const a = ring[i], b = ring[(i + 1) % ring.length], c = ring[(i + 2) % ring.length];
|
|
18567
|
+
if (equal(a, b))
|
|
18568
|
+
throw new RangeError("Duplicate terrain cutout ring vertex");
|
|
18569
|
+
area += orient2(ring[0], a, b);
|
|
18570
|
+
if (orient2(a, b, c) === 0 && (a[0] - b[0]) * (c[0] - b[0]) + (a[1] - b[1]) * (c[1] - b[1]) >= 0)
|
|
18571
|
+
throw new RangeError("Backtracking terrain cutout ring edge");
|
|
18572
|
+
for (let j = i + 1; j < ring.length; j++) {
|
|
18573
|
+
if (j === i + 1 || i === 0 && j === ring.length - 1)
|
|
18574
|
+
continue;
|
|
18575
|
+
charge(1);
|
|
18576
|
+
if (intersects2(a, b, ring[j], ring[(j + 1) % ring.length]))
|
|
18577
|
+
throw new RangeError("Self-intersecting terrain cutout ring");
|
|
18578
|
+
}
|
|
18579
|
+
}
|
|
18580
|
+
if (!Number.isFinite(area) || area === 0)
|
|
18581
|
+
throw new RangeError("Degenerate terrain cutout ring");
|
|
18582
|
+
}
|
|
18583
|
+
for (let i = 0; i < rings.length; i++)
|
|
18584
|
+
for (let j = i + 1; j < rings.length; j++) {
|
|
18585
|
+
const a = rings[i], b = rings[j];
|
|
18586
|
+
for (let x = 0; x < a.length; x++)
|
|
18587
|
+
for (let y = 0; y < b.length; y++) {
|
|
18588
|
+
charge(1);
|
|
18589
|
+
if (intersects2(a[x], a[(x + 1) % a.length], b[y], b[(y + 1) % b.length]))
|
|
18590
|
+
throw new RangeError("Terrain cutout rings must not touch or intersect");
|
|
18591
|
+
}
|
|
18592
|
+
}
|
|
18593
|
+
for (const region of regions)
|
|
18594
|
+
for (let i = 1; i < region.length; i++) {
|
|
18595
|
+
if (contains2(region[0], region[i][0], charge) !== 1)
|
|
18596
|
+
throw new RangeError("Terrain cutout hole must be strictly inside its outer ring");
|
|
18597
|
+
for (let j = 1; j < i; j++)
|
|
18598
|
+
if (contains2(region[j], region[i][0], charge) === 1 || contains2(region[i], region[j][0], charge) === 1)
|
|
18599
|
+
throw new RangeError("Nested terrain cutout holes are not supported");
|
|
18600
|
+
}
|
|
18601
|
+
function inRegion(region, point2, budget) {
|
|
18602
|
+
const outer = contains2(region[0], point2, budget);
|
|
18603
|
+
if (outer !== 1)
|
|
18604
|
+
return outer;
|
|
18605
|
+
for (let i = 1; i < region.length; i++) {
|
|
18606
|
+
const hole = contains2(region[i], point2, budget);
|
|
18607
|
+
if (hole === 0)
|
|
18608
|
+
return 0;
|
|
18609
|
+
if (hole === 1)
|
|
18610
|
+
return -1;
|
|
18611
|
+
}
|
|
18612
|
+
return 1;
|
|
18613
|
+
}
|
|
18614
|
+
for (let i = 0; i < regions.length; i++)
|
|
18615
|
+
for (let j = i + 1; j < regions.length; j++) {
|
|
18616
|
+
if (inRegion(regions[i], regions[j][0][0], charge) === 1 || inRegion(regions[j], regions[i][0][0], charge) === 1)
|
|
18617
|
+
throw new RangeError("Overlapping terrain cutout polygon domains");
|
|
18618
|
+
}
|
|
18619
|
+
const lines = [];
|
|
18620
|
+
for (const ring of rings)
|
|
18621
|
+
for (let i = 0; i < ring.length; i++) {
|
|
18622
|
+
const a = ring[i], b = ring[(i + 1) % ring.length];
|
|
18623
|
+
if (lines.some(([u, v]) => {
|
|
18624
|
+
charge(1);
|
|
18625
|
+
return orient2(u, v, a) === 0 && orient2(u, v, b) === 0;
|
|
18626
|
+
}))
|
|
18627
|
+
continue;
|
|
18628
|
+
lines.push(a[0] < b[0] || a[0] === b[0] && a[1] < b[1] ? [a, b] : [b, a]);
|
|
18629
|
+
}
|
|
18630
|
+
return createTerrainCutoutPlan({
|
|
18631
|
+
lines: Object.freeze(lines.map((line) => Object.freeze(line))),
|
|
18632
|
+
classify(point2, budget) {
|
|
18633
|
+
for (let i = 0; i < regions.length; i++) {
|
|
18634
|
+
const result = inRegion(regions[i], point2, budget);
|
|
18635
|
+
if (result === 0)
|
|
18636
|
+
throw new RangeError("Unrepresentable terrain cutout fragment interior");
|
|
18637
|
+
if (result === 1)
|
|
18638
|
+
return i;
|
|
18639
|
+
}
|
|
18640
|
+
return -1;
|
|
18641
|
+
}
|
|
18642
|
+
});
|
|
18643
|
+
}
|
|
18644
|
+
function equal(a, b) {
|
|
18645
|
+
return a[0] === b[0] && a[1] === b[1];
|
|
18646
|
+
}
|
|
18647
|
+
function orient2(a, b, c) {
|
|
18648
|
+
const value3 = (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0]);
|
|
18649
|
+
if (!Number.isFinite(value3))
|
|
18650
|
+
throw new RangeError("Terrain cutout polygon coordinate overflow");
|
|
18651
|
+
return value3;
|
|
18652
|
+
}
|
|
18653
|
+
function onSegment2(a, b, p) {
|
|
18654
|
+
return p[0] >= Math.min(a[0], b[0]) && p[0] <= Math.max(a[0], b[0]) && p[1] >= Math.min(a[1], b[1]) && p[1] <= Math.max(a[1], b[1]);
|
|
18655
|
+
}
|
|
18656
|
+
function intersects2(a, b, c, d) {
|
|
18657
|
+
const abC = orient2(a, b, c), abD = orient2(a, b, d), cdA = orient2(c, d, a), cdB = orient2(c, d, b);
|
|
18658
|
+
return abC === 0 && onSegment2(a, b, c) || abD === 0 && onSegment2(a, b, d) || cdA === 0 && onSegment2(c, d, a) || cdB === 0 && onSegment2(c, d, b) || (abC > 0 && abD < 0 || abC < 0 && abD > 0) && (cdA > 0 && cdB < 0 || cdA < 0 && cdB > 0);
|
|
18659
|
+
}
|
|
18660
|
+
function contains2(ring, p, charge) {
|
|
18661
|
+
let winding3 = 0;
|
|
18662
|
+
for (let i = 0; i < ring.length; i++) {
|
|
18663
|
+
charge(1);
|
|
18664
|
+
const a = ring[i], b = ring[(i + 1) % ring.length], cross7 = orient2(a, b, p);
|
|
18665
|
+
if (cross7 === 0 && onSegment2(a, b, p))
|
|
18666
|
+
return 0;
|
|
18667
|
+
if (a[1] <= p[1] && b[1] > p[1] && cross7 > 0)
|
|
18668
|
+
winding3++;
|
|
18669
|
+
if (a[1] > p[1] && b[1] <= p[1] && cross7 < 0)
|
|
18670
|
+
winding3--;
|
|
18671
|
+
}
|
|
18672
|
+
return winding3 === 0 ? -1 : 1;
|
|
18673
|
+
}
|
|
18178
18674
|
//# sourceMappingURL=index.cjs.map
|