Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
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;
}
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),
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]
}
};