Update action arrows

This commit is contained in:
Victor Shcherb 2015-06-19 09:19:15 +02:00
parent 4335926c8b
commit 9d4923cc2e

View file

@ -375,7 +375,7 @@ public class RouteLayer extends OsmandMapLayer {
double actionDist = 0; double actionDist = 0;
Location previousAction = null; Location previousAction = null;
actionPoints.clear(); actionPoints.clear();
int prevPoint = -2; int prevFinishPoint = -2;
for (int i = 0; i < routeNodes.size(); i++) { for (int i = 0; i < routeNodes.size(); i++) {
Location ls = routeNodes.get(i); Location ls = routeNodes.get(i);
if(nf != null) { if(nf != null) {
@ -400,12 +400,12 @@ public class RouteLayer extends OsmandMapLayer {
&& ls.getLatitude() <= topLatitude; && ls.getLatitude() <= topLatitude;
if(!action) { if(!action) {
if(previousAction != null) { if(previousAction != null) {
float loc = ls.distanceTo(previousAction); float dist = ls.distanceTo(previousAction);
actionDist += loc; actionDist += dist;
if(actionDist >= DISTANCE_ACTION) { if(actionDist >= DISTANCE_ACTION) {
actionPoints.add(calculateProjection(1 - (actionDist - DISTANCE_ACTION) / loc, previousAction, ls)); actionPoints.add(calculateProjection(1 - (actionDist - DISTANCE_ACTION) / dist, previousAction, ls));
prevPoint = i;
actionPoints.add(null); actionPoints.add(null);
prevFinishPoint = i;
previousAction = null; previousAction = null;
actionDist = 0; actionDist = 0;
} else { } else {
@ -416,38 +416,45 @@ public class RouteLayer extends OsmandMapLayer {
} else { } else {
// action point // action point
if(visible) { if(visible) {
int ind = actionPoints.size(); // visible action point
actionPoints.add(ls);
if (previousAction == null) { if (previousAction == null) {
Location lp = ls; // put some points in front
int ind = actionPoints.size();
Location lprevious = ls;
double dist = 0; double dist = 0;
for (int k = i - 1; k >= -1; k--) { for (int k = i - 1; k >= -1; k--) {
Location l = k == -1 ? lastProjection : routeNodes.get(k); Location l = k == -1 ? lastProjection : routeNodes.get(k);
float loc = lp.distanceTo(l); float loc = lprevious.distanceTo(l);
if(prevFinishPoint == k) {
if(ind >= 2) {
actionPoints.remove(ind - 2);
actionPoints.remove(ind - 2);
}
prevFinishPoint = -2;
break;
}
dist += loc; dist += loc;
if (dist >= DISTANCE_ACTION) { if (dist >= DISTANCE_ACTION) {
if(loc > 1) { if(loc > 1) {
actionPoints.add(ind, calculateProjection(1 - (dist - DISTANCE_ACTION) / loc, lp, l)); actionPoints.add(ind, calculateProjection(1 - (dist - DISTANCE_ACTION) / loc, lprevious, l));
} }
break; break;
} else { } else {
if(prevPoint == k) {
actionPoints.remove(actionPoints.size() - 1);
actionPoints.remove(actionPoints.size() - 1);
prevPoint = -2;
ind = actionPoints.size();
}
actionPoints.add(ind, l); actionPoints.add(ind, l);
lp = l; lprevious = l;
} }
} }
} }
actionPoints.add(ls);
previousAction = ls; previousAction = ls;
actionDist = 0; actionDist = 0;
} }
} }
} }
if(previousAction != null) {
actionPoints.add(null);
}
} }
private Location calculateProjection(double part, Location lp, Location l) { private Location calculateProjection(double part, Location lp, Location l) {