Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
points.forEach((point, index) => {
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));
}
}
}
});
if (this.state.latitudeDestination !== LATITUDE_DEST1) {
this.setState({
latitudeDestination: LATITUDE_DEST1,
longitudeDestination: LONGITUDE_DEST1
})
}
else {
this.setState({
latitudeDestination: LATITUDE_DEST2,
longitudeDestination: LONGITUDE_DEST2
})
}
let bearing = geolib.getBearing(
{latitude: LATITUDE, longitude: LONGITUDE},
{latitude: this.state.latitudeDestination, longitude: this.state.longitudeDestination}
);
this.animate();
return bearing;
}
parseStep(step, nextStep) {
const bearing = GeoLib.getBearing(toCoordinate(step.start_location), toCoordinate(nextStep ? nextStep.start_location : step.end_location));
return {
compass: this.decodeCompass(bearing),
maneuver: this.decodeManeuver(step, bearing),
bearing: bearing,
mode: step.travel_mode,
start: toCoordinate(step.start_location),
end: toCoordinate(step.end_location),
polyline: {
coordinates: this.decodePolylineToCoordinates(step.polyline.points),
type: PolylineTypes.ROUTE,
},
duration: step.duration,
distance: step.distance,
instructions: step.html_instructions,
}
if (this.state.latitudeDestination !== LATITUDE_DEST1) {
this.setState({
latitudeDestination: LATITUDE_DEST1,
longitudeDestination: LONGITUDE_DEST1
})
}
else {
this.setState({
latitudeDestination: LATITUDE_DEST2,
longitudeDestination: LONGITUDE_DEST2
})
}
let bearing = geolib.getBearing(
{latitude: LATITUDE, longitude: LONGITUDE},
{latitude: this.state.latitudeDestination, longitude: this.state.longitudeDestination}
);
this.animate();
return bearing;
}