<< Click to Display Table of Contents >>

SuperGIS Server JavaScript API

 

new sg.geometry.Polygon()

 

 

Description

建立一個多邊形物件

 

Position

Geometry.js

 

 

Properties

 

Properties

Type

Description

extent

sg.geometry.Extent

幾何資料範圍

type

String

幾何資料的類型

area

Number

多邊形面積

rings

Array.<sg.geometry.LinearRing>

多邊形環的陣列

 

 

Methods

 

Methods

Type

Description

getExtent()

Returns:

sg.geometry.Extent

取得幾何資料範圍

Returns:

Type

Description

sg.geometry.Extent

幾何範圍

toWkt()

Returns:

String

轉換成wkt字串

Returns:

Type

Description

String

wkt字串

addRing(ring)

sg.geometry.LinearRing

在多邊形加入環

Name

Type

Description

ring

sg.geometry.LinearRing

contains(pt)

pt:sg.geometry.Point

Returns:Boolean

判斷一個點是否與多邊形相交

Name

Type

Description

pt

sg.geometry.Point

要判斷是否相交的點

Returns:

Type

Description

Boolean

是否與多邊形相交

True: 相交

False:不相交

getArea()

Returns:

Number

取得多邊形面積

Returns:

Type

Description

Number

多邊形面積

getCentroid()

Returns:

sg.geometry.Point

取得多邊形的重心

Returns:

Type

Description

sg.geometry.Point

形心點

isClockwise(ring)

ring:sg.geometry.LinearRing

Returns:Boolean

判斷一個環的方向是否為順時鐘方向

Name

Type

Description

ring

sg.geometry.LinearRing

Returns:

Type

Description

Boolean

是否為順時鐘方向

True:是
False:否

update()


更新多邊形的範圍、面積等等屬性

Clone()

 

Returns:

sg.geometry.Polygon

複製多邊形幾何物件並回傳

Returns:

Type

Description

sg.geometry.Polygon

多邊形幾何物件

transform(a,b,c,d,e,f,g,h,i)

Number

透過轉換參數,對多邊形幾何物件進行座標轉換

Name

Type

Description

a,b,c,d,e,f,g,h,i

Nmber

轉換矩陣元素,

轉換矩陣M=[[a, b, c], [d, e, f], [g, h, i]]

forEachVertex(callback)        

function

透過callback方法,回傳多邊形幾何物件的所有頂點資料

callback(context)

{

  //頂點資料  (sg.geometry.Point)

  context.point;

  //環陣列索引值

  context.ringIndex;

  //頂點資料索引值

  context.pointIndex;

}

getFirstPoint_

 

Returns:

sg.geometry.point

取得多邊形幾何物件的第一個點位

Returns:

Type

Description

sg.geometry.Point

多邊形幾何物件的第一個點位

 

 

Example

 

 

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

                         

var polygon = new sg.geometry.Polygon;

var ring = new sg.geometry.LinearRing;

ring.path.push(new sg.geometry.Point(1528256, 5628329));

ring.path.push(new sg.geometry.Point(2001868, 5663128));

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

ring.path.push(new sg.geometry.Point(1841530, 5458390));

polygon.addRing(ring);

polygon.update();

 

 

See live example

 


©2015 Supergeo Technologies Inc.