Options
All
  • Public
  • Public/Protected
  • All
Menu

Class GeometryUtils

Utilities for Geometry objects

Hierarchy

  • GeometryUtils

Index

Properties

Methods

Properties

Static DEFAULT_EPSILON

DEFAULT_EPSILON: number = 1e-15

Default epsilon for line tolerance

Methods

Static bearing

  • Get the bearing heading in degrees between two points in degrees

    since

    1.1.1

    Parameters

    Returns number

    bearing angle in degrees between 0 and 360

Static bearingLine

  • bearingLine(line: Line): number
  • Get the bearing heading in degrees between line end points in degrees

    since

    1.1.1

    Parameters

    Returns number

    bearing angle in degrees between 0 inclusively and 360 exclusively

Static bound

  • Bound all points in the geometry to be within the geometry envelope. Point x and y values are bounded by the min and max envelope values.

    To perform a geometry crop using line intersections, see {@link #crop(Geometry, GeometryEnvelope)} (requires geometry in meters).

    since

    1.1.1

    Parameters

    Returns void

Static boundWGS84

  • Bound all points in the geometry to be within WGS84 limits.

    To perform a geometry crop using line intersections, see {@link #degreesToMeters(Geometry)} and {@link #crop(Geometry, GeometryEnvelope)}.

    since

    1.1.1

    Parameters

    Returns void

Static boundWGS84Transformable

  • boundWGS84Transformable(geometry: Geometry): void
  • Bound all points in the geometry to be within WGS84 projection transformable (degrees to meters) limits.

    To perform a geometry crop using line intersections, see {@link #degreesToMeters(Geometry)} and {@link #crop(Geometry, GeometryEnvelope)}.

    since

    1.1.1

    Parameters

    Returns void

Static boundWGS84WithWebMercator

  • boundWGS84WithWebMercator(geometry: Geometry): void
  • Bound all points in the WGS84 geometry to be within degree Web Mercator limits.

    To perform a geometry crop using line intersections, see {@link #degreesToMeters(Geometry)} and {@link #cropWebMercator(Geometry)}.

    since

    2.2.0

    Parameters

    Returns void

Static boundWebMercator

  • boundWebMercator(geometry: Geometry): void
  • Bound all points in the geometry to be within Web Mercator limits.

    To perform a geometry crop using line intersections, see {@link #cropWebMercator(Geometry)}.

    since

    2.2.0

    Parameters

    Returns void

Static childHierarchy

Static childTypes

Static closedPolygon

  • closedPolygon(polygon: Polygon): boolean
  • Check if the polygon outer ring is explicitly closed, where the first and last point are the same

    Parameters

    Returns boolean

    true if the first and last points are the same

Static closedPolygonPoints

  • closedPolygonPoints(points: Array<Point>): boolean
  • Check if the polygon ring points are explicitly closed, where the first and last point are the same

    Parameters

    • points: Array<Point>

      polygon ring points

    Returns boolean

    true if the first and last points are the same

Static closedPolygonRing

  • Check if the polygon ring is explicitly closed, where the first and last point are the same

    Parameters

    Returns boolean

    true if the first and last points are the same

Static containsGeometryEnvelope

  • Determine if the first envelope contains the second within the default tolerance of {@link GeometryConstants#DEFAULT_EQUAL_EPSILON}. For exact equality, use {@link GeometryEnvelope#contains(GeometryEnvelope)}.

    since

    1.1.1

    Parameters

    Returns boolean

    true if contains

Static containsPoint

  • Determine if the envelope contains the point within the default tolerance of {@link GeometryConstants#DEFAULT_EQUAL_EPSILON}. For exact equality, use {@link GeometryEnvelope#contains(Point)}.

    since

    1.1.1

    Parameters

    Returns boolean

    true if contains

Static crop

  • Crop the geometry in meters by the envelope bounds in meters. Cropping removes points outside the envelope and creates new points on the line intersections with the envelope.

    since

    1.1.1

    Parameters

    Returns Geometry

    cropped geometry in meters or null

Static cropCircularString

  • Crop the circular string in meters by the envelope bounds in meters. Cropping removes points outside the envelope and creates new points on the line intersections with the envelope.

    since

    1.1.1

    Parameters

    Returns CircularString

    cropped circular string in meters or null

Static cropCompoundCurve

  • Crop the compound curve in meters by the envelope bounds in meters. Cropping removes points outside the envelope and creates new points on the line intersections with the envelope.

    since

    1.1.1

    Parameters

    Returns CompoundCurve

    cropped compound curve in meters or null

Static cropCurvePolygon

  • Crop the curve polygon in meters by the envelope bounds in meters. Cropping removes points outside the envelope and creates new points on the line intersections with the envelope.

    since

    1.1.1

    Parameters

    Returns CurvePolygon<Curve>

    cropped curve polygon in meters or null

Static cropLine

  • Crop the line in meters by the envelope bounds in meters. Cropping removes points outside the envelope and creates new points on the line intersections with the envelope.

    since

    1.1.1

    Parameters

    Returns Line

    cropped line in meters or null

Static cropLineString

  • Crop the line string in meters by the envelope bounds in meters. Cropping removes points outside the envelope and creates new points on the line intersections with the envelope.

    since

    1.1.1

    Parameters

    Returns LineString

    cropped line string in meters or null

Static cropMultiLineString

  • Crop the multi line string in meters by the envelope bounds in meters. Cropping removes points outside the envelope and creates new points on the line intersections with the envelope.

    since

    1.1.1

    Parameters

    Returns MultiLineString

    cropped multi line string in meters or null

Static cropMultiPoint

Static cropMultiPolygon

  • Crop the multi polygon in meters by the envelope bounds in meters. Cropping removes points outside the envelope and creates new points on the line intersections with the envelope.

    since

    1.1.1

    Parameters

    Returns MultiPolygon

    cropped multi polygon in meters or null

Static cropPoint

Static cropPoints

  • Crop the list of consecutive points in meters by the envelope bounds in meters. Cropping removes points outside the envelope and creates new points on the line intersections with the envelope.

    since

    1.1.1

    Parameters

    Returns Point[]

    cropped points in meters or null

Static cropPolygon

  • Crop the polygon in meters by the envelope bounds in meters. Cropping removes points outside the envelope and creates new points on the line intersections with the envelope.

    since

    1.1.1

    Parameters

    Returns Polygon

    cropped polygon in meters or null

Static cropPolyhedralSurface

  • Crop the polyhedral surface in meters by the envelope bounds in meters. Cropping removes points outside the envelope and creates new points on the line intersections with the envelope.

    since

    1.1.1

    Parameters

    Returns PolyhedralSurface

    cropped polyhedral surface in meters or null

Static cropWebMercator

  • Crop the geometry in meters by web mercator world bounds. Cropping removes points outside the envelope and creates new points on the line intersections with the envelope.

    since

    1.1.1

    Parameters

    Returns Geometry

    cropped geometry in meters or null

Static degreesToMeters

Static degreesToMetersCircularString

Static degreesToMetersCompundCurve

Static degreesToMetersCoord

  • degreesToMetersCoord(x: number, y: number): Point
  • Convert a coordinate in degrees to a point in meters

    since

    1.1.1

    Parameters

    • x: number
             x value in degrees
    • y: number
             y value in degrees

    Returns Point

    point in meters

Static degreesToMetersCurvePolygon

Static degreesToMetersLine

Static degreesToMetersLineString

Static degreesToMetersMultiLineString

Static degreesToMetersMultiPoint

Static degreesToMetersMultiPolygon

Static degreesToMetersPoint

Static degreesToMetersPolygon

Static degreesToMetersPolyhedralSurface

Static degreesToRadians

  • degreesToRadians(degrees: number): number

Static distance

Static distanceFromLine

  • distanceFromLine(line: Line): number
  • Get the Pythagorean theorem distance between the line end points

    since

    1.1.1

    Parameters

    Returns number

    distance

Static getCentroid

  • Get the centroid point of a 2 dimensional representation of the Geometry (balancing point of a 2d cutout of the geometry). Only the x and y coordinate of the resulting point are calculated and populated. The resulting {@link Point#getZ()} and {@link Point#getM()} methods will always return null.

    Parameters

    Returns Point

    centroid point

Static getDegreesCentroid

  • Get the geographic centroid point of a 2 dimensional representation of the degree unit Geometry. Only the x and y coordinate of the resulting point are calculated and populated. The resulting {@link Point#getZ()} and {@link Point#getM()} methods will always return null.

    Parameters

    Returns Point

    centroid point

Static getDimension

  • getDimension(geometry: Geometry): number
  • Get the dimension of the Geometry, 0 for points, 1 for curves, 2 for surfaces. If a collection, the largest dimension is returned.

    Parameters

    Returns number

    dimension (0, 1, or 2)

Static intersection

  • Get the point intersection between end points of two lines

    since

    2.1.0

    Parameters

    • line1Point1: Point
             first point of the first line
    • line1Point2: Point
             second point of the first line
    • line2Point1: Point
             first point of the second line
    • line2Point2: Point
             second point of the second line

    Returns Point

    intersection point or null if no intersection

Static intersectionLine

  • Get the point intersection between two lines

    since

    1.1.1

    Parameters

    • line1: Line
             first line
    • line2: Line
             second line

    Returns Point

    intersection point or null if no intersection

Static isEastBearing

  • isEastBearing(bearing: number): boolean
  • Determine if the bearing is in any east direction

    since

    1.1.1

    Parameters

    • bearing: number
             bearing angle in degrees

    Returns boolean

    true if east bearing

Static isEqual

  • Determine if the points are equal within the default tolerance of {@link GeometryConstants#DEFAULT_EQUAL_EPSILON}. For exact equality, use {@link Point#equals(Object)}.

    since

    1.1.1

    Parameters

    Returns boolean

    true if equal

Static isEqualWithEpsilon

  • isEqualWithEpsilon(point1: Point, point2: Point, epsilon: number): boolean
  • Determine if the points are equal within the tolerance. For exact equality, use {@link Point#equals(Object)}.

    since

    1.1.1

    Parameters

    • point1: Point
             point 1
    • point2: Point
             point 2
    • epsilon: number
             epsilon equality tolerance

    Returns boolean

    true if equal

Static isNorthBearing

  • isNorthBearing(bearing: number): boolean
  • Determine if the bearing is in any north direction

    since

    1.1.1

    Parameters

    • bearing: number
             bearing angle in degrees

    Returns boolean

    true if north bearing

Static isSouthBearing

  • isSouthBearing(bearing: number): boolean
  • Determine if the bearing is in any south direction

    since

    1.1.1

    Parameters

    • bearing: number
             bearing angle in degrees

    Returns boolean

    true if south bearing

Static isWestBearing

  • isWestBearing(bearing: number): boolean
  • Determine if the bearing is in any west direction

    since

    1.1.1

    Parameters

    • bearing: number
             bearing angle in degrees

    Returns boolean

    true if west bearing

Static metersToDegrees

Static metersToDegreesCircularString

Static metersToDegreesCompoundCurve

Static metersToDegreesCoord

  • metersToDegreesCoord(x: number, y: number): Point
  • Convert a coordinate in meters to a point in degrees

    since

    1.1.1

    Parameters

    • x: number
             x value in meters
    • y: number
             y value in meters

    Returns Point

    point in degrees

Static metersToDegreesCurvePolygon

Static metersToDegreesLine

Static metersToDegreesLineString

Static metersToDegreesMultiLineString

Static metersToDegreesMultiPoint

Static metersToDegreesMultiPolygon

Static metersToDegreesPoint

Static metersToDegreesPolygon

Static metersToDegreesPolyhedralSurface

Static minimize

  • minimize(geometry: Geometry, maxX: number): void
  • Minimize the geometry using the shortest x distance between each connected set of points. The resulting geometry point x values will be in the range: (3 * min value <= x <= 3 * max value

    Example: For WGS84 provide a max x of {@link GeometryConstants#WGS84_HALF_WORLD_LON_WIDTH}. Resulting x values will be in the range: -540.0 <= x <= 540.0

    Example: For web mercator provide a world width of {@link GeometryConstants#WEB_MERCATOR_HALF_WORLD_WIDTH}. Resulting x values will be in the range: -60112525.028367732 <= x <= 60112525.028367732

    since

    1.1.1

    Parameters

    • geometry: Geometry
             geometry
    • maxX: number
             max positive x value in the geometry projection

    Returns void

Static minimizeGeometry

  • minimizeGeometry(geometry: Geometry, maxX: number): void
  • Minimize the geometry using the shortest x distance between each connected set of points. The resulting geometry point x values will be in the range: (3 * min value <= x <= 3 * max value

    Example: For WGS84 provide a max x of 180.0. Resulting x values will be in the range: -540.0 <= x <= 540.0

    Example: For web mercator provide a world width of 20037508.342789244. Resulting x values will be in the range: -60112525.028367732 <= x <= 60112525.028367732

    Parameters

    • geometry: Geometry

      geometry

    • maxX: number

      max positive x value in the geometry projection

    Returns void

Static minimizeWGS84

  • minimizeWGS84(geometry: Geometry): void
  • Minimize the WGS84 geometry using the shortest x distance between each connected set of points. Resulting x values will be in the range: -540.0 <= x <= 540.0

    since

    1.1.1

    Parameters

    Returns void

Static minimizeWebMercator

  • minimizeWebMercator(geometry: Geometry): void
  • Minimize the Web Mercator geometry using the shortest x distance between each connected set of points. Resulting x values will be in the range: -60112525.028367732 <= x <= 60112525.028367732

    since

    1.1.1

    Parameters

    Returns void

Static normalize

  • normalize(geometry: Geometry, maxX: number): void
  • Normalize the geometry so all points outside of the min and max value range are adjusted to fall within the range.

    Example: For WGS84 provide a max x of {@link GeometryConstants#WGS84_HALF_WORLD_LON_WIDTH}. Resulting x values will be in the range: -180.0 <= x <= 180.0

    Example: For web mercator provide a world width of {@link GeometryConstants#WEB_MERCATOR_HALF_WORLD_WIDTH}. Resulting x values will be in the range: -20037508.342789244 <= x <= 20037508.342789244

    since

    1.1.1

    Parameters

    • geometry: Geometry
             geometry
    • maxX: number
             max positive x value in the geometry projection

    Returns void

Static normalizeGeometry

  • normalizeGeometry(geometry: Geometry, maxX: number): void
  • Normalize the geometry so all points outside of the min and max value range are adjusted to fall within the range.

    Example: For WGS84 provide a max x of 180.0. Resulting x values will be in the range: -180.0 <= x <= 180.0.

    Example: For web mercator provide a world width of 20037508.342789244. Resulting x values will be in the range: -20037508.342789244 <= x <= 20037508.342789244.

    Parameters

    • geometry: Geometry

      geometry

    • maxX: number

      max positive x value in the geometry projection

    Returns void

Static normalizeWGS84

  • normalizeWGS84(geometry: Geometry): void
  • Normalize the WGS84 geometry using the shortest x distance between each connected set of points. Resulting x values will be in the range: -180.0 <= x <= 180.0

    since

    1.1.1

    Parameters

    Returns void

Static normalizeWebMercator

  • normalizeWebMercator(geometry: Geometry): void
  • Normalize the Web Mercator geometry using the shortest x distance between each connected set of points. Resulting x values will be in the range: -20037508.342789244 <= x <= 20037508.342789244

    since

    1.1.1

    Parameters

    Returns void

Static parentHierarchy

  • Get the parent type hierarchy of the provided geometry type starting with the immediate parent. If the argument is GEOMETRY, an empty list is returned, else the final type in the list will be GEOMETRY.

    Parameters

    Returns Array<GeometryType>

    list of increasing parent types

Static parentType

Static perpendicularDistance

  • perpendicularDistance(point: Point, lineStart: Point, lineEnd: Point): number
  • Calculate the perpendicular distance between the point and the line represented by the start and end points. Points should be in a meters unit type projection.

    Parameters

    • point: Point

      point

    • lineStart: Point

      point representing the line start

    • lineEnd: Point

      point representing the line end

    Returns number

    distance in meters

Static pointInPolygon

Static pointInPolygonRing

Static pointInPolygonRingPoints

  • pointInPolygonRingPoints(point: Point, points: Array<Point>): boolean

Static pointInPolygonRingPointsWithEpsilon

  • pointInPolygonRingPointsWithEpsilon(point: Point, points: Array<Point>, epsilon: number): boolean
  • Check if the point is in the polygon points

    Parameters

    • point: Point

      point

    • points: Array<Point>

      polygon points

    • epsilon: number

      epsilon line tolerance

    Returns boolean

    true if in the polygon

Static pointInPolygonRingWithEpsilon

  • pointInPolygonRingWithEpsilon(point: Point, ring: LineString, epsilon: number): boolean
  • Check if the point is in the polygon ring

    Parameters

    • point: Point

      point

    • ring: LineString

      polygon ring

    • epsilon: number

      epsilon line tolerance

    Returns boolean

    true if in the polygon

Static pointInPolygonWithEpsilon

  • pointInPolygonWithEpsilon(point: Point, polygon: Polygon, epsilon: number): boolean
  • Check if the point is in the polygon

    Parameters

    • point: Point

      point

    • polygon: Polygon

      polygon

    • epsilon: number

      epsilon line tolerance

    Returns boolean

    true if in the polygon

Static pointOnLine

Static pointOnLinePoints

  • pointOnLinePoints(point: Point, points: Array<Point>): boolean
  • Check if the point is on the line represented by the points

    Parameters

    • point: Point

      point

    • points: Array<Point>

      line points

    Returns boolean

    true if on the line

Static pointOnLinePointsWithEpsilon

  • pointOnLinePointsWithEpsilon(point: Point, points: Array<Point>, epsilon: number): boolean
  • Check if the point is on the line represented by the points

    Parameters

    • point: Point

      point

    • points: Array<Point>

      line points

    • epsilon: number

      epsilon line tolerance

    Returns boolean

    true if on the line

Static pointOnLineWithEpsilon

  • pointOnLineWithEpsilon(point: Point, line: LineString, epsilon: number): boolean

Static pointOnPath

  • Check if the point is on the path between point 1 and point 2

    Parameters

    Returns boolean

    true if on the path

Static pointOnPathWithEpsilon

  • pointOnPathWithEpsilon(point: Point, point1: Point, point2: Point, epsilon: number): boolean
  • Check if the point is on the path between point 1 and point 2

    Parameters

    • point: Point

      point

    • point1: Point

      path point 1

    • point2: Point

      path point 2

    • epsilon: number

      epsilon line tolerance

    Returns boolean

    true if on the path

Static pointOnPolygonEdge

  • pointOnPolygonEdge(point: Point, polygon: Polygon): boolean

Static pointOnPolygonEdgePoints

  • pointOnPolygonEdgePoints(point: Point, points: Array<Point>): boolean
  • Check if the point is on the polygon ring edge points

    Parameters

    • point: Point

      point

    • points: Array<Point>

      polygon points

    Returns boolean

    true if on the polygon edge

Static pointOnPolygonEdgePointsWithEpsilon

  • pointOnPolygonEdgePointsWithEpsilon(point: Point, points: Array<Point>, epsilon: number): boolean
  • Check if the point is on the polygon ring edge points

    Parameters

    • point: Point

      point

    • points: Array<Point>

      polygon points

    • epsilon: number

      epsilon line tolerance

    Returns boolean

    true if on the polygon edge

Static pointOnPolygonEdgeRing

Static pointOnPolygonEdgeRingWithEpsilon

  • pointOnPolygonEdgeRingWithEpsilon(point: Point, ring: LineString, epsilon: number): boolean
  • Check if the point is on the polygon ring edge

    Parameters

    • point: Point

      point

    • ring: LineString

      polygon ring

    • epsilon: number

      epsilon line tolerance

    Returns boolean

    true if on the polygon edge

Static pointOnPolygonEdgeWithEpsilon

  • pointOnPolygonEdgeWithEpsilon(point: Point, polygon: Polygon, epsilon: number): boolean
  • Check if the point is on the polygon edge

    Parameters

    • point: Point

      point

    • polygon: Polygon

      polygon

    • epsilon: number

      epsilon line tolerance

    Returns boolean

    true if on the polygon edge

Static radiansToDegrees

  • radiansToDegrees(radians: number): number

Static simplifyPoints

  • simplifyPoints(points: Array<Point>, tolerance: number): Array<Point>
  • Simplify the ordered points (representing a line, polygon, etc) using the Douglas Peucker algorithm to create a similar curve with fewer points. Points should be in a meters unit type projection. The tolerance is the minimum tolerated distance between consecutive points.

    since

    1.0.4

    Parameters

    • points: Array<Point>

      geometry points

    • tolerance: number

      minimum tolerance in meters for consecutive points

    Returns Array<Point>

    simplified points

Static webMercatorEnvelope

Static wgs84Envelope

Static wgs84EnvelopeWithWebMercator

Static wgs84TransformableEnvelope

Generated using TypeDoc