@trackunit/geo-json-utils 1.15.18-alpha-fa073b98d1d.0 → 1.15.18
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 +9 -1
- package/index.esm.js +9 -1
- package/package.json +1 -1
package/index.cjs.js
CHANGED
|
@@ -900,12 +900,20 @@ 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]);
|
|
909
917
|
const rawLngs = coordinates.map(c => c[0]);
|
|
910
918
|
const minRawLon = Math.min(...rawLngs);
|
|
911
919
|
const maxRawLon = Math.max(...rawLngs);
|
package/index.esm.js
CHANGED
|
@@ -898,12 +898,20 @@ 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]);
|
|
907
915
|
const rawLngs = coordinates.map(c => c[0]);
|
|
908
916
|
const minRawLon = Math.min(...rawLngs);
|
|
909
917
|
const maxRawLon = Math.max(...rawLngs);
|