Skip to content
On this page

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

NameTypeDescription
degnumber角度

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

NameTypeDescription
startObject经纬度坐标
start.latnumber-
start.lonnumber-
endObject经纬度坐标
end.latnumber-
end.lonnumber-

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

NameType
startObject
start.xnumber
start.ynumber
endObject
end.xnumber
end.ynumber

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

NameType
Textends Object

Parameters

NameTypeDescription
pointsT[]多边形点集合

Returns

Object

返回多边形中心点

NameType
xnumber
ynumber

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

NameTypeDescription
lonLatObject
lonLat.latnumber纬度
lonLat.lonnumber经度

Returns

Object

返回墨卡托坐标

NameType
xnumber
ynumber

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

NameTypeDescription
mercatorObject
mercator.xnumberx
mercator.ynumbery

Returns

Object

返回经纬度坐标

NameType
latnumber
lonnumber

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

NameType
Textends Object

Parameters

NameTypeDescription
pointsT[]多边形点集合
extranumber缩放值

Returns

T[]

返回缩放后多边形点集合