<< Click to Display Table of Contents >>

SuperGIS Server JavaScript API

 

new sg.geometry.LineString()

 

 

Description

建立一個線段物件

 

Position

Geometry.js

 

 

Properties

 

Properties

Type

Description

extent

sg.geometry.Extent

幾何資料範圍

type

String

幾何資料的類型

length

Number

線段長度

path

Array.<sg.geometry.Point>

線段路徑點陣列

 

 

Methods

 

Methods

Type

Description

addPoint(pt)

sg.geometry.Point

加入路徑點

Name

Type

Description

pt

sg.geometry.Point

路徑點

toWkt()

Returns:

String

轉換成wkt字串

Returns:

Type

Description

String

wkt字串

getExtent()

Returns:

sg.geometry.Extent

取得幾何資料範圍

Returns:

Type

Description

sg.geometry.Extent

幾何範圍

getLength()

Returns:

Number

取得線的長度

Returns:

Type

Description

Number

長度

getMidPoint()

Returns:

sg.geometry.Point

取得線條中點

Returns:

Type

Description

sg.geometry.Point

線條中點

setPath(path)

Array.<sg.geometry.Point>

設定線的路徑

Name

Type

Description

path

Array.<sg.geometry.Point>

路徑點陣列

update()


更新線的屬性

getCentroid()        

 

 

 

Returns:

sg.geometry.Point

取得線段的重心

Returns:

Type

Description    

sg.geometry.Point

重心點                    

Clone()        

Returns:

sg.geometry.LineString

複製線段幾何物件並回傳

Returns:

Type

Description

sg.geometry.LineString

線段幾何物件

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.pointIndex;

}

 

getFirstPoint_

Returns:

sg.geometry.point

取得線段物件的第一個點位

Return:

Type

Description

sg.geometry.point

線段物件的第一個點位

 

 

Example

 

 

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

                         

var line = new sg.geometry.LineString;

var path = [];

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

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

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

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

line.path = path;

line.update();

 

 

See live example

 


©2015 Supergeo Technologies Inc.