Class: GeoPolyline

GeoPolyline

幾何物件:多點的線

new GeoPolyline(obj)

common/Geometry.js, line 4975

建立多點的線

Name Type Description
obj GeoPolyline | GeoLine | Array.<GeoPoint> optional

欲複製的GeoPolyline;欲轉換的GeoLine;GeoPoint陣列。

Example

var a = new GeoPolyline();//預設建構子
var b = new GeoPolyline(a);//使用欲複製的GeoPolyline建立GeoPolyline
var c = new GeoPolyline(new GeoLine());//使用欲轉換的GeoLine建立GeoPolyline

var p1 = new GeoPoint({x: 0, y: 0});
var p2 = new GeoPoint({x: 0, y: 1});
var p3 = new GeoPoint({x: 1, y: 0});
var d = new GeoPolyline([p1, p2, p3]);//使用GeoPoint陣列建立GeoPolyline

Extends

Members

readonlyBoundary

此幾何的範圍

Properties:
Name Type Description
Boundary GeoBoundary

範圍

Buffer

放置點位的Buffer

Properties:
Name Type Description
Buffer Array.<GeoPoint>

點位陣列

readonlyCenter

此幾何的中心點

Properties:
Name Type Description
Center GeoPoint

中心點

length

內含點位的數量

Properties:
Name Type Description
length Number

點位的數量

readonlyLength

長度

Properties:
Name Type Description
Length Number

長度

readonlytype

物件型態,值為GEO_TYPE.POLYLINE

Properties:
Name Type Description
type GEO_TYPE

物件型態

Methods

Clone(){GeoPolyline}

common/Geometry.js, line 5098

產生一份新的自己。

Returns:
Type Description
GeoPolyline 傳回複製的新的自己。

CopyFrom(obj){GeoLine}

common/Geometry.js, line 5106

複製。

Name Type Description
obj GeoLine | GeoPolyline | Array.<GeoPoint>

複製的資料源。

Returns:
Type Description
GeoLine this。

Distance(obj){Number}

common/Geometry.js, line 5187

計算自己與傳入幾何的距離。

Name Type Description
obj GeoPoint | GeoLine | GeoPolyline | GeoPolygon | GeoPolygonSet

要計算距離的幾何資料。

Returns:
Type Description
Number 傳回距離。

FromGeoJSON(src){Boolean}

common/Geometry.js, line 5725

讀入GeoJSON數值。

Name Type Description
src object | string

GeoJSON物件或字串 。

Returns:
Type Description
Boolean 回傳讀取是否成功。

Get3DNearPointFromPoint(destPoint){object}

common/Geometry.js, line 5825

取得聚合線在線上與目標點最近的點(考慮z),在平面中直接使用即可,在球型要先將線從Map轉成WorldMap再計算,算完再轉回Map。

Name Type Description
destPoint GeoPoint

目標點。

Returns:
Type Description
object success:是否成功,pt1:來源聚合線上的最近點,distance:目標聚合線上的最近點。

Get3DNearPointFromPolyline(destPolyline){object}

common/Geometry.js, line 5750

取得兩條聚合線在線上最近的兩點(考慮z),在平面中直接使用即可,在球型要先將線從Map轉成WorldMap再計算,算完再轉回Map。

Name Type Description
destPolyline GeoPolyline

目標聚合線。

Returns:
Type Description
object success:是否成功,pt1:來源聚合線上的最近點,pt2:目標聚合線上的最近點。

GetAt(index){GeoPoint}

common/Geometry.js, line 5125

取第index個點。

Name Type Description
index Number

索引。

Returns:
Type Description
GeoPoint 第index個點

GetNearPoint(p, ret){Number}

common/Geometry.js, line 5210

取得在此線段中,離傳入的點p最近的點Ret。

Name Type Description
p GeoPoint

要計算的點。

ret GeoPoint

此為out,要在外面先配置好,會傳回最近的點。

Returns:
Type Description
Number 傳回離最近的點的距離。

GetPointByDistance1(distance, p){Boolean}

common/Geometry.js, line 5482

從起點開始,沿著Polyline走,找出沿著Polyline的距離Distance的點位。

Name Type Description
distance Number

想要的距離。

p GeoPoint

此為out參數,需再呼叫前先配置好,執行後,傳回找到的答案。

Returns:
Type Description
Boolean 傳回是否有答案。

GetPointByDistance2(distance, p){Boolean}

common/Geometry.js, line 5513

從起點開始,沿著Polyline走,找出某點離起點直線距離為Distance的點位。

Name Type Description
distance Number

想要的距離。

p GeoPoint

此為out參數,需再呼叫前先配置好,執行後,傳回找到的答案。

Returns:
Type Description
Boolean 傳回是否有答案。

InsertPoint(p){Boolean}

common/Geometry.js, line 5627

若輸入的點p位於Polyline上,則將點p插於polyline中的適當位置。

Name Type Description
p GeoPoint

要插入的點。

Returns:
Type Description
Boolean 傳回是否成功。

