The Polygon class provides some simple geometric analysis tools:

  • Haversine distance
  • Add meters to a (lat, lng)
  • Polygon self-intersection check

Hierarchy

  • Polygon

Constructors

Methods

  • Given a point (lng, lat), add (dx, dy) meters to its location. Negative values are subtracted.

    Returns

    Returns new point.

    Parameters

    • point: IPoint

      Source point.

    • dx: number

      Longitude meters to add.

    • dy: number

      Latitude meters to add.

    Returns IPoint

  • Calculates the distance between two points in meters using the Haversine formula.

    Returns

    Distance between point 1 and point 2 in meters.

    Example

    const dist = Polygon.distance({ lng: 0, lat: 0 }, { lng: 1, lat: 0 });
    

    Parameters

    • point1: IPoint

      Source point.

    • point2: IPoint

      Destination point.

    Returns number

  • Is the polygon specified by the list of points valid, i.e it does not self-intersect?

    Returns

    true if the polygon is valid (does not self-intersect), false if the polygon is invalid (has self-intersections).

    Parameters

    • points: IPoint[]

      Polygon points. Do not duplicate the last point.

    Returns boolean

  • Convert angle degrees to radians.

    Returns

    Radians

    Parameters

    • degrees: number

      Degrees value

    Returns number

Generated using TypeDoc