Class: Collection

SuperMap.Geometry.Collection

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 SuperMap.Geometry.Collection constructor.

new SuperMap.Geometry.Collection(components)

Collection.js, line 6
Name Type Description
components Array.<SuperMap.Geometry> optional

An array of geometric objects.

Example
var point1 = new SuperMap.Geometry.Point(10,20);
var point2 = new SuperMap.Geometry.Point(30,40);
var col = new SuperMap.Geometry.Collection([point1,point2]);

Extends

Members

Bounds of the geometric object.

componentsArray.<SuperMap.Geometry>

The component parts of this geometry.

componentTypesArray.<string>

The geometry format array supported by geometry object on the components storage.

idstring

The unique identifier of the geometric object.

This is set when a Geometry is added as component of another geometry

SRIDinterger

Projection coordinate parameter. By this parameter, server will determine whether the geometry object's coordinate reference is as the same as dataset, if not, then change projection before adding into database.

Example
var geometry= new SuperMap.Geometry();
  geometry. SRID=4326;

Methods

addComponent(component, index){boolean}

Collection.js, line 120

Add a geometry to this collection. If the componentTypes is set,the type of the geometry that to be added must on the componentTypes.

Name Type Description
component SuperMap.Geometry

The geometry to be added.

index int optional

The position of the insert of a geometric object.

Returns:
Type Description
boolean Whether or not to add success.

addComponents(components)

Collection.js, line 103

Add components to this geometry.

Name Type Description
components Array.<SuperMap.Geometry>

An array of geometries to add.

Example
var collection = new SuperMap.Geometry.Collection();
collection.addComponents(new SuerpMap.Geometry.Point(10,10));

calculateBounds()

Collection.js, line 82

Recalculate the bounds by traversing array, Call the extend method when traversing each subitem.

inherited clearBounds()

Geometry.js, line 82

clear bounds of the geometric object. If the object has a parent class, it also clears the bounds of the parent class geometry object.

clone(){SuperMap.Geometry.Collection}

Collection.js, line 52

Clone this geometry.

Returns:
Type Description
SuperMap.Geometry.Collection An exact clone of this collection.

destroy()

Collection.js, line 42

Destroy this geometry.

equals(geometry){boolean}

Collection.js, line 197

Determine whether another geometry is equivalent to this one. Geometries are considered equivalent if all components have the same coordinates.

Name Type Description
geometry SuperMap.Geometry

The geometry to determined.

Returns:
Type Description
boolean Whether the input geometry is equal to the current geometry.

inherited extendBounds(newBounds)

Geometry.js, line 95

Extend the existing bounds to include the new bounds. If geometry's bounds is not yet set, then set a new Bounds.

Name Type Description
newBounds SuperMap.Bounds

New bounds.

getArea(){number}

Collection.js, line 184

Calculate the area of this geometry. Note how this function is overridden in SuperMap.Geometry.Polygon.

Returns:
Type Description
number The area of the collection by summing its parts.

inherited getBounds(){SuperMap.Bounds}

Geometry.js, line 112

Gets the boundary of the geometric graphic. If not set, it can be acquired through computing.

Returns:
Type Description
SuperMap.Bounds Returns the bounds of the geometry.

getComponentsString(){string}

Collection.js, line 69

Get the components string.

Returns:
Type Description
string the components string.

getVertices(nodes){Array}

Collection.js, line 223

Return a list of all points in this geometry.

Name Type Description
nodes boolean optional

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:
Type Description
Array A list of all vertices in the geometry.

removeComponent(component){boolean}

Collection.js, line 169

Remove a component from this geometry.

Name Type Description
component SuperMap.Geometry

The component to be removed

Returns:
Type Description
boolean Whether or not the component is removed successfully.

removeComponents(components){boolean}

Collection.js, line 151

Remove components from this geometry.

Name Type Description
components Array.<SuperMap.Geometry>

The components to be removed.

Returns:
Type Description
boolean Whether or not the components is removed successfully.

inherited setBounds(bounds)

Geometry.js, line 70

Set bounds of the geometric object.

Name Type Description
bounds SuperMap.Bounds

bounds.