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

Package | org.openscales.core.geometry
Class | public class Geometry
Subclasses | Collection, Point

A Geometry is a description of a geographic object. Create an instance of this class with the Geometry constructor. This is a base class, typical geometry types are described by subclasses of this class.

Public Properties

| Property | Defined by
--- | --- | ---
|  | area : Number [read-only] Returns the geometry's area. | Geometry
|  | bounds : Bounds | Geometry
|  | id : String | Geometry
|  | length : Number [read-only] Returns the geometry's length. | Geometry
|  | parent : Geometry | Geometry

Protected Properties

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

Public Methods

| Method | Defined by
--- | --- | ---
|  | Geometry(id:String = null) Geometry constructor | Geometry
|  | 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 The definition of the bounding box of the geometry must be overrided in each sub class | Geometry
|  | clearBounds():void Clear the geometry's bounds | Geometry
|  | clone():Geometry To get this geometry clone | Geometry
|  | 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. | Geometry
|  | destroy():void Destroys the geometry | Geometry
|  | 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
|  | intersects(geom:Geometry):Boolean Determine if the input geometry intersects this one. | Geometry
|  | 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
|  | segmentsIntersect(seg1:Array, seg2:Array, tolerance:Number = 0.0):Boolean [static] Determine whether two line segments intersect or not. | Geometry
|  | toShortString():String | Geometry
|  | toVertices():Array Return an array of all the vertices (Point) of this geometry | Geometry
|  | transform(source:ProjProjection, dest:ProjProjection):void Method to convert the lon/lat (x/y) value of the geometry from a projection system to an other. | Geometry

Property detail

area | property

`area:Number` [read-only]

Returns the geometry's area. Overrided by subclasses.

Implementation
`public function get area():Number`

_bounds | property |

`protected var _bounds:Bounds = null`

The bounds of this geometry

bounds | property |

`bounds:Bounds` [read-write]Implementation
`public function get bounds():Bounds`
`public function set bounds(value:Bounds):void`

id | property |

`id:String` [read-write]Implementation
`public function get id():String`
`public function set id(value:String):void`

length | property |

`length:Number` [read-only]

Returns the geometry's length. Overrided by subclasses.

Implementation
`public function get length():Number`

parent | property |

`parent:Geometry` [read-write]Implementation
`public function get parent():Geometry`
`public function set parent(value:Geometry):void`
Constructor detail

Geometry | () | constructor

`public function Geometry(id:String = null)`

Geometry constructor

Parameters

| `id:String` (default = `null`)``

Method detail

atPoint | () | method

`public function atPoint(lonlat:LonLat, toleranceLon:Number, toleranceLat:Number):Boolean`

Determines if the feature is placed at the given point with a certain tolerance (or not).

Parameters

| `lonlat:LonLat` — The given point
| `toleranceLon:Number` — The longitude tolerance
| `toleranceLat:Number` — The latitude tolerance

Returns

| `Boolean`

calculateBounds | () | method |

`public function calculateBounds():void`

The definition of the bounding box of the geometry must be overrided in each sub class

clearBounds | () | method |

`public function clearBounds():void`

Clear the geometry's bounds

clone | () | method |

`public function clone():Geometry`

To get this geometry clone

Returns

| `Geometry`

contains | () | method |

`public function contains(geom:Geometry, assertIntersection:Boolean = false):Boolean`

Determine if the input geometry is fully contained in this one.

Parameters

| `geom:Geometry` — Any type of geometry.
| `assertIntersection:Boolean` (default = `false`)`` — if the intersection has already been tested it is better to not retest it by setting this parameter to "true"

Returns

| `Boolean` — Boolean defining if the input geometry is contained or not.

containsPoint | () | method |

`public 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 function destroy():void`

Destroys the geometry

distanceTo | () | method |

`public function distanceTo(geom:Geometry):Number`

Calculate the closest distance between two geometries (on the x-y plane).

Parameters

| `geom:Geometry` — The target geometry.

Returns

| `Number` — The distance between this geometry and the target. If details is true, the return will be an object with distance, x0, y0, x1, and x2 properties. The x0 and y0 properties represent the coordinates of the closest point on this geometry. The x1 and y1 properties represent the coordinates of the closest point on the target geometry.

extendBounds | () | method |

`public function extendBounds(newBounds:Bounds):void`

Extends geometry's bounds If bounds are not defined yet, it initializes the bounds. If bounds are already defined, it extends them.

Parameters

| `newBounds:Bounds` — Bounds to extend gemetry's bounds

intersects | () | method |

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

Determine if the input geometry intersects this one.

Parameters

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

Returns

| `Boolean` — Boolean defining if the input geometry intersects this one.

isLeftOrRight | () | method |

`public static function isLeftOrRight(p:Point, p0:Point, p1:Point):Number`

Test if a point is at the left, at the right or on an infinite line. Since x and y are number, result is also a number too

Parameters

| `p:Point` — the point to test
| `p0:Point` — two points that define an infinite line
| `p1:Point`

Returns

| `Number` — 0 if p is on the line (p0,p1), >0 if p is on its left, <0 if p is on its right

segmentsIntersect | () | method |

`public static function segmentsIntersect(seg1:Array, seg2:Array, tolerance:Number = 0.0):Boolean`

Determine whether two line segments intersect or not. This function is optimized for oriented segments so that x1 <= x2.

Parameters

| `seg1:Array` — Array representing a segment of two points ordered so that seg1.point1.x <= seg1.point2.x
| `seg2:Array` — Array representing a segment of two points ordered so that seg2.point1.x <= seg2.point2.x
| `tolerance:Number` (default = `0.0`)`` — if >0, two segments with a respective distance lower than this tolerance are considered intersecting

Returns

| `Boolean` — Boolean caracterizing if the two input segments intersect

toShortString | () | method |

`public function toShortString():String`

Returns

| `String`

toVertices | () | method |

`public function toVertices():Array`

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

Returns

| `Array`

transform | () | method |

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

Method to convert the lon/lat (x/y) value of the geometry from a projection system to an other.

Parameters

| `source:ProjProjection` — The source projection
| `dest:ProjProjection` — The destination projection