How to use the geolib/es/getPreciseDistance function in geolib

To help you get started, we’ve selected a few geolib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jimmykane / quantified-self-lib / src / geodesy / adapters / geolib.adapter.ts View on Github external
getDistance(positionArray: DataPositionInterface[]): number {
    let distance = 0;
    const excludeFirstPointsArray = positionArray.slice(1);
    let firstPosition = positionArray[0];
    for (const nextPosition of excludeFirstPointsArray) {
      const firstPositionAsDecimal = {
        longitude: firstPosition.longitudeDegrees,
        latitude: firstPosition.latitudeDegrees,
      };
      const nextPositionAsDecimal = {
        longitude: nextPosition.longitudeDegrees,
        latitude: nextPosition.latitudeDegrees,
      };
      distance += getPreciseDistance(firstPositionAsDecimal, nextPositionAsDecimal);
      firstPosition = nextPosition;
    }
    return distance;
  }
}

geolib

Library to provide basic geospatial operations like distance calculation, conversion of decimal coordinates to sexagesimal and vice versa, etc. This library is currently **2D**, meaning that altitude/elevation is not yet supported by any of its functions!

MIT
Latest version published 2 years ago

Package Health Score

58 / 100
Full package analysis

Similar packages