Class: Polygon

H.geo.Polygon

new H.geo.Polygon (exterior, opt_interiors)

A polygon represents a plane figure that is defined by an exterior ring (finite chain of straight line segments) and zero or more interior rings which are rendered by using the Even–odd rule. In a simple case each interior ring represents a hole within the polygon.

Interior rings that intersects the exterior ring or that are outside the exterior ring are not supported.

Name Type Description
exterior H.geo.LineString

The exterior ring of the polygon.

opt_interiors Array.<!H.geo.LineString> optional

The interior rings of the polygon.

Throws:

if the exterior or interiors argument is invalid.

Type
H.lang.InvalidArgumentError

Extends

Members

H.geo.Polygon.Direction static

See H.geo.Polygon#setPoleCovering for more details.

Properties:
Name Description
NORTH
SOUTH

Methods

equals (other)boolean inherited overrides

Checks whether the geometry is equal to the geometry supplied by the caller. Two geometries are considered as equal if they represent the same geometry type and have equal coordinate values.

Name Type Description
other *

The geometry to check against

Returns:
Type Description
boolean true if the two geometries are equal, otherwise false

getBoundingBox ()H.geo.Rect inherited overrides

Returns the bounding rectangle of the geometry.

Returns:
Type Description
H.geo.Rect the bounding rectangle of the geometry or null if the bounding rectangle can't be computed (e.g. for a geometry without coordinates)

getExterior ()H.geo.LineString

To obtain the exterior ring of the polygon.

Returns:
Type Description
H.geo.LineString

getInteriors ()Array.<!H.geo.LineString>

To obtain a reference to the list of interior rings of the polygon.

Returns:
Type Description
Array.<!H.geo.LineString>

getPoleCovering ()H.geo.Polygon.Direction

To obtain whether this polygon covers the North or the South Pole. See H.geo.Polygon#setPoleCovering for more details.

Returns:
Type Description
H.geo.Polygon.Direction

pushInterior (interior)

To add an interior ring.

Name Type Description
interior H.geo.LineString

The interior ring to add.

Throws:

if the interior argument is invalid.

Type
H.lang.InvalidArgumentError

removeInterior (interior)H.geo.LineString | undefined

To remove the specified interior ring.

Name Type Description
interior H.geo.LineString

The interior ring to remove.

Returns:
Type Description
H.geo.LineString | undefined the removed interior ring or undefined if the interior ring was not found.

removeInteriorAt (opt_index)H.geo.LineString | undefined

To remove an interior ring at the given index.

Name Type Description
opt_index number optional

The index of the interior ring to remove, defaults to 0.

Returns:
Type Description
H.geo.LineString | undefined the removed interior ring or undefined if no interior ring exists at the given index.

setExterior (exterior)

To set the exterior ring of the polygon.

Name Type Description
exterior H.geo.LineString

The exterior ring to set

setPoleCovering (direction)H.geo.Polygon

To specify whether this polygon covers the North or the South Pole. This information is only needed for very special polygons that are defined as a line string around the world on longitude axis (for example along the coast of the Antarctic). In such cases, an additional information is needed to know if the southern part of the Earth (Antarctic) or the northern part (anything except Antarctic) should be covered.

Name Type Description
direction H.geo.Polygon.Direction

The direction to set.

Returns:
Type Description
H.geo.Polygon the Polygon instance itself.

spliceInteriors (opt_index, opt_deleteCount, var_args)Array.<!H.geo.LineString>

Applies a splice-operation on the list of interior rings of the polygon.

Name Type Description
opt_index number optional

The index at which to start changing the list, defaults to 0.

opt_deleteCount number optional

The number of interior rings to remove, defaults to Infinity.

var_args H.geo.LineString repeatable

The interior rings to insert.

See:
Returns:
Type Description
Array.<!H.geo.LineString> An array containing the removed interior rings.

toGeoJSON ()Object inherited

To obtain a GeoJSON representation of the given geometry.

Returns:
Type Description
Object A GeoJSON Geometry object representing the given geometry.

toString () inherited

To obtain a Well-Known-Text (WKT) representation of the geometry.