Skip to content

API / geotoolkit / util / Polygon / Polygon

Class: Polygon

util.Polygon.Polygon

Represents a polygon with methods that allow the geometry of the polygon to be queried and modified.

Hierarchy

Table of contents

Constructors
  • [new Polygon(x, y, evenOddMode)](/solutions/geotoolkit/GeoToolkit_JS/apis/classes/geotoolkit.util.polygon.polygon.md#new polygon(x, y, evenoddmode))
Methods

Contents

Constructors

new Polygon(x, y, evenOddMode)

• new Polygon(x?, y?, evenOddMode?)

Parameters

Name Type Description
Optional xnumber[]x coordinates
Optional ynumber[]y coordinates
Optional evenOddModebooleaneven odd mode

Overrides

Area.constructor

Methods

clone

▸ clone(): Polygon

Clone polygon

Returns

Polygon

polygon


contains

▸ contains(x, y): boolean

Check if polygon contains point

Throws

if illegal argument count

Parameters

Name Type Description
xnumberx position of the point
ynumbery position of the point

Returns

boolean

Overrides

Area.contains

▸ contains(point): boolean

Check if polygon contains point

Throws

if illegal argument count

Parameters

Name Type Description
pointPointpoint

Returns

boolean

Overrides

Area.contains


containsPolygon

▸ containsPolygon(polygon): boolean

Check if polygon contains polygon

Parameters

Name Type Description
polygonPolygonpolygon

Returns

boolean

true if contains, else false


containsRectangle

▸ containsRectangle(rectangle): boolean

Check if polygon contains rectangle

Parameters

Name Type Description
rectangleRectrectangle

Returns

boolean

true if contains, else false


getBounds

▸ getBounds(): Rect

Return bounds and locks the bounds rect from further editing.

Returns

Rect

bounds

Overrides

Area.getBounds


getClassName

▸ getClassName(): string

Returns

string

Inherited from

Area.getClassName


getEvenOddMode

▸ getEvenOddMode(): boolean

Get even odd mode

Returns

boolean

will this use even odd mode or not


getPointsX

▸ getPointsX(): number[]

Gets x-coords of points

Returns

number[]

array of x-coordinates


getPointsY

▸ getPointsY(): number[]

Gets y-coords of points

Returns

number[]

array of y-coordinates


getProperties

▸ getProperties(): Record<string, any&gt;

Gets all the properties pertaining to this object

Returns

Record<string, any&gt;

Inherited from

Area.getProperties


getSize

▸ getSize(): number

Gets number of points

Returns

number

points the number of points in this polygon


intersectRectangle

▸ intersectRectangle(rectangle): Polygon

Intersects polygon with the rectangle and leaves only the inner part of polygon WARNING! The result might have self-intersections in some cases

Parameters

Name Type Description
rectangleRectrectangle

Returns

Polygon

this


intersectsPolygon

▸ intersectsPolygon(polygon): boolean

Check if polygon intersects polygon

Parameters

Name Type Description
polygonPolygonpolygon

Returns

boolean

true if intersects, else false


intersectsRectangle

▸ intersectsRectangle(rectangle): boolean

Check if polygon intersects rectangle

Parameters

Name Type Description
rectangleRectrectangle

Returns

boolean

true if intersects, else false


push

▸ push(x, y): void

Add point to array of points.

Parameters

Name Type Description
xnumberx coordinate
ynumbery coordinate

Returns

void


setCoordinates

▸ setCoordinates(x, y): Polygon

Sets arrays of points. Will overwrite any existing points in this polygon.

Parameters

Name Type Description
xnumber[]array of x coordinates
ynumber[]array of y coordinates

Returns

Polygon


setEvenOddMode

▸ setEvenOddMode(mode): Polygon

Set even odd mode

Parameters

Name Type Description
modebooleaneven odd mode

Returns

Polygon


setProperties

▸ setProperties(properties?): Polygon

Sets all the properties pertaining to this object

Parameters

Name Type Description
Optional propertiesRecord<string, any&gt;object containing the properties to set

Returns

Polygon

this

Inherited from

Area.setProperties


fromRect

▸ Static fromRect(rect): Polygon

Create polygon from rect

Parameters

Name Type Description
rectRectrectangle

Returns

Polygon

instance


getClassName

▸ Static getClassName(): string

Returns

string

Inherited from

Area.getClassName