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).
As new geometries are added to the collection, they are NOT cloned. When removing geometries, they need to be specified by reference (ie you have to pass in the exact geometry to be removed).
The <getArea> and getLength functions here merely iterate through the components, summing their respective areas and lengths.
Create a new instance with the ZOO.Geometry.Collection constructor.
Inherits from
NAME | DESCRIPTION |
---|---|
components | {Array(ZOO.Geometry)} The component parts of this geometry |
componentTypes | {Array(String)} An array of class names representing the types of components that the collection can include. |
NAME | DESCRIPTION |
---|---|
ZOO.Geometry.Collection | Creates a Geometry Collection – a list of geoms. |
destroy | Destroy this geometry. |
clone | Clone this geometry. |
getComponentsString | Get a string representing the components for this collection. |
calculateBounds | Recalculate the bounds by iterating through the components and calling extendBounds() on each item. |
addComponent | Add a new component (geometry) to the collection. |
removeComponents | Remove components from this geometry. |
removeComponent | Remove a component from this geometry. |
getLength | Calculate the length of this geometry. |
getCentroid | {ZOO.Geometry.Point} The centroid of the collection. |
getGeodesicLength | Calculate the approximate length of the geometry were it projected onto the earth. |
move | Moves a geometry by the given displacement along positive x and y axes. |
rotate | Rotate a geometry around some origin. |
resize | Resize a geometry relative to some origin. |
equals | Determine whether another geometry is equivalent to this one. |
transform | Reproject the components geometry from source to dest. |
intersects | Determine if the input geometry intersects this one. |
getVertices | Return a list of all points in this geometry. |
Properties
Functions
Creates a Geometry Collection – a list of geoms.
Parameters
components {Array(ZOO.Geometry)} Optional array of geometries
destroy: function ()
Destroy this geometry.
clone: function()
Clone this geometry.
Returns
{ZOO.Geometry.Collection} An exact clone of this collection.
getComponentsString: function()
Get a string representing the components for this collection.
Returns
{String} A string representation of the components of this geometry.
calculateBounds: function()
Recalculate the bounds by iterating through the components and calling extendBounds() on each item.
addComponent: function(component,index)
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
Returns
{Boolean} The component geometry was successfully added
removeComponents: function(components)
Remove components from this geometry.
Parameters
components {Array(ZOO.Geometry)} The components to be removed
removeComponent: function(component)
Remove a component from this geometry.
Parameters
component {ZOO.Geometry}
getLength: function()
Calculate the length of this geometry
Returns
{Float} The length of the geometry
getCentroid: function()
Returns
{ZOO.Geometry.Point} The centroid of the collection
getGeodesicLength: function(projection)
Calculate the approximate length of the geometry were it projected onto the earth.
Parameters
projection {ZOO.Projection} The spatial reference system for the geometry coordinates. If not provided, Geographic/WGS84 is assumed.
Returns
{Float} The appoximate geodesic length of the geometry in meters.
move: function(x,y)
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
rotate: function(angle,origin)
Rotate a geometry around some origin
Parameters
resize: function(scale,origin,ratio)
Resize a geometry relative to some origin. Use this method to apply a uniform scaling to a geometry.
Parameters
Returns
{ZOO.Geometry} The current geometry.
equals: function(geometry)
Determine whether another geometry is equivalent to this one. Geometries are considered equivalent if all components have the same coordinates.
Parameters
geom {ZOO.Geometry} The geometry to test.
Returns
{Boolean} The supplied geometry is equivalent to this geometry.
transform: function(source,dest)
Reproject the components geometry from source to dest.
Parameters
Returns
intersects: function(geometry)
Determine if the input geometry intersects this one.
Parameters
geometry {ZOO.Geometry} Any type of geometry.
Returns
{Boolean} The input geometry intersects this one.
getVertices: function(nodes)
Return a list of all points in this geometry.
Parameters
nodes {Boolean} For lines, only return vertices that are endpoints. If false, for lines, only vertices that are not endpoints will be returned. If not provided, all vertices will be returned.
Returns
{Array} A list of all vertices in the geometry.