Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2014-12-09 22:35:53 +01:00
commit 89e0b7670d
2 changed files with 33 additions and 0 deletions

View file

@ -850,6 +850,36 @@ public class RouteResultPreparation {
return calculateRawTurnLanes(splitLaneOptions, 0); return calculateRawTurnLanes(splitLaneOptions, 0);
} }
public static int[] parseLanes(RouteDataObject ro, double dirToNorthEastPi) {
int lns = 0;
try {
if (ro.getOneway() == 0) {
// we should get direction to detect forward or backward
double cmp = ro.directionRoute(0, true);
if(Math.abs(MapUtils.alignAngleDifference(dirToNorthEastPi -cmp)) < Math.PI / 2) {
if(ro.getValue("lanes:forward") != null) {
lns = Integer.parseInt(ro.getValue("lanes:forward"));
}
} else {
if(ro.getValue("lanes:backward") != null) {
lns = Integer.parseInt(ro.getValue("lanes:backward"));
}
}
if (lns == 0 && ro.getValue("lanes") != null) {
lns = Integer.parseInt(ro.getValue("lanes")) / 2;
}
} else {
lns = Integer.parseInt(ro.getValue("lanes"));
}
if(lns > 0 ) {
return new int[lns];
}
} catch (NumberFormatException e) {
}
return null;
}
private static int[] calculateRawTurnLanes(String[] splitLaneOptions, int calcTurnType) { private static int[] calculateRawTurnLanes(String[] splitLaneOptions, int calcTurnType) {
int[] lanes = new int[splitLaneOptions.length]; int[] lanes = new int[splitLaneOptions.length];
for (int i = 0; i < splitLaneOptions.length; i++) { for (int i = 0; i < splitLaneOptions.length; i++) {

View file

@ -614,6 +614,9 @@ public class RouteInfoWidgetsFactory {
if(ro != null) { if(ro != null) {
float degree = lp == null || !lp.hasBearing() ? 0 : lp.getBearing(); float degree = lp == null || !lp.hasBearing() ? 0 : lp.getBearing();
loclanes = RouteResultPreparation.parseTurnLanes(ro, degree / 180 * Math.PI); loclanes = RouteResultPreparation.parseTurnLanes(ro, degree / 180 * Math.PI);
if(loclanes == null) {
loclanes = RouteResultPreparation.parseLanes(ro, degree / 180 * Math.PI);
}
} }
} else if (rh != null && rh.isRouteCalculated() ) { } else if (rh != null && rh.isRouteCalculated() ) {
if (rh.isFollowingMode() && view.getSettings().SHOW_LANES.get()) { if (rh.isFollowingMode() && view.getSettings().SHOW_LANES.get()) {