1.0.0 • Published 12 months ago

gps-distance-es v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

gps-distance-es

NPM

gps-distance的Typescript重构版

简体中文 | English

安装

npm install gps-distance-es

Examples

gps-distance-es 支持两种调用方式.如果是测量两点距离,可以用 (source_lat, source_lon, destination_lat, destination_lon)方式调用, 如果要计算多点组成的路径长度,则可以传入一个 [lat,lon] 格式的数组. 详见下方示例.

点对点

import distance from 'gps-distance-es';

// 计算两点距离:
const result = distance(45.527517, -122.718766, 45.373373, -121.693604);

// 81.78450202539503

坐标数组

import distance, { Point } from  'gps-distance-es';

// 计算多点路径的长度:
const path:Point[] = [
  [45.527517, -122.718766],
  [45.373373, -121.693604],
  [45.527517, -122.718766]
];
var result2 = distance(path);
// 163.56900405079006

注意

距离利用半正矢公式计算,返回单位为公里,所以计算结果仅为大致距离,不能代表精确距离

1.0.0

12 months ago

1.0.0-alpha.2

12 months ago

1.0.0-alpha.1

12 months ago