当前位置:网站首页>JS map two-point distance calculation
JS map two-point distance calculation
2022-07-18 18:58:00 【Stavin Li】
/** * Obtain the distance between two points through longitude and latitude * @param lat1lng1 * @param lat2lng2 * @returns Distance units km */
const getDistance = function (lat1, lng1, lat2, lng2) {
const radLat1 = (lat1 * Math.PI) / 180.0;
const radLat2 = (lat2 * Math.PI) / 180.0;
const a = radLat1 - radLat2;
const b = (lng1 * Math.PI) / 180.0 - (lng2 * Math.PI) / 180.0;
let s =
2 *
Math.asin(
Math.sqrt(
Math.pow(Math.sin(a / 2), 2) +
Math.cos(radLat1) *
Math.cos(radLat2) *
Math.pow(Math.sin(b / 2), 2)
)
);
s *= 6378.137; // EARTH_RADIUS;
s = Math.round(s * 100) / 100;
return s; // call return Distance in km
};
边栏推荐
- Excel finds characters from the right and intercepts them
- 函数模板的系列操作( 详解 )
- Use of thingjs
- 2022/7/14 每日一题(简单路径与树结合--->深搜)
- Importerror: DLL load failed: the specified module could not be found.
- 【C语言刷LeetCode】676. 实现一个魔法字典(M)
- Impala advanced settings of broadcast_ BYTES_ LIMIT
- STM32 key external interrupt control LED water light Hal Library
- STM32-中断优先级管理NVIC详解
- Flask response
猜你喜欢
随机推荐
Flask response
ospf路由管理
巴比特 | 元宇宙每日必读:半年诈骗2亿,数字人的最大“隐忧”,Deepfake骗局再次引爆互联网...
数据类型的转换
The principle and implementation of ring queue
IDEA 创建新分支,合并代码(其它->dev)
Learning path PHP -- post can't get the requested data
LeetCode高频题:三个长度为N的无序数组A,B,C,求 A[i] + B[j] + C[k] = 64 的(i , j, k )的组合总数量
STM32 key external interrupt control LED water light Hal Library
Decoding of relative motion of two moving points
《痞子衡嵌入式半月刊》 第 58 期
2022/7/15 每日一题(二分+dp+贪心思维)
自定义类型——结构体
图的广度优先遍历
模板与泛型编程之萃取-02-固定萃取技术之迭代器萃取范例
Can optical transceiver solves the long-distance networking problem of taihe'an tx3016c fire host
Microcomputer bus address, physical address, virtual address (detailed introduction)
ImportError: DLL load failed: 找不到指定的模块。
Use of thingjs
Importerror: DLL load failed: the specified module could not be found.









