JSPM

gps-distance-es

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3
  • Score
    100M100P100Q37796F
  • License MIT

Typescript refactoring version of gps-distance

Package Exports

  • gps-distance-es
  • gps-distance-es/lib/gps-distance-es.cjs.js
  • gps-distance-es/lib/gps-distance-es.esm.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (gps-distance-es) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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

注意

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