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

Package | org.openscales.core.geometry
Class | public class Collection
Inheritance | Collection Geometry
Subclasses | MultiLineString, MultiPoint, MultiPolygon, Polygon

A Collection is exactly what it sounds like: A collection of different Geometries. These are stored in the local parameter components (which can be passed as a parameter to the constructor). The getArea and getLength functions here merely iterate through the components, summing their respective areas and lengths.

Public Properties
Hide Inherited Public Properties
Show Inherited Public Properties

| Property | Defined by
--- | --- | ---
|  | area : Number [read-only] Calculate the length of this geometry | Collection
|  | bounds : Bounds | Geometry
|  | components : Array [write-only] Setter of the components (children) of this collection. | Collection
|  | componentsLength : int [read-only] Number of components in the collection | Collection
|  | componentsString : String [read-only] 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
--- | --- | ---
|  | Collection(components:Array) Creates a Geometry Collection | Collection
|  | 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 | Collection
|  | 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. | Collection
|  | 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. | Collection
|  | 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
|  | 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 | Collection
|  | 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 length of this geometry

Implementation
`public function get area():Number`

components | property |

`components:Array` [write-only]

Setter of the components (children) of this collection. The getter is not defined to avoid to return a untyped array. Use componentsLength() and componentByIndex(i) instead.

Implementation
`public function set components(value:Array):void`

componentsLength | property |

`componentsLength:int` [read-only]

Number of components in the collection

Implementation
`public function get componentsLength():int`

componentsString | property |

`componentsString:String` [read-only]

Get a string representing the components for this collection

Implementation
`public function get componentsString():String`

componentTypes | property |

`componentTypes:Array` [read-write]

Getter and setter of the authorized types for the components (children) of this collection

Implementation
`public function get componentTypes():Array`
`public function set componentTypes(value:Array):void`
Constructor detail

Collection | () | constructor

`public function Collection(components:Array)`

Creates a Geometry Collection

Parameters

| `components:Array`

Method detail

addComponent | () | method

`public function addComponent(component:Geometry, index:Number):Boolean`

Add a new component (geometry) to the collection. If this.componentTypes is set, then the component class name must be in the componentTypes array. The bounds cache is reset.

Parameters

| `component:Geometry` — A geometry to add
| `index:Number` — Optional index into the array to insert the component

Returns

| `Boolean` — The component geometry was successfully added

addComponents | () | method |

`public function addComponents(components:Array):void`

Add components to this geometry.

Parameters

| `components:Array` — An array of geometries to add

calculateBounds | () | method |

`public override function calculateBounds():void`

Recalculate the bounds by iterating through the components and calling extendBounds() on each item.

clone | () | method |

`public override function clone():Geometry`

To get this geometry clone

Returns

| `Geometry`

componentByIndex | () | method |

`public function componentByIndex(i:int):Geometry`

Component of the specified index, casted to the Geometry type

Parameters

| `i:int`

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

destroy | () | method |

`public override function destroy():void`

Destroy the collection.

getcomponentsClone | () | method |

`public function getcomponentsClone():Array`

TO get component clone

Returns

| `Array`

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.

removeComponent | () | method |

`public function removeComponent(component:Geometry):void`

Remove a component from this geometry.

Parameters

| `component:Geometry`

removeComponents | () | method |

`public function removeComponents(components:Array):void`

Remove components from this geometry.

Parameters

| `components:Array` — The components to be removed

replaceComponent | () | method |

`public function replaceComponent(index:int, component:Geometry):Boolean`

replace the component of specified index by the input geometry.

Parameters

| `index:int` — the index of the component to replace
| `component:Geometry` — the new component to use

Returns

| `Boolean`

toShortString | () | method |

`public override function toShortString():String`

Returns

| `String`

toVertices | () | method |

`public override function toVertices():Array`

Return an array of all the vertices (Point) of this geometry

Returns

| `Array`

transform | () | method |

`public override function transform(source:ProjProjection, dest:ProjProjection):void`

Moves a geometry by the given displacement along positive x and y axes. This modifies the position of the geometry and clears the cached bounds.

Parameters

| `source:ProjProjection` — Distance to move geometry in positive x direction.
| `dest:ProjProjection` — Distance to move geometry in positive y direction.