Options
All
  • Public
  • Public/Protected
  • All
Menu

A polygon is a shape that represents a closed polygon without holes. A polygon always is defined in a particular geographical reference (Geodetic reference or Grid Reference). A Polygon cannot be instantiated directly. It must be instantiated using createPolygon.

Hierarchy

Implements

Overview

Accessors

bounds

coordinateType

  • The coordinate type this shape. This property is read only. An Error will be thrown when trying to assign to this property.

    Returns CoordinateType

focusPoint

  • get focusPoint(): Point

pointCount

  • get pointCount(): number
  • The number of points in the polygon

    Returns number

reference

  • The spatial reference of this shape. This property is read only. An Error will be thrown when trying to assign to this property.

    Returns CoordinateReference | null

type

Methods

contains2D

  • Determines whether a given point is inside this shape. This method checks containment only in two dimensions: on the (x,y)-axis or the (lon,lat)-axis (depending on the spatial reference of the shape).

    throws

    InvalidReferenceError when passing a Point with another spatial reference

    deprecated

    Please use contains2DPoint instead.

    Parameters

    • x: Point | number | Bounds

      The point for which containment must be checked. If a 3D point is passed to this function, it will be treated as a 2D point: the z coordinate (height) will be ignored. The reference of this point must be the same reference as this Shape

    • Optional y: number

    Returns boolean

    true when the given point is contained in this shape

Abstract contains2DCoordinates

  • (x: number, y: number): boolean
  • Determines whether the given point is inside this shape. This method checks containment only in two dimensions: on the (x,y)-axis or the (lon,lat)-axis (depending on the spatial reference of the shape).

    throws

    InvalidReferenceError when passing a Point with another spatial reference

    Parameters

    • x: number

      The x coordinate of the point for which containment must be checked

    • y: number

      The y coordinate of the point for which containment must be checked

    Returns boolean

    true when the given point is contained in this shape

contains2DPoint

  • (point: Point): boolean
  • Determines whether the given point is inside this shape. This method checks containment only in two dimensions: on the (x,y)-axis or the (lon,lat)-axis (depending on the spatial reference of the shape).

    throws

    InvalidReferenceError when passing a Point with another spatial reference

    Parameters

    • point: Point

      The point for which containment must be checked.

    Returns boolean

    true when the given point is contained in this shape

Abstract copy

equals

  • (otherPolygon: Shape): boolean

getPoint

  • Returns the point of the polygon at the given index. Any subsequent mutation on the point affects the polygon shape. Note: A new Point is returned on each function invocation that shares the same point representation of the polygon.

    const pA = polygon.getPoint(0)
    const pB = polygon.getPoint(0)
    console.log(pA === pB) // false
    pA.x = 100;
    console.log(pA.x, pB.x, polygon.getPoint(0).x) // 100, 100, 100

    Parameters

    • index: number

      The index of the point to be returned.

    Returns Point

    the point at the given index

insertPoint

  • (index: number, point: Point): void
  • Inserts a Point at a given position in this Polygon. The point must be defined in the same spatial reference as the polygon, otherwise an exception will be thrown.

    throws

    InvalidReferenceError When the point's spatial reference does not correspond with the polygon's spatial reference.

    throws

    ProgrammingError When the index is invalid (i.e. smaller than zero or larger than the amount of points in the polygon.

    Parameters

    • index: number

      The index at which the point must be inserted

    • point: Point

      The point to be inserted

    Returns void

isValid

  • (): boolean
  • Verifies whether the polygon is valid. A valid polygon:

    • consists of at least 3 points

    Returns boolean

    true if the polygon is valid, false otherwise

move2DPoint

  • (index: number, x: number, y: number): void
  • Moves the x and y coordinates of the point at the given index to the given coordinates. The z value remains unchanged.

    throws

    ProgrammingError When the index is invalid (i.e. smaller than zero or larger than the index of the last point in the polygon

    Parameters

    • index: number

      The index of the point that must be removed.

    • x: number

      x coordinate value

    • y: number

      y coordinate value

    Returns void

move3DPoint

  • (index: number, x: number, y: number, z: number): void
  • Moves the point at the given index to the given coordinates.

    throws

    ProgrammingError When the index is invalid (i.e. smaller than zero or larger than the index of the last point in the polygon

    Parameters

    • index: number

      The index of the point that must be removed.

    • x: number

      x coordinate value

    • y: number

      y coordinate value

    • z: number

      z coordinate value

    Returns void

removePoint

  • (index: number): void
  • Removes a point at a given position in this Polygon. This method does not guarantee that the polygon remains valid, i.e. the polygon must at least have 3 points. Validity of the polygon can be checked with Polygon.isValid.

    throws

    ProgrammingError When the index is invalid (i.e. smaller than zero or larger than the index of the last point in the polygon

    Parameters

    • index: number

      The index of the point that must be removed.

    Returns void

toString

  • (): string

translate

  • (x: number, y: number, z?: number): void
  • Translates all the points of this Polygon over the given vector in 2D or 3D space. A point is only translated in 3D space if the z parameter is specified.

    Parameters

    • x: number

      x coordinate value

    • y: number

      y coordinate value

    • Optional z: number

      z coordinate value

    Returns void

translate2D

  • (x: number, y: number): void

translate3D

  • (x: number, y: number, z: number): void
  • Translates all the points of this Polygon over the given vector in 3D space.

    Parameters

    • x: number

      x coordinate value

    • y: number

      y coordinate value

    • z: number

      z coordinate value

    Returns void

translatePoint

  • (index: number, x: number, y: number, z?: number): void
  • Translates the point at the given index over the given vector in 2D or 3D space. A point is only translated in 3D space the z parameter is specified.

    throws

    ProgrammingError When the index is invalid (i.e. smaller than zero or larger than the index of the last point in the polygon

    Parameters

    • index: number

      The index of the point that must be removed.

    • x: number

      x coordinate value

    • y: number

      y coordinate value

    • Optional z: number

      z coordinate value

    Returns void

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method