Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -301,21 +301,25 @@ public void setRoute(DirectionsRoute route) {
*/
private void calculateStepPoints() {
LineString line = LineString.fromPolyline(
route.getLegs().get(currentLeg)
.getSteps().get(currentStep).getGeometry(), Constants.PRECISION_6);
route.getLegs().get(currentLeg).getSteps().get(currentStep).getGeometry(), Constants.PRECISION_6);

if (currentStep < route.getLegs().get(currentLeg).getSteps().size() - 1) {
currentStep++;
} else if (currentLeg < route.getLegs().size() - 1) {
currentLeg++;
}
increaseIndex();

sliceRoute(line, distance);
if (noisyGps) {
addNoiseToRoute(distance);
}
}

private void increaseIndex() {
if (currentStep < route.getLegs().get(currentLeg).getSteps().size() - 1) {
currentStep++;
} else if (currentLeg < route.getLegs().size() - 1) {
currentLeg++;
currentStep = 0;
}
}

/**
* Here we build the new mock {@link Location} object and fill in as much information we can calculate.
*
Expand Down Expand Up @@ -353,7 +357,9 @@ private Location mockLocation(Position position) {
private class LocationUpdateRunnable implements Runnable {
@Override
public void run() {
if (positions.size() <= 5) {
// Calculate the next steps points if the list becomes empty
// so that the mock location continues along the route
if (positions.size() <= 0) {
calculateStepPoints();
}

Expand Down