@trackunit/geo-json-utils 1.11.85 → 1.11.87

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 CHANGED
@@ -225,6 +225,30 @@ const extractFirstPointCoordinate = (features) => {
225
225
  }
226
226
  return null;
227
227
  };
228
+ /**
229
+ * Extract all coordinates from a single GeoJSON geometry.
230
+ * Handles Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon,
231
+ * and GeometryCollection (recursively).
232
+ */
233
+ const extractPositionsFromGeometry = (geometry) => {
234
+ switch (geometry.type) {
235
+ case "Point":
236
+ return [geometry.coordinates];
237
+ case "MultiPoint":
238
+ case "LineString":
239
+ return [...geometry.coordinates];
240
+ case "MultiLineString":
241
+ case "Polygon":
242
+ return geometry.coordinates.flatMap(ring => ring);
243
+ case "MultiPolygon":
244
+ return geometry.coordinates.flatMap(polygon => polygon.flatMap(ring => ring));
245
+ case "GeometryCollection":
246
+ return geometry.geometries.flatMap(g => extractPositionsFromGeometry(g));
247
+ default: {
248
+ throw new Error(`${geometry} is not known`);
249
+ }
250
+ }
251
+ };
228
252
  /**
229
253
  * Wrap a GeoJSON geometry in a single-feature FeatureCollection.
230
254
  *
@@ -1057,6 +1081,7 @@ exports.coordinatesToStandardFormat = coordinatesToStandardFormat;
1057
1081
  exports.denormalizeLongitude = denormalizeLongitude;
1058
1082
  exports.extractEdges = extractEdges;
1059
1083
  exports.extractFirstPointCoordinate = extractFirstPointCoordinate;
1084
+ exports.extractPositionsFromGeometry = extractPositionsFromGeometry;
1060
1085
  exports.geoJsonBboxSchema = geoJsonBboxSchema;
1061
1086
  exports.geoJsonFeatureCollectionSchema = geoJsonFeatureCollectionSchema;
1062
1087
  exports.geoJsonFeatureSchema = geoJsonFeatureSchema;
package/index.esm.js CHANGED
@@ -223,6 +223,30 @@ const extractFirstPointCoordinate = (features) => {
223
223
  }
224
224
  return null;
225
225
  };
226
+ /**
227
+ * Extract all coordinates from a single GeoJSON geometry.
228
+ * Handles Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon,
229
+ * and GeometryCollection (recursively).
230
+ */
231
+ const extractPositionsFromGeometry = (geometry) => {
232
+ switch (geometry.type) {
233
+ case "Point":
234
+ return [geometry.coordinates];
235
+ case "MultiPoint":
236
+ case "LineString":
237
+ return [...geometry.coordinates];
238
+ case "MultiLineString":
239
+ case "Polygon":
240
+ return geometry.coordinates.flatMap(ring => ring);
241
+ case "MultiPolygon":
242
+ return geometry.coordinates.flatMap(polygon => polygon.flatMap(ring => ring));
243
+ case "GeometryCollection":
244
+ return geometry.geometries.flatMap(g => extractPositionsFromGeometry(g));
245
+ default: {
246
+ throw new Error(`${geometry} is not known`);
247
+ }
248
+ }
249
+ };
226
250
  /**
227
251
  * Wrap a GeoJSON geometry in a single-feature FeatureCollection.
228
252
  *
@@ -1047,4 +1071,4 @@ const tuGeoJsonRectangularBoxPolygonSchema = z
1047
1071
  }
1048
1072
  });
1049
1073
 
1050
- export { EARTH_RADIUS, boundingBoxCrossesMeridian, checkCrossesMeridian, computeGeometryCentroid, coordinatesToStandardFormat, denormalizeLongitude, extractEdges, extractFirstPointCoordinate, geoJsonBboxSchema, geoJsonFeatureCollectionSchema, geoJsonFeatureSchema, geoJsonGeometryCollectionSchema, geoJsonGeometrySchema, geoJsonLineStringSchema, geoJsonLinearRingSchema, geoJsonMultiLineStringSchema, geoJsonMultiPointSchema, geoJsonMultiPolygonSchema, geoJsonPointSchema, geoJsonPolygonSchema, geoJsonPosition2dSchema, geoJsonPositionSchema, getBboxFromGeoJsonPolygon, getBoundingBoxFromGeoJsonBbox, getBoundingBoxFromGeoJsonPolygon, getExtremeGeoJsonPointFromPolygon, getGeoJsonPolygonFromBoundingBox, getGeoJsonPolygonIntersection, getMinMaxLongitudes, getMultipleCoordinatesFromGeoJsonObject, getPointCoordinateFromGeoJsonObject, getPointCoordinateFromGeoJsonPoint, getPolygonFromBbox, getPolygonFromPointAndRadius, isBboxInsideFeatureCollection, isFullyContainedInGeoJsonPolygon, isGeoJsonPointInPolygon, isGeoJsonPositionInLinearRing, isPositionInsideRing, normalizeLongitudes, toFeatureCollection, toPosition2d, tuGeoJsonPointRadiusSchema, tuGeoJsonPolygonNoHolesSchema, tuGeoJsonRectangularBoxPolygonSchema };
1074
+ export { EARTH_RADIUS, boundingBoxCrossesMeridian, checkCrossesMeridian, computeGeometryCentroid, coordinatesToStandardFormat, denormalizeLongitude, extractEdges, extractFirstPointCoordinate, extractPositionsFromGeometry, geoJsonBboxSchema, geoJsonFeatureCollectionSchema, geoJsonFeatureSchema, geoJsonGeometryCollectionSchema, geoJsonGeometrySchema, geoJsonLineStringSchema, geoJsonLinearRingSchema, geoJsonMultiLineStringSchema, geoJsonMultiPointSchema, geoJsonMultiPolygonSchema, geoJsonPointSchema, geoJsonPolygonSchema, geoJsonPosition2dSchema, geoJsonPositionSchema, getBboxFromGeoJsonPolygon, getBoundingBoxFromGeoJsonBbox, getBoundingBoxFromGeoJsonPolygon, getExtremeGeoJsonPointFromPolygon, getGeoJsonPolygonFromBoundingBox, getGeoJsonPolygonIntersection, getMinMaxLongitudes, getMultipleCoordinatesFromGeoJsonObject, getPointCoordinateFromGeoJsonObject, getPointCoordinateFromGeoJsonPoint, getPolygonFromBbox, getPolygonFromPointAndRadius, isBboxInsideFeatureCollection, isFullyContainedInGeoJsonPolygon, isGeoJsonPointInPolygon, isGeoJsonPositionInLinearRing, isPositionInsideRing, normalizeLongitudes, toFeatureCollection, toPosition2d, tuGeoJsonPointRadiusSchema, tuGeoJsonPolygonNoHolesSchema, tuGeoJsonRectangularBoxPolygonSchema };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/geo-json-utils",
3
- "version": "1.11.85",
3
+ "version": "1.11.87",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -35,6 +35,12 @@ export declare const computeGeometryCentroid: (features: GeoJsonFeatureCollectio
35
35
  * Point or MultiPoint geometries. Returns null if no point geometries exist.
36
36
  */
37
37
  export declare const extractFirstPointCoordinate: (features: GeoJsonFeatureCollection) => GeoJsonPosition | null;
38
+ /**
39
+ * Extract all coordinates from a single GeoJSON geometry.
40
+ * Handles Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon,
41
+ * and GeometryCollection (recursively).
42
+ */
43
+ export declare const extractPositionsFromGeometry: (geometry: GeoJsonGeometry) => ReadonlyArray<GeoJsonPosition>;
38
44
  /**
39
45
  * Wrap a GeoJSON geometry in a single-feature FeatureCollection.
40
46
  *