Packageorg.openscales.core.geometry
Classpublic class Polygon
InheritancePolygon Inheritance Collection Inheritance Geometry

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



Public Properties
 PropertyDefined by
  area : Number
[read-only] Calculate the approximate area of this geometry (the projection and the geodesic are not managed).
Polygon
 Inheritedbounds : Bounds
Geometry
 Inheritedcomponents : Array
Setter of the components (children) of this collection.
Collection
 InheritedcomponentsLength : int
Number of components in the collection
Collection
 InheritedcomponentsString : String
Get a string representing the components for this collection
Collection
 InheritedcomponentTypes : Array
Getter and setter of the authorized types for the components (children) of this collection
Collection
 Inheritedid : String
Geometry
 Inheritedlength : Number
Returns the geometry's length.
Geometry
 Inheritedparent : Geometry
Geometry
Protected Properties
 PropertyDefined by
 Inherited_bounds : Bounds = null
The bounds of this geometry
Geometry
Public Methods
 MethodDefined by
  
Polygon(rings:Array)
Constructor for a Polygon geometry.
Polygon
 Inherited
addComponent(component:Geometry, index:Number):Boolean
Add a new component (geometry) to the collection.
Collection
 Inherited
addComponents(components:Array):void
Add components to this geometry.
Collection
 Inherited
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
 Inherited
Recalculate the bounds by iterating through the components and calling extendBounds() on each item.
Collection
 Inherited
clearBounds():void
Clear the geometry's bounds
Geometry
  
To get this geometry clone
Polygon
 Inherited
Component of the specified index, casted to the Geometry type
Collection
 Inherited
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
 Inherited
destroy():void
Destroy the collection.
Collection
 Inherited
distanceTo(geom:Geometry):Number
Calculate the closest distance between two geometries (on the x-y plane).
Geometry
 Inherited
extendBounds(newBounds:Bounds):void
Extends geometry's bounds If bounds are not defined yet, it initializes the bounds.
Geometry
 Inherited
TO get component clone
Collection
  
intersects(geom:Geometry):Boolean
Determine if the input geometry intersects this one.
Polygon
 Inherited
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
 Inherited
removeComponent(component:Geometry):void
Remove a component from this geometry.
Collection
 Inherited
removeComponents(components:Array):void
Remove components from this geometry.
Collection
 Inherited
replaceComponent(index:int, component:Geometry):Boolean
replace the component of specified index by the input geometry.
Collection
 Inherited
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
 Inherited
toVertices():Array
Return an array of all the vertices (Point) of this geometry
Collection
 Inherited
transform(source:ProjProjection, dest:ProjProjection):void
Moves a geometry by the given displacement along positive x and y axes.
Collection
Property detail
areaproperty
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