| 1234567891011121314151617181920212223242526272829 |
- import { Pos, Pos3D } from "@/sdk";
- export const calcLatLonsDis = (point1: Pos, point2: Pos) => {
- const lat1 = point1.y;
- const lat2 = point2.y;
- const lng1 = point1.x;
- const lng2 = point2.x;
- var radLat1 = (lat1 * Math.PI) / 180.0;
- var radLat2 = (lat2 * Math.PI) / 180.0;
- var a = radLat1 - radLat2;
- var b = (lng1 * Math.PI) / 180.0 - (lng2 * Math.PI) / 180.0;
- var 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 = s * 6378.137; // EARTH_RADIUS;
- return s * 1000;
- };
- export const calcLintDis = (point1: Pos | Pos3D, point2: Pos | Pos3D) => {
- const xf = Math.pow(point1.x - point2.x, 2);
- const yf = Math.pow(point1.y - point2.y, 2);
- let sqDis = xf + yf;
- return Math.sqrt(sqDis);
- };
|