# Class: GeoPoint
GeoPoint
地理坐标.
# Table of contents
# Constructors
# Properties
# Methods
- add
- angle
- angleTo
- angleWith
- angleWithSep
- clone
- distSqr
- distanceTo
- div
- divByPoint
- dot
- equals
- equalsZ
- lengthSq
- lerp
- mag
- matMult
- mult
- multByPoint
- perp
- roateAround
- rotate
- round
- roundInt
- roundStr
- sub
- toArray
- toString
- transform
- unit
- convert
- fromString
# Constructors
# constructor
+ new GeoPoint(x
: number, y
: number, z?
: number): GeoPoint
GeoPoint
构造函数
# Parameters
Name | Type | Description |
---|---|---|
x | number | x坐标. |
y | number | y坐标. |
z? | number | z坐标(可选). |
Returns: GeoPoint
# Properties
# x
• x: number
坐标X.
# y
• y: number
坐标y.
# z
• Optional
z: number
坐标z(可选).
# Methods
# add
两个点相加.
# Parameters
Name | Type | Description |
---|---|---|
p | GeoPoint | 要相加的点. |
Returns: GeoPoint
# angle
▸ angle(): number
角度.
Returns: number
# angleTo
▸ angleTo(b
: GeoPoint): number
距一个点的角度
# Parameters
Name | Type |
---|---|
b | GeoPoint |
Returns: number
# angleWith
▸ angleWith(b
: GeoPoint): number
距一个点的interiorAngle
# Parameters
Name | Type |
---|---|
b | GeoPoint |
Returns: number
# angleWithSep
▸ angleWithSep(x
: number, y
: number): number
距一个点的interiorAngle
# Parameters
Name | Type |
---|---|
x | number |
y | number |
Returns: number
# clone
▸ clone(): GeoPoint
克隆一个坐标
Returns: GeoPoint
# distSqr
▸ distSqr(p
: GeoPoint): number
两点之间距离平方.
# Parameters
Name | Type |
---|---|
p | GeoPoint |
Returns: number
# distanceTo
▸ distanceTo(p
: GeoPoint): number
两点之间距离.
# Parameters
Name | Type |
---|---|
p | GeoPoint |
Returns: number
# div
▸ div(k
: number): GeoPoint
除一个系数.
# Parameters
Name | Type | Description |
---|---|---|
k | number | 系数. |
Returns: GeoPoint
# divByPoint
▸ divByPoint(p
: GeoPoint): GeoPoint
两个点相除.
# Parameters
Name | Type | Description |
---|---|---|
p | GeoPoint | 要相除的点. |
Returns: GeoPoint
# dot
▸ dot(p
: GeoPoint): number
# Parameters
Name | Type |
---|---|
p | GeoPoint |
Returns: number
# equals
▸ equals(other
: GeoPoint, dotErr?
: number): boolean
判断是否相等
# Parameters
Name | Type | Default value | Description |
---|---|---|---|
other | GeoPoint | - | 另外一个点 |
dotErr | number | 8 | 允许误差的小数点后几位,默认8位 |
Returns: boolean
# equalsZ
▸ equalsZ(other
: GeoPoint): boolean
是否相等(判断z).
# Parameters
Name | Type |
---|---|
other | GeoPoint |
Returns: boolean
# lengthSq
▸ lengthSq(): number
Returns: number
# lerp
▸ lerp(v
: GeoPoint, alpha
: number): GeoPoint
# Parameters
Name | Type |
---|---|
v | GeoPoint |
alpha | number |
Returns: GeoPoint
# mag
▸ mag(): number
长度.
Returns: number
# matMult
▸ matMult(m
: number[]): GeoPoint
乘一个矩阵.
# Parameters
Name | Type | Description |
---|---|---|
m | number[] | 矩阵值. |
Returns: GeoPoint
# mult
▸ mult(k
: number): GeoPoint
乘一个系数.
# Parameters
Name | Type | Description |
---|---|---|
k | number | 系数. |
Returns: GeoPoint
# multByPoint
▸ multByPoint(p
: GeoPoint): GeoPoint
两个点相乘.
# Parameters
Name | Type | Description |
---|---|---|
p | GeoPoint | 要相乘的点. |
Returns: GeoPoint
# perp
▸ perp(): GeoPoint
投影 [x,y] = [-y, x].
Returns: GeoPoint
# roateAround
▸ roateAround(angle
: number, p
: GeoPoint): GeoPoint
绕一个点旋转.
# Parameters
Name | Type | Description |
---|---|---|
angle | number | 弧度. |
p | GeoPoint | 围绕的点. |
Returns: GeoPoint
# rotate
▸ rotate(angle
: number): GeoPoint
旋转.
# Parameters
Name | Type | Description |
---|---|---|
angle | number | 弧度. |
Returns: GeoPoint
# round
▸ round(fixed?
: number): GeoPoint
后小数点几位取整
# Parameters
Name | Type | Default value |
---|---|---|
fixed | number | 6 |
Returns: GeoPoint
# roundInt
▸ roundInt(): GeoPoint
四舍五入取整.
Returns: GeoPoint
# roundStr
▸ roundStr(fixed?
: number): string
# Parameters
Name | Type | Default value |
---|---|---|
fixed | number | 6 |
Returns: string
# sub
两个点相减.
# Parameters
Name | Type | Description |
---|---|---|
p | GeoPoint | 要相减的点. |
Returns: GeoPoint
# toArray
▸ toArray(): number[]
返回数组
Returns: number[]
The coordinates represeted as an array of x and y.
var ll = new vjmap.GeoPoint(-73.9749, 40.7736);
ll.toArray(); // = [-73.9749, 40.7736]
2
# toString
▸ toString(fixed?
: number): string
返回字符串.
# Parameters
Name | Type | Default value |
---|---|---|
fixed | number | 6 |
Returns: string
The coordinates represented as a string of the format 'x, y, z?'
.
var ll = new vjmap.GeoPoint(-73.9749, 40.7736);
ll.toString(); // = "GeoPoint(-73.9749, 40.7736)"
2
# transform
▸ transform(basePt
: GeoPoint, destPt
: GeoPoint, scale?
: number, angle?
: number): GeoPoint
对一个点围绕一个基点进行缩放旋转平移操作.
# Parameters
Name | Type | Description |
---|---|---|
basePt | GeoPoint | 围绕的基点坐标 |
destPt | GeoPoint | 要平移至的目的地坐标 |
scale? | number | 缩放比例,默认1.0 |
angle? | number | 旋转角度,逆时针,默认0 |
Returns: GeoPoint
# unit
▸ unit(): GeoPoint
单位长度.
Returns: GeoPoint
# convert
▸ Static
convert(input
: GeoPointLike): GeoPoint
根据不同的类型创建地理坐标 GeoPoint .
Example:
const p1 = GeoPoint.convert(new GeoPoint(x, y, z));
const p2 = GeoPoint.convert([x, y]);
const p3 = GeoPoint.convert([x, y, z]);
const p4 = GeoPoint.convert(lng: -73.9749, lat: 40.7736});
const p5 = GeoPoint.convert(lon: -73.9749, lat: 40.7736});
2
3
4
5
# Parameters
Name | Type | Description |
---|---|---|
input | GeoPointLike | Either GeoPointLike, GeoPointLike or GeoPointLike object literal. |
Returns: GeoPoint
# fromString
▸ Static
fromString(input
: string): GeoPoint
根据字符串创建 GeoPoint
.
Example:
const b = GeoPoint.fromString("1,2");
# Parameters
Name | Type |
---|---|
input | string |
Returns: GeoPoint