new GeoPolygon(obj)
建立多邊形
Name | Type | Description |
---|---|---|
obj |
GeoPolygon | GeoPolyline | GeoBoundary | Array.<PointLike> |
optional
欲複製的GeoPolygon;欲轉換的GeoPolyline;欲轉換的GeoBoundary;GeoPoint陣列。 |
Example
var a = new GeoPolygon();//預設建構子
var b = new GeoPolygon(a);//使用欲複製的GeoPolygon建立GeoPolygon
var c = new GeoPolygon(new GeoPolyline());//使用欲轉換的GeoPolyline建立GeoPolygon
var d = new GeoPolygon(new GeoBoundary());//使用欲轉換的GeoBoundary建立GeoPolygon
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 e = new GeoPolygon([p1, p2, p3]);//使用GeoPoint陣列建立GeoPolygon
Extends
Members
-
readonlyBoundary
-
此幾何的範圍
Properties:
Name Type Description Boundary
GeoBoundary 範圍
-
BufferArray.<GeoPoint>
-
放置點位的Buffer
-
readonlyCenter
-
此幾何的中心點
Properties:
Name Type Description Center
GeoPoint 中心點
-
length
-
內含點位的數量
Properties:
Name Type Description length
number 點位的數量
-
readonlytype
-
物件型態,值為GEO_TYPE.POLYGON
Properties:
Name Type Description type
GEO_TYPE 物件型態
Methods
-
ClipLine(s, result){boolean}
common/geometry/GeoPolygon.js, line 546 -
將傳入的Line用此Polygon來切除,只剩在Polygon內的線。
Name Type Description s
GeoLine 欲處理的線段資料。
result
GeoLine 此為out參數,須在執行前先配置好,執行後,此為處理後的答案。
Returns:
Type Description boolean 傳回執行是否成功。 -
ClipPolygon(s, result){boolean}
common/geometry/GeoPolygon.js, line 590 -
將傳入的Polygon用此Polygon來切除,只剩在Polygon內的範圍。
Name Type Description s
GeoPolygon 欲處理的多邊形資料。
result
GeoPolygon 此為out參數,須在執行前先配置好,執行後,此為處理後的答案。
Returns:
Type Description boolean 傳回執行是否成功。 -
Clone(){GeoPolygon}
common/geometry/GeoPolygon.js, line 235 -
產生一份新的自己。
Returns:
Type Description GeoPolygon 傳回複製的新的自己。 -
CombinPolygon(polygon, polygonSet, combineType){boolean}
common/geometry/GeoPolygon.js, line 709 -
將自己與傳入的Polygon做合併運算。
Name Type Description polygon
GeoPolygon 運算的Polygon資料。
polygonSet
GeoPolygonSet 此為out參數,需先在外面配好變數,合併後的結果。
combineType
GEO_CB_TYPE 運算類型。
Returns:
Type Description boolean 傳回運算是否成功。 -
ConvertToPolyline(){GeoPolyline}
common/geometry/GeoPolygon.js, line 1445 -
將此Polygon轉為Polyline。
Returns:
Type Description GeoPolyline 傳回轉換後的Polyline。 -
CopyFrom(obj){GeoPolygon}
common/geometry/GeoPolygon.js, line 243 -
複製。
Name Type Description obj
GeoLine | GeoPolyline | Array.<GeoPoint> 複製的資料源。
Returns:
Type Description GeoPolygon this。 -
Distance(obj){number}
common/geometry/GeoPolygon.js, line 1360 -
計算自己與傳入幾何的距離。
Name Type Description obj
GeoPoint | GeoLine | GeoPolyline | GeoPolygon | GeoPolygonSet 要計算距離的幾何資料。
Returns:
Type Description number 傳回距離。 -
DistanceInBound(p){number}
common/geometry/GeoPolygon.js, line 1513 -
計算傳入的點到Polygon邊緣上的距離。
Name Type Description p
GeoPoint 要計算距離的幾何資料。
Returns:
Type Description number 傳回距離。 -
FromGeoJSON(src){boolean}
common/geometry/GeoPolygon.js, line 1475 -
讀入GeoJSON數值。
Name Type Description src
GeoJSON.PolygonSet | string GeoJSON物件或字串。
Returns:
Type Description boolean 回傳讀取是否成功。 -
GetArea(){number}
common/geometry/GeoPolygon.js, line 354 -
計算此Polygon的面積。
Returns:
Type Description number 傳回計算的面積。 -
GetAt(index){GeoPoint}
common/geometry/GeoPolygon.js, line 309 -
取第index個點。
Name Type Description index
number 索引。
Returns:
Type Description GeoPoint 第index個點。 -
Include(obj, bound){boolean}
common/geometry/GeoPolygon.js, line 1272 -
判斷傳入的幾何資料是否被自己包含。
Name Type Description obj
GeoPoint | GeoLine | GeoPolyline | GeoPolygon | GeoPolygonSet 判斷的幾何資料。
bound
boolean 只用於Polygon與PolygonSet,指示相交於編上是否算包含。
Returns:
Type Description boolean 傳回是否包含。 -
IsConvex(){boolean}
common/geometry/GeoPolygon.js, line 372 -
判定此Polygon是否為凸多邊形。
Returns:
Type Description boolean 傳回判斷結果。 -
IsGood(){boolean}
common/geometry/GeoPolygon.js, line 423 -
判定此Polygon是否為好的Polygon(順序對,沒自己相交,有面積...)。
Returns:
Type Description boolean 傳回判斷結果。 -
IsIntersect(obj, slice){boolean}
common/geometry/GeoPolygon.js, line 687 -
判斷自己與傳入幾何是否相交。
Name Type Description obj
GeoPolyline | GeoPolygon | GeoPolygonSet 判斷的幾何資料。
slice
boolean 指定若只交在節點上,算不算相交。
Returns:
Type Description boolean 傳回是否相交。 -
MakeBuffer(distance, polygonSet){boolean}
common/geometry/GeoPolygon.js, line 1393 -
做出環域的PolygonSet。
Name Type Description distance
number 環域的距離。
polygonSet
GeoPolygonSet out參數,環域計算的答案。
Returns:
Type Description boolean 回傳是否成功。 -
Offset(p)
common/geometry/GeoPolygon.js, line 1381 -
位移p。
Name Type Description p
GeoPoint 欲位移的距離。
-
PtInPolygon(p, obj){boolean}
common/geometry/GeoPolygon.js, line 326 -
檢查傳入的點p是否位於此Polygon內。
Name Type Description p
GeoPoint 欲檢查的點。
obj
Object 此為out參數,需在執行前先配置好,執行後,Obj.InBound=true|false代表是否位於邊緣上。
Returns:
Type Description boolean 傳回是否位於Polygon內。 -
RemoveAll()
common/geometry/GeoPolygon.js, line 268 -
移除所有的點位資料。
-
SetAt(index, obj)
common/geometry/GeoPolygon.js, line 317 -
設定第index個點。
Name Type Description index
number 索引。
obj
GeoPoint 要設定的值。
-
SetGeoData(buffer){boolean}
common/geometry/GeoPolygon.js, line 276 -
設定幾何資料,會檢查順逆時針,將其調整成正確的順序,若已知順序,可直接將點位資料Copy進Buffer變數,以增進效能。
Name Type Description buffer
Array.<PointLike> 要Copy的點位資料。
Returns:
Type Description boolean 是否Copy成功。 -
SimplifyByPointCount(count){number}
common/geometry/GeoPolygon.js, line 1436 -
給定指定點數(希望簡約化後的點數),計算簡約化。
Name Type Description count
number 簡約化後希望的點數。
Returns:
Type Description number 傳回簡約化後,剩餘的點數。 -
SimplifyByTolerance(maxErr, polylines){number}
common/geometry/GeoPolygon.js, line 1410 -
給定誤差值,計算簡約化
Name Type Default Description maxErr
number 簡約化的誤差值。
polylines
Array.<GeoPolyline> | undefined null 簡約化過程中,要避免與這些Polyline相交。
Returns:
Type Description number 傳回簡約化後,剩餘的點數。 -
SplitByLine(line, rightAnswer, leftAnswer){boolean}
common/geometry/GeoPolygon.js, line 734 -
將自己用傳入的Line來切成右與左兩部分的Polygon。
Name Type Description line
GeoLine 切割的Line。
rightAnswer
Array.<GeoPolygon> 此為out參數,需在執行前先配置好,執行後,傳回右邊的Polygon。
leftAnswer
Array.<GeoPolygon> 此為out參數,需在執行前先配置好,執行後,傳回左邊的Polygon。
Returns:
Type Description boolean 傳回運算是否成功 -
SplitByPolygon(polygon, inside, outside){boolean}
common/geometry/GeoPolygon.js, line 1141 -
將自己用傳入的Polygon來切成內部與外部兩部分的PolygonSet。
Name Type Description polygon
GeoPolygon 切割的Polygon。
inside
Array.<GeoPolygonSet> 此為out參數,需在執行前先配置好,執行後,傳回內部的PolygonSet。
outside
Array.<GeoPolygonSet> 此為out參數,需在執行前先配置好,執行後,傳回外部的PolygonSet。
Returns:
Type Description boolean 傳回運算是否成功。 -
SplitByPolyline(line, rightAnswer, leftAnswer){boolean}
common/geometry/GeoPolygon.js, line 966 -
將自己用傳入的Polyline來切成右與左兩部分的Polygon。
Name Type Description line
GeoPolyline 切割的Line。
rightAnswer
Array.<GeoPolygon> 此為out參數,需在執行前先配置好,執行後,傳回右邊的Polygon。
leftAnswer
Array.<GeoPolygon> 此為out參數,需在執行前先配置好,執行後,傳回左邊的Polygon。
Returns:
Type Description boolean 傳回運算是否成功。 -
ToGeoBuffer(){Float64Array}
common/geometry/GeoPolygon.js, line 1491 -
輸出成緩衝區物件。
Returns:
Type Description Float64Array 回傳多邊形點位陣列。 -
ToGeoJSON(toString){GeoJSON.PolygonSet|string}
common/geometry/GeoPolygon.js, line 1458 -
將幾何輸出成GeoJSON物件或字串。
Name Type Description toString
boolean 是否把物件轉成JSON字串。
Returns:
Type Description GeoJSON.PolygonSet | string 輸出轉換結果。