new GeoLine(obj, to)
建立線段
Name | Type | Description |
---|---|---|
obj |
GeoLine | GeoPoint | Object |
optional
欲複製的GeoLine;指定的From;帶有From,To的Object。 |
to |
GeoPoint |
optional
指定的To。 |
Example
var a = new GeoLine();//預設建構子
var b = new GeoLine(a);//使用欲複製的GeoLine建立GeoLine
var from = new GeoPoint();
var to = new GeoPoint();
var c = new GeoLine(from, to);//指定From,To並建立GeoLine
var d = new GeoLine({From: from, To: to});//使用帶有From,To的Object建立GeoLine
Extends
Members
-
readonlyBoundary
-
此幾何的範圍
Properties:
Name Type Description Boundary
GeoBoundary 範圍
-
readonlyCenter
-
中心點
Properties:
Name Type Description Center
GeoPoint 中心點
-
From
-
起始點
Properties:
Name Type Description From
GeoPoint 起始點
-
readonlyLength
-
長度
Properties:
Name Type Description Length
Number 長度
-
PolarAngle
-
波拉角,即從起點往終點的向量,此向量的數學角度,單位為角度
Properties:
Name Type Description PolarAngle
Number 波拉角
-
To
-
終點
Properties:
Name Type Description To
GeoPoint 終點
-
readonlytype
-
物件型態,值為GEO_TYPE.LINE
Properties:
Name Type Description type
GEO_TYPE 物件型態
Methods
-
BackExtend(distance)
common/Geometry.js, line 4874 -
線段往後退縮Distance距離。
Name Type Description distance
Number 往後退縮的距離。
-
Classify(p){GEO_STATUS}
common/Geometry.js, line 4419 -
取得傳入點p與本身的相關位置。
Name Type Description p
GeoPoint 欲測試的資料點。
Returns:
Type Description GEO_STATUS 相關位置 -
Clone(){GeoLine}
common/Geometry.js, line 4340 -
產生一份新的自己。
Returns:
Type Description GeoLine 傳回複製的新的自己。 -
CopyFrom(obj){GeoLine}
common/Geometry.js, line 4348 -
複製。
Name Type Description obj
GeoLine 複製的資料源。
Returns:
Type Description GeoLine this -
Distance(obj){Number}
common/Geometry.js, line 4770 -
計算自己與傳入幾何的距離。
Name Type Description obj
GeoPoint | GeoLine | GeoPolyline | GeoPolygon | GeoPolygonSet 要計算距離的幾何資料。
Returns:
Type Description Number 傳回距離。 -
Flip()
common/Geometry.js, line 4664 -
將此線段的起點與終點對調。
-
ForwardExtend(distance)
common/Geometry.js, line 4863 -
線段往前延展Distance距離。
Name Type Description distance
Number 往前延展的距離。
-
FromGeoJSON(src){Boolean}
common/Geometry.js, line 4939 -
讀入GeoJSON數值。
Name Type Description src
Object | String GeoJSON物件或字串 。
Returns:
Type Description Boolean 回傳讀取是否成功。 -
GetNearPoint(p, ret){Number}
common/Geometry.js, line 4793 -
取得在此線段中,離傳入的點p最近的點Ret。
Name Type Description p
GeoPoint 要計算的點。
ret
GeoPoint 此為out,要在外面先配置好,會傳回最近的點。
Returns:
Type Description Number 傳回離最近的點的距離。 -
GetPoint(t){GeoPoint}
common/Geometry.js, line 4674 -
取得從起點往終點方向的某比例的點。
Name Type Description t
Number 欲取出點的比例,此比例可為正或負,單位為線段的長度。
Returns:
Type Description GeoPoint 取出的點 -
Intersect(e, obj, includeZ){GEO_STATUS}
common/Geometry.js, line 4634 -
取得與傳入線段e的相關位置。
Name Type Default Description e
GeoLine 欲比較的線段。
obj
GeoPoint | Object 此為out參數,需先在外面配好變數,回傳時,若為GeoPoint,則為交點,否則Obj.t代表交點離起點的距離,單位為整個線段的比例,也就是0<=Obj.t<=1。
includeZ
boolean false 是否處理z值,預設值為false
Returns:
Type Description GEO_STATUS 相關位置。 -
IsIntersect(line, endPointIncluded, obj, includeZ){boolean}
common/Geometry.js, line 4721 -
判斷自己與傳入線段Line是否相交。
Name Type Default Description line
GeoLine 欲檢查的線段。
endPointIncluded
Boolean 若只交道端點,是否算是相交。
obj
GeoPoint | Object 此為out參數,需先在外面配好變數,回傳時,若為GeoPoint,則為交點,否則Obj.t代表交點離起點的距離,單位為整個線段的比例,也就是0<=Obj.t<=1。
includeZ
boolean false 是否處理z值,預設值為false,只有在Obj類型為GeoPoint時有用。
Returns:
Type Description boolean 是否相交。 -
MakeBuffer(distance, polygonSet){Boolean}
common/Geometry.js, line 4856 -
做出環域的PolygonSet。
Name Type Description distance
Number 環域的距離。
polygonSet
GeoPolygonSet out參數,環域計算的答案。
Returns:
Type Description Boolean 回傳是否成功。 -
Offset(p)
common/Geometry.js, line 4846 -
將線段位移p。
Name Type Description p
GeoPoint 欲位移的距離。
-
PtInsideLine(p){Boolean}
common/Geometry.js, line 4839 -
判定點p是否位於線段中。
Name Type Description p
GeoPoint 欲判斷的點。
Returns:
Type Description Boolean 傳回判斷的結果。 -
Rot()
common/Geometry.js, line 4649 -
將此線段以中心點為旋轉中心,逆時針,轉動90度。
-
SplitBy(line, buffer1, buffer2){Number}
common/Geometry.js, line 4888 -
找出此線段和傳入線段Line的焦點。
Name Type Description line
GeoLine 要計算的線段。
buffer1
Array.<GeoPoint> 此為out參數,要在外面先配置好,傳回從自己的起點算,所經過的交點,因為是線段,所以最多只會有一個點。
buffer2
Array.<GeoPoint> 此為out參數,要在外面先配置好,傳回從傳入的Line起點算,所經過的交點,因為是線段,所以最多只會有一個點。
Returns:
Type Description Number 傳回所有交點數量。 -
ToGeoJSON(toString, includeZ){object|String}
common/Geometry.js, line 4914 -
將幾何輸出成GeoJSON物件或字串。
Name Type Description toString
Boolean 是否把物件轉成JSON字串。
includeZ
Boolean 是否包含Z,標準GeoJSON不包含Z(可不給,預設false)。
Returns:
Type Description object | String 輸出轉換結果。