geometryFilter

Namespace

geometryFilter

Description:
  • Utility functions for filtering geometry coordinates based on bounding boxes.

Source:

Methods

(static) filterCoordinates(coordinates, bbox) → {Array}

Description:
  • Filters coordinates within the specified bounding box.

    Recursively filters coordinates for different GeoJSON geometries including Point, LineString, Polygon, MultiLineString, and MultiPolygon.

Source:
Example
const coordinates = [
  [[-80, 34], [-79.5, 34.5], [-79, 35]],
  [[-81, 33], [-80, 34], [-79.5, 34.5]]
];
const bbox = [-80, 34, -79, 35];
const filtered = filterCoordinates(coordinates, bbox);
console.log(filtered);
// Output: [
//   [[-80, 34], [-79.5, 34.5]],
//   []
// ]
Parameters:
Name Type Description
coordinates Array

The GeoJSON coordinates to filter. Can be a nested array representing different geometry types.

bbox Array.<number>

The bounding box, represented as [xmin, ymin, xmax, ymax].

Returns:

The filtered coordinates within the bounding box. The structure matches the input geometry type.

Type
Array