@trackunit/geo-json-utils 1.15.21 → 1.15.22-alpha-3e7014314a8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs.js +1 -18
- package/index.esm.js +1 -18
- package/package.json +1 -1
- package/src/GeoJsonUtils.d.ts +0 -9
- package/migrations/entry.js.map +0 -1
package/index.cjs.js
CHANGED
|
@@ -900,20 +900,12 @@ const getPolygonFromPointAndRadius = (point, radius) => {
|
|
|
900
900
|
const deltaLat = (radius / EARTH_RADIUS) * (180 / Math.PI);
|
|
901
901
|
const deltaLon = deltaLat / Math.cos((lat * Math.PI) / 180);
|
|
902
902
|
const coordinates = [];
|
|
903
|
-
for (let i = 0; i
|
|
903
|
+
for (let i = 0; i <= pointsCount; i++) {
|
|
904
904
|
const angle = i * angleStep;
|
|
905
905
|
const newLat = Math.max(-90, Math.min(90, lat + deltaLat * Math.sin(angle)));
|
|
906
906
|
const newLon = lonCenter + deltaLon * Math.cos(angle);
|
|
907
907
|
coordinates.push([newLon, newLat]);
|
|
908
908
|
}
|
|
909
|
-
// Close the ring by copying vertex 0 rather than recomputing it at angle 2π: Math.sin(2π) is
|
|
910
|
-
// -2.449e-16, and near the equator that offset exceeds half an ulp of the latitude, leaving the
|
|
911
|
-
// ring open and failing RFC 7946 validation.
|
|
912
|
-
const firstVertex = coordinates[0];
|
|
913
|
-
if (firstVertex === undefined) {
|
|
914
|
-
return null;
|
|
915
|
-
}
|
|
916
|
-
coordinates.push([...firstVertex]);
|
|
917
909
|
const rawLngs = coordinates.map(c => c[0]);
|
|
918
910
|
const minRawLon = Math.min(...rawLngs);
|
|
919
911
|
const maxRawLon = Math.max(...rawLngs);
|
|
@@ -1285,15 +1277,6 @@ const isFullyContainedInGeoJsonPolygon = (polygon1, polygon2) => {
|
|
|
1285
1277
|
/**
|
|
1286
1278
|
* @description Gets the intersection between two GeoJSON polygons/multi-polygons.
|
|
1287
1279
|
* Returns a MultiPolygon representing the intersection, or null if there is no intersection.
|
|
1288
|
-
*
|
|
1289
|
-
* Delegates to `polygon-clipping`, which can **throw** `"Unable to complete output ring"`
|
|
1290
|
-
* for degenerate or near-self-intersecting geometry that is still schema-valid. Callers must
|
|
1291
|
-
* decide how to handle that: `null` here is reserved for a *provably empty* intersection, so
|
|
1292
|
-
* a thrown failure must not be silently folded into `null` (see SAGA-743). Callers for which
|
|
1293
|
-
* "no overlap" is a safe degradation (e.g. overlap grouping in `@trackunit/react-map`) should
|
|
1294
|
-
* catch and treat the throw as no intersection; callers that turn `null` into "no spatial
|
|
1295
|
-
* filter" (e.g. `mapUtils` viewport/area merges) must instead fall back to a conservative
|
|
1296
|
-
* geometry rather than assume disjointness.
|
|
1297
1280
|
*/
|
|
1298
1281
|
const getGeoJsonPolygonIntersection = (polygon1, polygon2) => {
|
|
1299
1282
|
const geom1 = polygon1.type === "MultiPolygon" ? toClipMultiPolygon(polygon1.coordinates) : [toClipPolygon(polygon1.coordinates)];
|
package/index.esm.js
CHANGED
|
@@ -898,20 +898,12 @@ const getPolygonFromPointAndRadius = (point, radius) => {
|
|
|
898
898
|
const deltaLat = (radius / EARTH_RADIUS) * (180 / Math.PI);
|
|
899
899
|
const deltaLon = deltaLat / Math.cos((lat * Math.PI) / 180);
|
|
900
900
|
const coordinates = [];
|
|
901
|
-
for (let i = 0; i
|
|
901
|
+
for (let i = 0; i <= pointsCount; i++) {
|
|
902
902
|
const angle = i * angleStep;
|
|
903
903
|
const newLat = Math.max(-90, Math.min(90, lat + deltaLat * Math.sin(angle)));
|
|
904
904
|
const newLon = lonCenter + deltaLon * Math.cos(angle);
|
|
905
905
|
coordinates.push([newLon, newLat]);
|
|
906
906
|
}
|
|
907
|
-
// Close the ring by copying vertex 0 rather than recomputing it at angle 2π: Math.sin(2π) is
|
|
908
|
-
// -2.449e-16, and near the equator that offset exceeds half an ulp of the latitude, leaving the
|
|
909
|
-
// ring open and failing RFC 7946 validation.
|
|
910
|
-
const firstVertex = coordinates[0];
|
|
911
|
-
if (firstVertex === undefined) {
|
|
912
|
-
return null;
|
|
913
|
-
}
|
|
914
|
-
coordinates.push([...firstVertex]);
|
|
915
907
|
const rawLngs = coordinates.map(c => c[0]);
|
|
916
908
|
const minRawLon = Math.min(...rawLngs);
|
|
917
909
|
const maxRawLon = Math.max(...rawLngs);
|
|
@@ -1283,15 +1275,6 @@ const isFullyContainedInGeoJsonPolygon = (polygon1, polygon2) => {
|
|
|
1283
1275
|
/**
|
|
1284
1276
|
* @description Gets the intersection between two GeoJSON polygons/multi-polygons.
|
|
1285
1277
|
* Returns a MultiPolygon representing the intersection, or null if there is no intersection.
|
|
1286
|
-
*
|
|
1287
|
-
* Delegates to `polygon-clipping`, which can **throw** `"Unable to complete output ring"`
|
|
1288
|
-
* for degenerate or near-self-intersecting geometry that is still schema-valid. Callers must
|
|
1289
|
-
* decide how to handle that: `null` here is reserved for a *provably empty* intersection, so
|
|
1290
|
-
* a thrown failure must not be silently folded into `null` (see SAGA-743). Callers for which
|
|
1291
|
-
* "no overlap" is a safe degradation (e.g. overlap grouping in `@trackunit/react-map`) should
|
|
1292
|
-
* catch and treat the throw as no intersection; callers that turn `null` into "no spatial
|
|
1293
|
-
* filter" (e.g. `mapUtils` viewport/area merges) must instead fall back to a conservative
|
|
1294
|
-
* geometry rather than assume disjointness.
|
|
1295
1278
|
*/
|
|
1296
1279
|
const getGeoJsonPolygonIntersection = (polygon1, polygon2) => {
|
|
1297
1280
|
const geom1 = polygon1.type === "MultiPolygon" ? toClipMultiPolygon(polygon1.coordinates) : [toClipPolygon(polygon1.coordinates)];
|
package/package.json
CHANGED
package/src/GeoJsonUtils.d.ts
CHANGED
|
@@ -100,15 +100,6 @@ export declare const isFullyContainedInGeoJsonPolygon: (polygon1: GeoJsonPolygon
|
|
|
100
100
|
/**
|
|
101
101
|
* @description Gets the intersection between two GeoJSON polygons/multi-polygons.
|
|
102
102
|
* Returns a MultiPolygon representing the intersection, or null if there is no intersection.
|
|
103
|
-
*
|
|
104
|
-
* Delegates to `polygon-clipping`, which can **throw** `"Unable to complete output ring"`
|
|
105
|
-
* for degenerate or near-self-intersecting geometry that is still schema-valid. Callers must
|
|
106
|
-
* decide how to handle that: `null` here is reserved for a *provably empty* intersection, so
|
|
107
|
-
* a thrown failure must not be silently folded into `null` (see SAGA-743). Callers for which
|
|
108
|
-
* "no overlap" is a safe degradation (e.g. overlap grouping in `@trackunit/react-map`) should
|
|
109
|
-
* catch and treat the throw as no intersection; callers that turn `null` into "no spatial
|
|
110
|
-
* filter" (e.g. `mapUtils` viewport/area merges) must instead fall back to a conservative
|
|
111
|
-
* geometry rather than assume disjointness.
|
|
112
103
|
*/
|
|
113
104
|
export declare const getGeoJsonPolygonIntersection: (polygon1: GeoJsonPolygon | GeoJsonMultiPolygon, polygon2: GeoJsonPolygon | GeoJsonMultiPolygon) => GeoJsonMultiPolygon | GeoJsonPolygon | null;
|
|
114
105
|
/**
|
package/migrations/entry.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"entry.js","sourceRoot":"","sources":["../../../../../libs/geo-json/utils/migrations/entry.ts"],"names":[],"mappings":"","sourcesContent":["export {};\n"]}
|