How to use the geolib.computeDestinationPoint 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 flyandi / react-native-maps-navigation / src / modules / Tools.js View on Github external
const d2r = Math.PI / 180;   // degrees to radians
    const r2d = 180 / Math.PI;   // radians to degrees
    const points = 32;
    let result = [];

    // find the radius in lat/lon
    //const rlat = (radius / EARTH_RADIUS_METERS) * r2d;
    //const rlng = rlat / Math.cos({coordinate.latitude * d2r);

    if (initialBearing > finalBearing) finalBearing += 360;
    let deltaBearing = finalBearing - initialBearing;
    deltaBearing = deltaBearing/points;

    for (let i=0; (i < points+1); i++)
    {
        result.push(geolib.computeDestinationPoint(coordinate, radius, initialBearing + i*deltaBearing));
    }

    return result;
};
github vokkim / tuktuk-chart-plotter / src / client / map.js View on Github external
function calculateExtensionLine(position, course, speed, extensionLineSetting) {
  if (extensionLineSetting === EXTENSION_LINE_OFF) {
    return undefined
  }
  const time = 60 * parseInt(extensionLineSetting)
  if (position && position.latitude && position.longitude && course && speed > 0.5) {
    const distance = speed * time // Speed in m/s
    const start = [position.latitude, position.longitude]
    const destination = computeDestinationPoint(
      {lat: position.latitude, lon: position.longitude},
      distance,
      toDegrees(course)
    )
    const middle = computeDestinationPoint(
      {lat: position.latitude, lon: position.longitude},
      distance / 2,
      toDegrees(course)
    )
    return {
      start,
      middle: [middle.latitude, middle.longitude],
      end: [destination.latitude, destination.longitude]
    }
  }
  return undefined
}
github vokkim / tuktuk-chart-plotter / src / client / map.js View on Github external
function calculateExtensionLine(position, course, speed, extensionLineSetting) {
  if (extensionLineSetting === EXTENSION_LINE_OFF) {
    return undefined
  }
  const time = 60 * parseInt(extensionLineSetting)
  if (position && position.latitude && position.longitude && course && speed > 0.5) {
    const distance = speed * time // Speed in m/s
    const start = [position.latitude, position.longitude]
    const destination = computeDestinationPoint(
      {lat: position.latitude, lon: position.longitude},
      distance,
      toDegrees(course)
    )
    const middle = computeDestinationPoint(
      {lat: position.latitude, lon: position.longitude},
      distance / 2,
      toDegrees(course)
    )
    return {
      start,
      middle: [middle.latitude, middle.longitude],
      end: [destination.latitude, destination.longitude]
    }
  }
  return undefined
github flyandi / react-native-maps-navigation / src / modules / Simulator.js View on Github external
const nextPoint = points[index + 1];

            if(nextPoint && !nextPoint.final == true) {

                // calculate distance between each point
                const distance = Math.round(GeoLib.getDistance(point, nextPoint));
                const bearing =  GeoLib.getBearing(point, nextPoint);

                if(bearing !== 0) {

                    if (distance > 1) {

                        for (var x = 1; x < distance; x++) {

                            result.push(Object.assign({}, {bearing}, GeoLib.computeDestinationPoint(point, x, bearing)));
                        }

                    } else {
                        result.push(Object.assign({}, {bearing}, point));
                    }
                }
            }
        });

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 1 year ago

Package Health Score

62 / 100
Full package analysis