How to use the @turf/turf.destination function in @turf/turf

To help you get started, we’ve selected a few @turf/turf 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 uber / xviz / modules / builder / src / builders / helpers / xviz-trajectory-helper.js View on Github external
y: from.y || 0,
    z: from.z || 0,
    yaw: from.yaw || 0
  };

  to = {
    longitude: to.longitude || 0,
    latitude: to.latitude || 0,
    altitude: to.altitude || 0,
    x: to.x || 0,
    y: to.y || 0,
    z: to.z || 0,
    yaw: to.yaw || 0
  };

  const fromPoint = turf.destination(
    [from.longitude, from.latitude, from.altitude],
    Math.sqrt(from.x * from.x + from.y * from.y),
    Math.PI / 2 - from.yaw,
    {units: 'meters'}
  );

  const toPoint = turf.destination(
    [to.longitude, to.latitude, to.altitude],
    Math.sqrt(to.x * to.x + to.y * to.y),
    Math.PI / 2 - to.yaw,
    {units: 'meters'}
  );

  const distInMeters = turf.distance(fromPoint, toPoint, {units: 'meters'});

  // Bearing is degrees from north, positive is clockwise
github DoFabien / OsmGo / src / app / services / map.service.ts View on Github external
lng_min = coordinates[i][0];
      }
      if (!lng_max || coordinates[i][0] > lng_max) {
        lng_max = coordinates[i][0];
      }
      if (!lat_min || coordinates[i][1] < lat_min) {
        lat_min = coordinates[i][1];
      }
      if (!lat_max || coordinates[i][1] > lat_max) {
        lat_max = coordinates[i][1];
      }
    }

    const pointMin: Point = { 'type': 'Point', 'coordinates': [lng_min, lat_min] };
    const pointMax: Point = { 'type': 'Point', 'coordinates': [lng_max, lat_max] };
    const coordsMin = destination(pointMin, marginBuffer / 1000, -135).geometry.coordinates;
    const coordsMax = destination(pointMax, marginBuffer / 1000, 45).geometry.coordinates;
    const bbox: BBox = [coordsMin[0], coordsMin[1], coordsMax[0], coordsMax[1]]; // TODO : on est pas à 1m près
    return bbox;
  }
github uber / xviz / modules / builder / src / builders / helpers / xviz-trajectory-helper.js View on Github external
latitude: to.latitude || 0,
    altitude: to.altitude || 0,
    x: to.x || 0,
    y: to.y || 0,
    z: to.z || 0,
    yaw: to.yaw || 0
  };

  const fromPoint = turf.destination(
    [from.longitude, from.latitude, from.altitude],
    Math.sqrt(from.x * from.x + from.y * from.y),
    Math.PI / 2 - from.yaw,
    {units: 'meters'}
  );

  const toPoint = turf.destination(
    [to.longitude, to.latitude, to.altitude],
    Math.sqrt(to.x * to.x + to.y * to.y),
    Math.PI / 2 - to.yaw,
    {units: 'meters'}
  );

  const distInMeters = turf.distance(fromPoint, toPoint, {units: 'meters'});

  // Bearing is degrees from north, positive is clockwise
  const bearing = turf.bearing(fromPoint, toPoint);
  const bearingInRadians = turf.degreesToRadians(bearing);

  const diffZ = to.altitude + to.z - from.altitude - from.z;

  return [
    distInMeters * Math.sin(bearingInRadians),
github janhartmann / flight-spotter / client / src / flights / path-prediction.ts View on Github external
export const getFlightPathPrediction = (
  currentPosition: number[],
  velocity: number,
  duration: number,
  direction: number,
  steps: number
) => {
  const destination = turf.destination(
    currentPosition,
    velocity * duration,
    direction,
    {
      units: "meters"
    }
  );

  const route: GeoJSON.Feature = {
    type: "Feature",
    properties: {},
    geometry: {
      type: "LineString",
      coordinates: [currentPosition, destination.geometry.coordinates]
    }
  };