<< Click to Display Table of Contents >>

 

new sg.geometry.MultiPolygon()

 

 

Description

create a multi-polygon object.

 

Position

Geometry.js

 

 

Properties

 

Properties

Type

Description

extent

sg.geometry.Extent

Geometry extent

parts

Array.<sg.geometry.Geometry>

Array of geometries

type

String

Geometry type

 

 

Methods

 

Methods

Type

Description

addPart(part)

sg.geometry.Geometry

add geometries to the collection

Name

Type

Description

part

sg.geometry.Geometry

The geometry object

getExtent()

Returns:

sg.geometry.Extent

return geometry extent object

Returns:

Type

Description

sg.geometry.Extent

The extent object

update(updatePart)

None

whether to update other geometry parts

Name

Type

Description

updatepart

Boolean

T: Update

F: Do not update

toWkt()

Returns:

String

convert to WKT string

Returns:

Type

Description

String

wkt字串

Contains(geom)        

sg.geometry.Geometry

return whether a geometry object is contained in a multi-polygon geometry object.

Name

Type

Description

part

sg.geometry.Geometry

geometry object

Returns:

Type

Description

Boolean

True:The geometry object is inside the multipolygon.
False:The geometry object is NOT inside the multipolygon.

getCentroid()        

Returns:

sg.geometry.Point

return the centroid of a multi-polygon geometry object

Returns:

Type

Description

sg.geometry.Point

centroid of a multi-polygon

getFirstPoint_        

Returns:

sg.geometry.Point

Get the first vertex of a multi-polygon geometry object

Returns:

Type

Description

sg.geometry.Point

vertex of a multi-polygon

Clone()

Returns:

sg.geometry.MultiPolygon

Copy the multi-polygon geomtery object

Returns:

Type

Description

sg.geometry.MultiPolygon

multi-polygon geomtery object

forEachVertex(callback)        

function

Get each verttex of a mult-polygon

 

callback(context)

{

 //Vertex

 Context.point;

 //Vertex index

 Context.pointIndex;

}

 

 

Example

 

 

<script type="text/javascript" src="scripts/Geometry.js"></script>

                         

var multipolygon = new sg.geometry.MultiPolygon;

 

var polygon1 = new sg.geometry.Polygon;

var ring1 = new sg.geometry.LinearRing;

ring1.path.push(new sg.geometry.Point(1628256, 5128329));

ring1.path.push(new sg.geometry.Point(2101868, 5163128));

ring1.path.push(new sg.geometry.Point(2274538, 5546056));

ring1.path.push(new sg.geometry.Point(1941530, 5558390));

polygon1.addRing(ring1);

polygon1.update();

 

var polygon2 = new sg.geometry.Polygon;

var ring2 = new sg.geometry.LinearRing;

ring2.path.push(new sg.geometry.Point(1778256, 5228329));

ring2.path.push(new sg.geometry.Point(2051868, 5263128));

ring2.path.push(new sg.geometry.Point(2174538, 5446056));

ring2.path.push(new sg.geometry.Point(1991530, 5458390));

polygon2.addRing(ring2);

polygon2.update();

 

multipolygon.addPart(polygon1);

multipolygon.addPart(polygon2);

 

 

See live example

 


©2015 Supergeo Technologies Inc.