Add vehicle angle
This commit is contained in:
parent
1b837272ae
commit
d13a9ea3d7
|
@ -251,8 +251,7 @@ const createMap = target =>
|
||||||
const color = network.lines[course.line].color;
|
const color = network.lines[course.line].color;
|
||||||
const style = getCourseStyle(color);
|
const style = getCourseStyle(color);
|
||||||
|
|
||||||
style.getImage().setRotation(rotation * Math.PI / 16);
|
style.getImage().setRotation(course.angle);
|
||||||
rotation += 1;
|
|
||||||
ctx.setStyle(style);
|
ctx.setStyle(style);
|
||||||
|
|
||||||
const point = new Point(course.position);
|
const point = new Point(course.position);
|
||||||
|
|
|
@ -128,6 +128,8 @@ const updateFromTam = async (courses) =>
|
||||||
id,
|
id,
|
||||||
line: course.line,
|
line: course.line,
|
||||||
finalStop: course.finalStop,
|
finalStop: course.finalStop,
|
||||||
|
position: [0, 0],
|
||||||
|
angle: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
arriveAtStop(courses[id], nextStop);
|
arriveAtStop(courses[id], nextStop);
|
||||||
|
@ -210,11 +212,17 @@ const updatePositions = (courses, time) =>
|
||||||
t * nextPoint[0] + (1 - t) * previousPoint[0],
|
t * nextPoint[0] + (1 - t) * previousPoint[0],
|
||||||
t * nextPoint[1] + (1 - t) * previousPoint[1],
|
t * nextPoint[1] + (1 - t) * previousPoint[1],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
course.angle = Math.atan2(
|
||||||
|
previousPoint[1] - nextPoint[1],
|
||||||
|
nextPoint[0] - previousPoint[0],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const currentNode = network.stops[course.currentStop];
|
const currentNode = network.stops[course.currentStop];
|
||||||
|
|
||||||
course.position = turf.toMercator([
|
course.position = turf.toMercator([
|
||||||
currentNode.lon,
|
currentNode.lon,
|
||||||
currentNode.lat
|
currentNode.lat
|
||||||
|
|
Loading…
Reference in New Issue