count lines differenetly

This commit is contained in:
Victor Shcherb 2014-10-02 17:50:02 +02:00
parent e27a425465
commit 19ef80c33f

View file

@ -516,7 +516,7 @@ public class RouteResultPreparation {
kl = true; kl = true;
int lns = attached.getObject().getLanes(); int lns = attached.getObject().getLanes();
if(attached.getObject().getOneway() == 0) { if(attached.getObject().getOneway() == 0) {
lns = (lns + 1) / 2; lns = countLines(attached, lns);
} }
if (lns > 0) { if (lns > 0) {
right += lns; right += lns;
@ -526,7 +526,7 @@ public class RouteResultPreparation {
kr = true; kr = true;
int lns = attached.getObject().getLanes(); int lns = attached.getObject().getLanes();
if(attached.getObject().getOneway() == 0) { if(attached.getObject().getOneway() == 0) {
lns = (lns + 1) / 2; lns = countLines(attached, lns);
} }
if (lns > 0) { if (lns > 0) {
left += lns; left += lns;
@ -542,8 +542,9 @@ public class RouteResultPreparation {
right = 1; right = 1;
} }
int current = currentSegm.getObject().getLanes(); int current = currentSegm.getObject().getLanes();
if(currentSegm.getObject().getOneway() == 0) { // attachedRoutes covers all allowed outbound routes at that point except currentSegm.
current = (current + 1) / 2; if (currentSegm.getObject().getOneway() == 0) {
current = countLines(currentSegm, current);
} }
if (current <= 0) { if (current <= 0) {
current = 1; current = 1;
@ -580,6 +581,19 @@ public class RouteResultPreparation {
return t; return t;
} }
protected int countLines(RouteSegmentResult attached, int lns) {
try {
if (attached.isForwardDirection() && attached.getObject().getValue("lanes:forward") != null) {
return Integer.parseInt(attached.getObject().getValue("lanes:forward"));
} else if (!attached.isForwardDirection() && attached.getObject().getValue("lanes:backward") != null) {
return Integer.parseInt(attached.getObject().getValue("lanes:backward"));
}
} catch (NumberFormatException e) {
e.printStackTrace();
}
return (lns + 1) / 2;
}
private boolean isMotorway(RouteSegmentResult s){ private boolean isMotorway(RouteSegmentResult s){
String h = s.getObject().getHighway(); String h = s.getObject().getHighway();
return "motorway".equals(h) || "motorway_link".equals(h) || return "motorway".equals(h) || "motorway_link".equals(h) ||