API Documentation | All Packages | All Classes | Index | Frames No Frames |
Class Polygon

Package | org.openscales.core.geometry
Class | public class Polygon
Inheritance | Polygon Collection Geometry

A Polygon is a collection of Geometry LinearRings defining a Mathematical Polygon (the first LinearRing) with holes (the potential others LinearRings).

Public Properties
Hide Inherited Public Properties
Show Inherited Public Properties

| Property | Defined by
--- | --- | ---
|  | area : Number [read-only] Calculate the approximate area of this geometry (the projection and the geodesic are not managed). | Polygon
|  | bounds : Bounds | Geometry
|  | components : Array Setter of the components (children) of this collection. | Collection
|  | componentsLength : int Number of components in the collection | Collection
|  | componentsString : String Get a string representing the components for this collection | Collection
|  | componentTypes : Array Getter and setter of the authorized types for the components (children) of this collection | Collection
|  | id : String | Geometry
|  | length : Number Returns the geometry's length. | Geometry
|  | parent : Geometry | Geometry

Protected Properties
Hide Inherited Protected Properties
Show Inherited Protected Properties

| Property | Defined by
--- | --- | ---
|  | _bounds : Bounds = null The bounds of this geometry | Geometry

Public Methods
Hide Inherited Public Methods
Show Inherited Public Methods

| Method | Defined by
--- | --- | ---
|  | Polygon(rings:Array) Constructor for a Polygon geometry. | Polygon
|  | addComponent(component:Geometry, index:Number):Boolean Add a new component (geometry) to the collection. | Collection
|  | addComponents(components:Array):void Add components to this geometry. | Collection
|  | atPoint(lonlat:LonLat, toleranceLon:Number, toleranceLat:Number):Boolean Determines if the feature is placed at the given point with a certain tolerance (or not). | Geometry
|  | calculateBounds():void Recalculate the bounds by iterating through the components and calling extendBounds() on each item. | Collection
|  | clearBounds():void Clear the geometry's bounds | Geometry
|  | clone():Geometry To get this geometry clone | Polygon
|  | componentByIndex(i:int):Geometry Component of the specified index, casted to the Geometry type | Collection
|  | contains(geom:Geometry, assertIntersection:Boolean = false):Boolean Determine if the input geometry is fully contained in this one. | Geometry
|  | containsPoint(p:Point):Boolean Test if a point is inside this geometry. | Polygon
|  | createRegularPolygon(origin:Point, radius:Number, sides:Number, rotation:Number):Polygon Create a regular polygon around a radius. | Polygon
|  | destroy():void Destroy the collection. | Collection
|  | distanceTo(geom:Geometry):Number Calculate the closest distance between two geometries (on the x-y plane). | Geometry
|  | extendBounds(newBounds:Bounds):void Extends geometry's bounds If bounds are not defined yet, it initializes the bounds. | Geometry
|  | getcomponentsClone():Array TO get component clone | Collection
|  | intersects(geom:Geometry):Boolean Determine if the input geometry intersects this one. | Polygon
|  | isLeftOrRight(p:Point, p0:Point, p1:Point):Number [static] Test if a point is at the left, at the right or on an infinite line. | Geometry
|  | isPointInPolygon(point:Point, manageHoles:Boolean = true):Boolean Test if a point is inside a polygon. | Polygon
|  | removeComponent(component:Geometry):void Remove a component from this geometry. | Collection
|  | removeComponents(components:Array):void Remove components from this geometry. | Collection
|  | replaceComponent(index:int, component:Geometry):Boolean replace the component of specified index by the input geometry. | Collection
|  | segmentsIntersect(seg1:Array, seg2:Array, tolerance:Number = 0.0):Boolean [static] Determine whether two line segments intersect or not. | Geometry
|  | toShortString():String Component of the specified index, casted to the LinearRing type | Polygon
|  | toVertices():Array Return an array of all the vertices (Point) of this geometry | Collection
|  | transform(source:ProjProjection, dest:ProjProjection):void Moves a geometry by the given displacement along positive x and y axes. | Collection

Property detail

area | property

`area:Number` [read-only]

Calculate the approximate area of this geometry (the projection and the geodesic are not managed). Be careful, if some components intersect themselves, the intersection area is substracted several times ! Moreover, the auto-intersection of edges of each LinearRing is not managed.

Implementation
`public function get area():Number`
Constructor detail

Polygon | () | constructor

`public function Polygon(rings:Array)`

Constructor for a Polygon geometry. The first ring (components[0]) is the outer bounds of the polygon and all subsequent rings (component[1..n]) are internal holes.

Parameters

| `rings:Array` — the polygon and its holes

Method detail

clone | () | method

`public override function clone():Geometry`

To get this geometry clone

Returns

| `Geometry`

containsPoint | () | method |

`public override function containsPoint(p:Point):Boolean`

Test if a point is inside this geometry.

Parameters

| `p:Point` — the point to test

Returns

| `Boolean` — a boolean defining if the point is inside or outside this geometry

createRegularPolygon | () | method |

`public function createRegularPolygon(origin:Point, radius:Number, sides:Number, rotation:Number):Polygon`

Create a regular polygon around a radius. Useful for creating circles and the like.

Parameters

| `origin:Point` — The center of polygon.
| `radius:Number` — Distance to vertex, in map units.
| `sides:Number` — Number of sides. 20 approximates a circle.
| `rotation:Number` — original angle of rotation, in degrees.

Returns

| `Polygon`

intersects | () | method |

`public override function intersects(geom:Geometry):Boolean`

Determine if the input geometry intersects this one.

Parameters

| `geom:Geometry` — Any type of geometry.

Returns

| `Boolean` — The input geometry intersects this one.

isPointInPolygon | () | method |

`public function isPointInPolygon(point:Point, manageHoles:Boolean = true):Boolean`

Test if a point is inside a polygon. A point on a polygon edge is considered inside. A point on at least one of the holes is considered outside except if the manageHoles parameter is set to false.

Parameters

| `point:Point` — the point to test
| `manageHoles:Boolean` (default = `true`)`` — a boolean defining if the test must manage the holes (default) or not.

Returns

| `Boolean` — a boolean defining if the point is inside or outside this geometry

toShortString | () | method |

`public override function toShortString():String`

Component of the specified index, casted to the LinearRing type

Returns

| `String`