new GeoPolygon(obj)
建立多邊形
Name | Type | Description |
---|---|---|
obj |
GeoPolygon | GeoPolyline | GeoBoundary | Array.<GeoPoint> |
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.js, line 6458 -
將傳入的Line用此Polygon來切除,只剩在Polygon內的線。
Name Type Description s
GeoLine 欲處理的線段資料。
result
GeoLine 此為out參數,須在執行前先配置好,執行後,此為處理後的答案。
Returns:
Type Description Boolean 傳回執行是否成功。 -
ClipPolygon(s, result){Boolean}
common/Geometry.js, line 6502 -
將傳入的Polygon用此Polygon來切除,只剩在Polygon內的範圍。
Name Type Description s
GeoPolygon 欲處理的多邊形資料。
result
GeoPolygon 此為out參數,須在執行前先配置好,執行後,此為處理後的答案。
Returns:
Type Description Boolean 傳回執行是否成功。 -
Clone(){GeoPolygon}
common/Geometry.js, line 6147 -
產生一份新的自己。
Returns:
Type Description GeoPolygon 傳回複製的新的自己。 -
CombinPolygon(polygon, polygonSet, combineType){Boolean}
common/Geometry.js, line 6621 -
將自己與傳入的Polygon做合併運算。
Name Type Description polygon
GeoPolygon 運算的Polygon資料。
polygonSet
GeoPolygonSet 此為out參數,需先在外面配好變數,合併後的結果。
combineType
GEO_CB_TYPE 運算類型。
Returns:
Type Description Boolean 傳回運算是否成功。 -
ConvertToPolyline(){GeoPolyline}
common/Geometry.js, line 7357 -
將此Polygon轉為Polyline。
Returns:
Type Description GeoPolyline 傳回轉換後的Polyline。 -
CopyFrom(obj){GeoPolygon}
common/Geometry.js, line 6155 -
複製。
Name Type Description obj
GeoLine | GeoPolyline | Array.<GeoPoint> 複製的資料源。
Returns:
Type Description GeoPolygon this。 -
Distance(obj){Number}
common/Geometry.js, line 7272 -
計算自己與傳入幾何的距離。
Name Type Description obj
GeoPoint | GeoLine | GeoPolyline | GeoPolygon | GeoPolygonSet 要計算距離的幾何資料。
Returns:
Type Description Number 傳回距離。 -
DistanceInBound(p){Number}
common/Geometry.js, line 7425 -
計算傳入的點到Polygon邊緣上的距離。
Name Type Description p
GeoPoint 要計算距離的幾何資料。
Returns:
Type Description Number 傳回距離。 -
FromGeoJSON(src){Boolean}
common/Geometry.js, line 7387 -
讀入GeoJSON數值。
Name Type Description src
Object | String GeoJSON物件或字串。
Returns:
Type Description Boolean 回傳讀取是否成功。 -
GetArea(){Number}
common/Geometry.js, line 6266 -
計算此Polygon的面積。
Returns:
Type Description Number 傳回計算的面積。 -
GetAt(index){GeoPoint}
common/Geometry.js, line 6221 -
取第index個點。
Name Type Description index
Number 索引。
Returns:
Type Description GeoPoint 第index個點。 -
Include(obj, bound){Boolean}
common/Geometry.js, line 7184 -
判斷傳入的幾何資料是否被自己包含。
Name Type Description obj
GeoPoint | GeoLine | GeoPolyline | GeoPolygon | GeoPolygonSet 判斷的幾何資料。
bound
Boolean 只用於Polygon與PolygonSet,指示相交於編上是否算包含。
Returns:
Type Description Boolean 傳回是否包含。 -
IsConvex(){Boolean}
common/Geometry.js, line 6284 -
判定此Polygon是否為凸多邊形。
Returns:
Type Description Boolean 傳回判斷結果。 -
IsGood(){Boolean}
common/Geometry.js, line 6335 -
判定此Polygon是否為好的Polygon(順序對,沒自己相交,有面積...)。
Returns:
Type Description Boolean 傳回判斷結果。 -
IsIntersect(obj, slice){Boolean}
common/Geometry.js, line 6599 -
判斷自己與傳入幾何是否相交。
Name Type Description obj
GeoPolyline | GeoPolygon | GeoPolygonSet 判斷的幾何資料。
slice
Boolean 指定若只交在節點上,算不算相交。
Returns:
Type Description Boolean 傳回是否相交。 -
MakeBuffer(distance, polygonSet){Boolean}
common/Geometry.js, line 7305 -
做出環域的PolygonSet。
Name Type Description distance
Number 環域的距離。
polygonSet
GeoPolygonSet out參數,環域計算的答案。
Returns:
Type Description Boolean 回傳是否成功。 -
Offset(p)
common/Geometry.js, line 7293 -
位移p。
Name Type Description p
GeoPoint 欲位移的距離。
-
PtInPolygon(p, obj){Boolean}
common/Geometry.js, line 6238 -
檢查傳入的點p是否位於此Polygon內。
Name Type Description p
GeoPoint 欲檢查的點。
obj
Object 此為out參數,需在執行前先配置好,執行後,Obj.InBound=true|false代表是否位於邊緣上。
Returns:
Type Description Boolean 傳回是否位於Polygon內。 -
RemoveAll()
common/Geometry.js, line 6180 -
移除所有的點位資料。
-
SetAt(index, obj)
common/Geometry.js, line 6229 -
設定第index個點。
Name Type Description index
Number 索引。
obj
GeoPoint 要設定的值。
-
SetGeoData(buffer){Boolean}
common/Geometry.js, line 6188 -
設定幾何資料,會檢查順逆時針,將其調整成正確的順序,若已知順序,可直接將點位資料Copy進Buffer變數,以增進效能。
Name Type Description buffer
Array.<GeoPoint> 要Copy的點位資料。
Returns:
Type Description Boolean 是否Copy成功。 -
SimplifyByPointCount(count){Number}
common/Geometry.js, line 7348 -
給定指定點數(希望簡約化後的點數),計算簡約化。
Name Type Description count
Number 簡約化後希望的點數。
Returns:
Type Description Number 傳回簡約化後,剩餘的點數。 -
SimplifyByTolerance(maxErr, polylines){Number}
common/Geometry.js, line 7322 -
給定誤差值,計算簡約化
Name Type Default Description maxErr
Number 簡約化的誤差值。
polylines
Array.<GeoPolyline> | undefined null 簡約化過程中,要避免與這些Polyline相交。
Returns:
Type Description Number 傳回簡約化後,剩餘的點數。 -
SplitByLine(line, rightAnswer, leftAnswer){Boolean}
common/Geometry.js, line 6646 -
將自己用傳入的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.js, line 7053 -
將自己用傳入的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.js, line 6878 -
將自己用傳入的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.js, line 7403 -
輸出成緩衝區物件。
Returns:
Type Description Float64Array 回傳多邊形點位陣列。 -
ToGeoJSON(toString){Object|String}
common/Geometry.js, line 7370 -
將幾何輸出成GeoJSON物件或字串。
Name Type Description toString
Boolean 是否把物件轉成JSON字串。
Returns:
Type Description Object | String 輸出轉換結果。