Helper class for the geospatial analysis. Makes use of Turf.js.

GeometryUtil

Constructors

Methods

  • Adds a buffer to a given geometry.

    If the target is of type ol.Feature it will return an ol.Feature. If the target is of type ol.geom.Geometry it will return ol.geom.Geometry.

    Parameters

    • geometryOrFeature: Geometry | Feature<Geometry>

      The geometry.

    • radius: number = 0

      The buffer to add in meters.

    • projection: ProjectionLike = 'EPSG:3857'

      The projection of the input geometry as EPSG code. Default is to EPSG:3857.

    Returns Geometry | Feature<Geometry>

    The geometry or feature with the added buffer.

  • Adds a buffer to a given geometry.

    Parameters

    • geometry: Geometry

      The geometry.

    • radius: number = 0

      The buffer to add in meters.

    • projection: ProjectionLike = 'EPSG:3857'

      The projection of the input geometry as EPSG code. Default is to EPSG:3857.

    Returns Geometry

    The geometry with the added buffer.

  • Finds the difference between two polygons by clipping the second polygon from the first.

    If both polygons are of type ol.Feature it will return an ol.Feature. Else it will return an ol.geom.Geometry.

    Parameters

    • polygon1: Polygon | Feature<Polygon>
    • polygon2: Polygon | Feature<Polygon>
    • projection: ProjectionLike = 'EPSG:3857'

      The projection of the input polygons as EPSG code. Default is to EPSG:3857.

    Returns Polygon | MultiPolygon | Feature<Polygon | MultiPolygon>

    A Feature or geometry with the area of polygon1 excluding the area of polygon2.

  • Finds the difference between two polygons by clipping the second polygon from the first.

    Parameters

    • polygon1: Polygon

      An ol.geom.Geometry

    • polygon2: Polygon

      An ol.geom.Geometry

    • projection: ProjectionLike = 'EPSG:3857'

      The projection of the input polygons as EPSG code. Default is to EPSG:3857.

    Returns Polygon | MultiPolygon

    A with the area of polygon1 excluding the area of polygon2.

  • Takes two polygons and finds their intersection.

    Parameters

    • polygon1: Polygon | MultiPolygon

      An ol.geom.Geometry

    • polygon2: Polygon | MultiPolygon

      An ol.geom.Geometry

    • projection: ProjectionLike = 'EPSG:3857'

      The projection of the input polygons as EPSG code. Default is to EPSG:3857.

    Returns undefined | Polygon | MultiPolygon

    A Geometry with the shared area of the two polygons or null if the polygons don't intersect.

  • Takes two polygons and finds their intersection.

    If both polygons are of type ol.Feature it will return an ol.Feature. Else it will return an ol.geom.Geometry.

    Parameters

    • polygon1: Polygon | Feature<Polygon | MultiPolygon>
    • polygon2: Polygon | Feature<Polygon | MultiPolygon>
    • projection: ProjectionLike = 'EPSG:3857'

      The projection of the input polygons as EPSG code. Default is to EPSG:3857.

    Returns undefined | Polygon | MultiPolygon | Feature<Polygon | MultiPolygon>

    A Feature or Geometry with the shared area of the two polygons or null if the polygons don't intersect.

  • Merges multiple geometries into one MultiGeometry.

    Type Parameters

    • Geom extends Geometry

    Parameters

    • geometries: Geom[]

      An array of ol.geom.geometries;

    Returns MultiPolygon | MultiLineString | MultiPoint

    A Multigeometry.

  • Splits an array of geometries (and multi geometries) or a single MultiGeom into an array of single geometries.

    Parameters

    • geometry: Geometry | Geometry[]

      An (array of) ol.geom.geometries;

    Returns Geometry[]

    An array of geometries.

  • Splits an OlFeature with/or ol.geom.Polygon by an OlFeature with/or ol.geom.LineString into an array of instances of OlFeature with/or ol.geom.Polygon. If the target polygon (first param) is of type ol.Feature it will return an array with ol.Feature. If the target polygon (first param) is of type ol.geom.Geometry it will return an array with ol.geom.Geometry.

    Parameters

    • polygon: Polygon | Feature<Polygon>

      The polygon geometry to split.

    • line: Feature<LineString>

      The line geometry to split the polygon geometry with.

    • projection: ProjectionLike = 'EPSG:3857'

      The EPSG code of the input features. Default is to EPSG:3857.

    Returns Polygon[] | Feature<Polygon>[]

    An array of instances of OlFeature with/or ol.geom.Polygon

  • Splits an ol.geom.Polygon by an ol.geom.LineString into an array of instances of ol.geom.Polygon.

    Parameters

    • polygon: Polygon

      The polygon geometry to split.

    • line: LineString

      The line geometry to split the polygon geometry with.

    • projection: ProjectionLike = 'EPSG:3857'

      The EPSG code of the input features. Default is to EPSG:3857.

    Returns Polygon[]

    An array of instances of ol.geom.Polygon

  • Takes two or more polygons and returns a combined (Multi-)polygon.

    Parameters

    • inputPolygonalObjects: Polygon[] | Feature<Polygon | MultiPolygon>[]

      An array of ol.Feature or ol.geom.Geometry instances of type (Multi)-Polygon.

    • projection: ProjectionLike = 'EPSG:3857'

      The projection of the input polygons as EPSG code. Default is to EPSG:3857.

    Returns Polygon | MultiPolygon | Feature<Polygon | MultiPolygon>

    A Feature or Geometry with the combined area of the (Multi-)polygons.

  • Takes two or more polygons and returns a combined (Multi-)polygon.

    Parameters

    • polygons: Polygon[] | MultiPolygon[]

      An array of ol.geom.Geometry instances of type (Multi-)polygon.

    • projection: ProjectionLike = 'EPSG:3857'

      The projection of the input polygons as EPSG code. Default is to EPSG:3857.

    Returns Polygon | MultiPolygon

    A FGeometry with the combined area of the (Multi-)polygons.