Represents is a plane geometry figure that is bounded by a finite chain of straight line segments closing in a loop to form a closed chain or circuit.

Members

Array

rings

Returns a frozen Array of array of points that represent the different rings in the polygon.

Constructor

new

Polygon

([Array<Point> ringPoints])

Creates a new Polygon instance.

Examples:
new Polygon([ new Point(30, 10), new Point(40, 40), new Point(10, 20), new Point(30, 10) ]);
//polygon with a hole
new Polygon(
 [ new Point(30, 10), new Point(40, 40), new Point(10, 20), new Point(30, 10) ],
 [ new Point(25, 20), new Point(30, 30), new Point(20, 20), new Point(25, 20) ]
);
Parameters:
Name Type Description
ringPoints optional variable Array<Point>

A sequence of Array of Point items as arguments representing the rings of the polygon.

Methods

equals

(Polygon other)

Returns true if the values of the polygons are the same, otherwise it returns false.

Parameters:
Name Type Description
other Polygon
Returns:
Type Description
Boolean

Polygon.fromBuffer

(Buffer buffer)

Creates a Polygon instance from a Well-known Text (WKT) representation of a polygon.

Static
This function is static
Parameters:
Name Type Description
buffer Buffer
Returns:
Type Description
Polygon

Polygon.fromString

(String textValue)

Creates a Polygon instance from a Well-known Text (WKT) representation of a shape.

Static
This function is static
Parameters:
Name Type Description
textValue String
Returns:
Type Description
Polygon

toBuffer

()

Returns a Well-known Binary (WKB) representation of this instance.

Returns:
Type Description
Buffer

toJSON

()

Returns a JSON representation of this geo-spatial type.

toString

()

Returns Well-known text (WKT) representation of the geometry object.

Returns:
Type Description
String