Class: Polygon

geometry~ Polygon

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.

Constructor

new Polygon(…ringPointsopt)

Creates a new Polygon instance.
Parameters:
Name Type Attributes Description
ringPoints Array.<Point> <optional>
<repeatable>
A sequence of Array of Point items as arguments representing the rings of the polygon.
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) ]
);

Members

rings :Array.<Array.<Point>>

Returns a frozen Array of array of points that represent the different rings in the polygon.
Type:
  • Array.<Array.<Point>>

Methods

(static) fromBuffer(buffer) → {Polygon}

Creates a LineString instance from a Well-known Text (WKT) representation of a polygon.
Parameters:
Name Type Description
buffer Buffer
Returns:
Type
Polygon

equals(other) → {Boolean}

Returns true if the values of the polygons are the same, otherwise it returns false.
Parameters:
Name Type Description
other Polygon
Returns:
Type
Boolean

toBuffer() → {Buffer}

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

toJSON()

Returns a JSON representation of this geo-spatial type.

toString() → {String}

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