Intersect(polyline, buffer){Number}

common/Geometry.js, line 5235

計算與傳入的Polyline的交點。

Name Type Description
polyline GeoPolyline

欲檢查的線段。

buffer Array.<GeoPoint>

此為out參數,需先在外面配好變數,回傳時,代表交點。

Returns:
Type Description
Number 交點的數量。

Inverse()

common/Geometry.js, line 5615

將點位逆向排序。

IsIntersect(obj, slice){Boolean}

common/Geometry.js, line 5282

判斷自己與傳入幾何是否相交。

Name Type Description
obj GeoPolyline | GeoPolygon | GeoPolygonSet

判斷的幾何資料。

slice Boolean

指定若只交在節點上,算不算相交。

Returns:
Type Description
Boolean 傳回是否相交。

Join(polyline){Boolean}

common/Geometry.js, line 5662

傳入的Polyline若與本身可相連,則將Polyline連於自己。

Name Type Description
polyline GeoPolyline

要相連的Polyline。

Returns:
Type Description
Boolean 傳回是否成功。

MakeBuffer(distance, polygonSet, twoSide){Boolean}

common/Geometry.js, line 5312

做出環域的PolygonSet。

Name Type Default Description
distance Number

環域的距離。

polygonSet GeoPolygonSet

out參數,環域計算的答案。

twoSide Boolean true optional

是否要兩邊

Returns:
Type Description
Boolean 回傳是否成功。

MidByDistance1(distance1, distance2){Boolean}

common/Geometry.js, line 5534

將自己切成沿Polyline走,距離Distance1與Distance2之間的Sub Polyline。

Name Type Description
distance1 Number

切割的起始距離。

distance2 Number

切割的結束距離。

Returns:
Type Description
Boolean 傳回是否切割成功。

MidByDistance2(distance1, distance2){Boolean}

common/Geometry.js, line 5576

將自己切成沿Polyline走,離起點直線距離Distance1與Distance2之間的Sub Polyline。

Name Type Description
distance1 Number

切割的起始距離。

distance2 Number

切割的結束距離。

Returns:
Type Description
Boolean 傳回是否切割成功。

Offset(p)

common/Geometry.js, line 5299

位移p。

Name Type Description
p GeoPoint

欲位移的距離。

RemoveAll()

common/Geometry.js, line 5654

移除所有點位資料。

SetAt(index, obj)

common/Geometry.js, line 5133

設定第index個點。

Name Type Description
index Number

索引。

obj GeoPoint

要設定的值。

SimplifyByPointCount(count, delta, dontCutPolylines){Number}

common/Geometry.js, line 5343

給定指定點數(希望簡約化後的點數),計算簡約化。

Name Type Default Description
count Number

簡約化後希望的點數。

delta Number

簡約化的誤差值。

dontCutPolylines Array.<GeoPolyline> | undefined null

簡約化過程中,要避免與這些Polyline相交。

Returns:
Type Description
Number 傳回簡約化後,剩餘的點數。

SimplifyByTolerance(maxErr, dontCutPolylines){Number}

common/Geometry.js, line 5332

給定誤差值,計算簡約化。

Name Type Default Description
maxErr Number

簡約化的誤差值。

dontCutPolylines Array.<GeoPolyline> | undefined null

簡約化過程中,要避免與這些Polyline相交。

Returns:
Type Description
Number 傳回簡約化後,剩餘的點數。

SplitByLine(line, buffer){Number}

common/Geometry.js, line 5357

被線段切割。

Name Type Description
line GeoLine

切割的線段。

buffer Array.<GeoPolyline>

此為out參數,需再呼叫前先配置好,執行完後,傳回切割的Polyline。

Returns:
Type Description
Number 傳回切割的線數量。

SplitByPolygon(polygon, inside, outside){Number}

common/Geometry.js, line 5429

被Polygon切割。

Name Type Description
polygon GeoPolygon

切割的Polygon。

inside Array.<GeoPolyline>

此為out參數,需再呼叫前先配置好,執行完後,傳回被切後,在Polygon內的Polyline。

outside Array.<GeoPolyline>

此為out參數,需再呼叫前先配置好,執行完後,傳回被切後,在Polygon外的Polyline。

Returns:
Type Description
Number 傳回被削下的所有Polyline的數量。

SplitByPolyline(line, retBuffer){Number}

common/Geometry.js, line 5371

被Polyline切割。

Name Type Description
line GeoPolyline

切割的Polyline。

retBuffer Array.<GeoPolyline>

此為out參數,需再呼叫前先配置好,執行完後,傳回切割的Polyline。

Returns:
Type Description
Number 傳回切割的線數量。

ToGeoJSON(toString, includeZ){object|string}

common/Geometry.js, line 5699

將幾何輸出成GeoJSON物件或字串。

Name Type Description
toString Boolean

是否把物件轉成JSON字串。

includeZ Boolean

是否包含Z,標準GeoJSON不包含Z(可不給,預設false)。

Returns:
Type Description
object | string 輸出轉換結果。