Appearance
super-tools-lib - v1.74.0 / Modules / math
Module: math
Table of contents
Functions
Functions
degsToRads
▸ degsToRads(deg
): number
将角度转换为弧度
Since
1.62.0
Example
ts
import { degsToRads } from 'super-tools-lib'
degsToRads(90) // 1.5707963267948966
Parameters
Name | Type | Description |
---|---|---|
deg | number | 角度 |
Returns
number
返回角度转换后的弧度
disLonlat
▸ disLonlat(start
, end
): number
计算两个经纬度坐标的距离
Since
1.62.0
Example
ts
import { disLonlat } from 'super-tools-lib'
disLonlat({lon: 116.445088, lat: 39.94614}, {lon: 116.145088, lat: 39.94614}) // 25574.209968296687
Parameters
Name | Type | Description |
---|---|---|
start | Object | 经纬度坐标 |
start.lat | number | - |
start.lon | number | - |
end | Object | 经纬度坐标 |
end.lat | number | - |
end.lon | number | - |
Returns
number
返回两个点的距离,单位为米
disMercator
▸ disMercator(start
, end
): number
计算墨卡托两点之间的距离
Since
1.62.0
Example
ts
import { disMercator } from 'super-tools-lib'
disMercator({
x: 12601590.934991667,
y: 2507144.4488188336,
},
{
x: 12603303.603016667,
y: 2506982.020053167,
}) // 1720.353122987682
Parameters
Name | Type |
---|---|
start | Object |
start.x | number |
start.y | number |
end | Object |
end.x | number |
end.y | number |
Returns
number
返回亮点直接的距离 m
getPolygonCenter
▸ getPolygonCenter<T
>(points
): Object
获取多边形中心点
Since
1.62.0
Example
ts
import { getPolygonCenter } from 'super-tools-lib'
getPolygonCenter([
{
"x": 11791461.222580431,
"y": 3418824.913886976
},
{
"x": 11791521.222580431,
"y": 3418824.913886976
},
{
"x": 11791521.222580431,
"y": 3418789.913886976
},
{
"x": 11791461.222580431,
"y": 3418789.913886976
}
]) // {"x": 11791491.222580431,"y": 3418807.413886976 }
Type parameters
Name | Type |
---|---|
T | extends Object |
Parameters
Name | Type | Description |
---|---|---|
points | T [] | 多边形点集合 |
Returns
Object
返回多边形中心点
Name | Type |
---|---|
x | number |
y | number |
lonLatToMercator
▸ lonLatToMercator(lonLat
): Object
经纬度坐标转墨卡托坐标
Since
1.62.0
Example
ts
import { lonLatToMercator } from 'super-tools-lib'
lonLatToMercator({ lon: 116.445088, lat: 39.94614 })
// => {x: 12962607.899733523, y: 4858118.574453057}
Parameters
Name | Type | Description |
---|---|---|
lonLat | Object | |
lonLat.lat | number | 纬度 |
lonLat.lon | number | 经度 |
Returns
Object
返回墨卡托坐标
Name | Type |
---|---|
x | number |
y | number |
mercatorToLonlat
▸ mercatorToLonlat(mercator
): Object
墨卡托坐标转经纬度坐标
Since
1.62.0
Example
ts
import { mercatorToLonlat } from 'super-tools-lib'
mercatorToLonlat({x: 12962607.899733523, y: 4858118.574453057})
// => { lon: 116.445088, lat: 39.94614 }
Parameters
Name | Type | Description |
---|---|---|
mercator | Object | |
mercator.x | number | x |
mercator.y | number | y |
Returns
Object
返回经纬度坐标
Name | Type |
---|---|
lat | number |
lon | number |
scalePolygon
▸ scalePolygon<T
>(points
, extra
): T
[]
缩放多边形坐标
Since
1.62.0
Example
ts
import { scalePolygon } from 'super-tools-lib'
scalePolygon([
{
x: 11791461.222580431,
y: 3418824.913886976,
},
{
x: 11791521.222580431,
y: 3418824.913886976,
},
{
x: 11791521.222580431,
y: 3418789.913886976,
},
{
x: 11791461.222580431,
y: 3418789.913886976,
},
], 5)
// => [
{
"x": 11791456.222580431,
"y": 3418829.913886976
},
{
"x": 11791526.222580431,
"y": 3418829.913886976
},
{
"x": 11791526.222580431,
"y": 3418784.913886976
},
{
"x": 11791456.222580431,
"y": 3418784.913886976
}
]
Type parameters
Name | Type |
---|---|
T | extends Object |
Parameters
Name | Type | Description |
---|---|---|
points | T [] | 多边形点集合 |
extra | number | 缩放值 |
Returns
T
[]
返回缩放后多边形点集合