Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
38c5763337
6 changed files with 82 additions and 55 deletions
|
@ -167,8 +167,11 @@ public class BinaryMapRouteReaderAdapter {
|
||||||
RouteTypeCondition cond = new RouteTypeCondition();
|
RouteTypeCondition cond = new RouteTypeCondition();
|
||||||
cond.floatValue = RouteDataObject.parseSpeed(c.substring(0, ch), 0);
|
cond.floatValue = RouteDataObject.parseSpeed(c.substring(0, ch), 0);
|
||||||
cond.condition = c.substring(ch + 1).trim();
|
cond.condition = c.substring(ch + 1).trim();
|
||||||
if (cond.condition.startsWith("(") && cond.condition.endsWith(")")) {
|
if (cond.condition.startsWith("(")) {
|
||||||
cond.condition = cond.condition.substring(1, cond.condition.length() - 1).trim();
|
cond.condition = cond.condition.substring(1, cond.condition.length()).trim();
|
||||||
|
}
|
||||||
|
if(cond.condition.endsWith(")")) {
|
||||||
|
cond.condition = cond.condition.substring(0, cond.condition.length() - 1).trim();
|
||||||
}
|
}
|
||||||
cond.hours = OpeningHoursParser.parseOpenedHours(cond.condition);
|
cond.hours = OpeningHoursParser.parseOpenedHours(cond.condition);
|
||||||
conditions.add(cond);
|
conditions.add(cond);
|
||||||
|
|
|
@ -409,34 +409,6 @@ public class RouteResultPreparation {
|
||||||
if (i == result.size() || result.get(i).getTurnType() != null) {
|
if (i == result.size() || result.get(i).getTurnType() != null) {
|
||||||
if (prevSegment >= 0) {
|
if (prevSegment >= 0) {
|
||||||
String turn = result.get(prevSegment).getTurnType().toString();
|
String turn = result.get(prevSegment).getTurnType().toString();
|
||||||
final int[] lns = result.get(prevSegment).getTurnType().getLanes();
|
|
||||||
if (lns != null) {
|
|
||||||
String s = "[ ";
|
|
||||||
for (int h = 0; h < lns.length; h++) {
|
|
||||||
if (h > 0) {
|
|
||||||
s += " | ";
|
|
||||||
}
|
|
||||||
if (lns[h] % 2 == 1) {
|
|
||||||
s += "+";
|
|
||||||
}
|
|
||||||
int pt = TurnType.getPrimaryTurn(lns[h]);
|
|
||||||
if (pt == 0) {
|
|
||||||
pt = 1;
|
|
||||||
}
|
|
||||||
s += TurnType.valueOf(pt, false).toXmlString();
|
|
||||||
int st = TurnType.getSecondaryTurn(lns[h]);
|
|
||||||
if (st != 0) {
|
|
||||||
s += "," + TurnType.valueOf(st, false).toXmlString();
|
|
||||||
}
|
|
||||||
int tt = TurnType.getTertiaryTurn(lns[h]);
|
|
||||||
if (tt != 0) {
|
|
||||||
s += "," + TurnType.valueOf(tt, false).toXmlString();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
s += "]";
|
|
||||||
turn += s;
|
|
||||||
}
|
|
||||||
result.get(prevSegment).setDescription(
|
result.get(prevSegment).setDescription(
|
||||||
turn + MessageFormat.format(" and go {0,number,#.##} meters", dist));
|
turn + MessageFormat.format(" and go {0,number,#.##} meters", dist));
|
||||||
if (result.get(prevSegment).getTurnType().isSkipToSpeak()) {
|
if (result.get(prevSegment).getTurnType().isSkipToSpeak()) {
|
||||||
|
@ -531,6 +503,7 @@ public class RouteResultPreparation {
|
||||||
}
|
}
|
||||||
if (dist < mergeDistance) {
|
if (dist < mergeDistance) {
|
||||||
mergeTurnLanes(leftside, currentSegment, nextSegment);
|
mergeTurnLanes(leftside, currentSegment, nextSegment);
|
||||||
|
inferCommonActiveLane(currentSegment.getTurnType(), nextSegment.getTurnType());
|
||||||
merged = true;
|
merged = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -626,7 +599,7 @@ public class RouteResultPreparation {
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
if (target.isActiveTurnMostLeft()) {
|
if (target.isActiveTurnMostLeft()) {
|
||||||
// let only the most left lanes be enabled
|
// let only the most left lanes be enabled
|
||||||
if (target.activeLen <= active.activeLen) {
|
if (target.activeLen < active.activeLen) {
|
||||||
active.activeEndIndex -= (active.activeLen - target.activeLen);
|
active.activeEndIndex -= (active.activeLen - target.activeLen);
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
@ -676,20 +649,35 @@ public class RouteResultPreparation {
|
||||||
}
|
}
|
||||||
TurnType currentTurn = currentSegment.getTurnType();
|
TurnType currentTurn = currentSegment.getTurnType();
|
||||||
currentTurn.setLanes(active.disabledLanes);
|
currentTurn.setLanes(active.disabledLanes);
|
||||||
inferCommonActiveLane(currentTurn);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void inferCommonActiveLane(TurnType currentTurn) {
|
private void inferCommonActiveLane(TurnType currentTurn, TurnType nextTurn) {
|
||||||
int[] lanes = currentTurn.getLanes();
|
int[] lanes = currentTurn.getLanes();
|
||||||
int singleTurn = 0;
|
TIntHashSet turnSet = new TIntHashSet();
|
||||||
for(int i = 0; i < lanes.length; i++) {
|
for(int i = 0; i < lanes.length; i++) {
|
||||||
if(lanes[i] % 2 == 1 && TurnType.getSecondaryTurn(lanes[i]) == 0) {
|
if(lanes[i] % 2 == 1 ) {
|
||||||
singleTurn = TurnType.getPrimaryTurn(lanes[i]);
|
int singleTurn = TurnType.getPrimaryTurn(lanes[i]);
|
||||||
break;
|
turnSet.add(singleTurn);
|
||||||
|
if(TurnType.getSecondaryTurn(lanes[i]) != 0) {
|
||||||
|
turnSet.add(TurnType.getSecondaryTurn(lanes[i]));
|
||||||
|
}
|
||||||
|
if(TurnType.getTertiaryTurn(lanes[i]) != 0) {
|
||||||
|
turnSet.add(TurnType.getTertiaryTurn(lanes[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(singleTurn == 0) {
|
}
|
||||||
|
int singleTurn ;
|
||||||
|
if(turnSet.size() == 1) {
|
||||||
|
singleTurn = turnSet.iterator().next();
|
||||||
|
} else if(currentTurn.goAhead() && nextTurn.goAhead()) {
|
||||||
|
singleTurn = currentTurn.getValue();
|
||||||
|
} else if(currentTurn.goAhead() && turnSet.contains(nextTurn.getValue()) &&
|
||||||
|
(currentTurn.isPossibleLeftTurn() && TurnType.isLeftTurn(nextTurn.getValue()) ) ||
|
||||||
|
(currentTurn.isPossibleRightTurn() && TurnType.isRightTurn(nextTurn.getValue()))
|
||||||
|
) {
|
||||||
|
singleTurn = nextTurn.getValue();
|
||||||
|
} else {
|
||||||
singleTurn = currentTurn.getValue();
|
singleTurn = currentTurn.getValue();
|
||||||
}
|
}
|
||||||
for(int i = 0; i < lanes.length; i++) {
|
for(int i = 0; i < lanes.length; i++) {
|
||||||
|
@ -700,6 +688,9 @@ public class RouteResultPreparation {
|
||||||
} else if(TurnType.getTertiaryTurn(lanes[i]) == singleTurn) {
|
} else if(TurnType.getTertiaryTurn(lanes[i]) == singleTurn) {
|
||||||
TurnType.setTertiaryTurn(lanes, i, TurnType.getPrimaryTurn(lanes[i]));
|
TurnType.setTertiaryTurn(lanes, i, TurnType.getPrimaryTurn(lanes[i]));
|
||||||
TurnType.setPrimaryTurn(lanes, i, singleTurn);
|
TurnType.setPrimaryTurn(lanes, i, singleTurn);
|
||||||
|
} else {
|
||||||
|
// disable lane
|
||||||
|
lanes[i] = lanes[i] - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -955,6 +946,8 @@ public class RouteResultPreparation {
|
||||||
} else {
|
} else {
|
||||||
boolean possiblyLeftTurn = rs.roadsOnLeft == 0;
|
boolean possiblyLeftTurn = rs.roadsOnLeft == 0;
|
||||||
boolean possiblyRightTurn = rs.roadsOnRight == 0;
|
boolean possiblyRightTurn = rs.roadsOnRight == 0;
|
||||||
|
t.setPossibleLeftTurn(possiblyLeftTurn);
|
||||||
|
t.setPossibleRightTurn(possiblyRightTurn);
|
||||||
for (int k = 0; k < rawLanes.length; k++) {
|
for (int k = 0; k < rawLanes.length; k++) {
|
||||||
int turn = TurnType.getPrimaryTurn(rawLanes[k]);
|
int turn = TurnType.getPrimaryTurn(rawLanes[k]);
|
||||||
int sturn = TurnType.getSecondaryTurn(rawLanes[k]);
|
int sturn = TurnType.getSecondaryTurn(rawLanes[k]);
|
||||||
|
@ -964,8 +957,10 @@ public class RouteResultPreparation {
|
||||||
// all undesired lanes will be disabled through the 2nd pass
|
// all undesired lanes will be disabled through the 2nd pass
|
||||||
if((TurnType.isRightTurn(sturn) && possiblyRightTurn) ||
|
if((TurnType.isRightTurn(sturn) && possiblyRightTurn) ||
|
||||||
(TurnType.isLeftTurn(sturn) && possiblyLeftTurn)) {
|
(TurnType.isLeftTurn(sturn) && possiblyLeftTurn)) {
|
||||||
TurnType.setPrimaryTurn(rawLanes, k, sturn);
|
// we can't predict here whether it will be a left turn or straight on,
|
||||||
TurnType.setSecondaryTurn(rawLanes, k, turn);
|
// it could be done during 2nd pass
|
||||||
|
// TurnType.setPrimaryTurn(rawLanes, k, sturn);
|
||||||
|
// TurnType.setSecondaryTurn(rawLanes, k, turn);
|
||||||
active = true;
|
active = true;
|
||||||
} else if((TurnType.isRightTurn(turn) && possiblyRightTurn) ||
|
} else if((TurnType.isRightTurn(turn) && possiblyRightTurn) ||
|
||||||
(TurnType.isLeftTurn(turn) && possiblyLeftTurn)) {
|
(TurnType.isLeftTurn(turn) && possiblyLeftTurn)) {
|
||||||
|
|
|
@ -117,6 +117,8 @@ public class TurnType {
|
||||||
private float turnAngle;
|
private float turnAngle;
|
||||||
private boolean skipToSpeak;
|
private boolean skipToSpeak;
|
||||||
private int[] lanes;
|
private int[] lanes;
|
||||||
|
private boolean possiblyLeftTurn;
|
||||||
|
private boolean possiblyRightTurn;
|
||||||
|
|
||||||
public static TurnType getExitTurn(int out, float angle, boolean leftSide) {
|
public static TurnType getExitTurn(int out, float angle, boolean leftSide) {
|
||||||
TurnType r = valueOf(RNDB, leftSide); //$NON-NLS-1$
|
TurnType r = valueOf(RNDB, leftSide); //$NON-NLS-1$
|
||||||
|
@ -248,6 +250,22 @@ public class TurnType {
|
||||||
return lanes;
|
return lanes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setPossibleLeftTurn(boolean possiblyLeftTurn) {
|
||||||
|
this.possiblyLeftTurn = possiblyLeftTurn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPossibleRightTurn(boolean possiblyRightTurn) {
|
||||||
|
this.possiblyRightTurn = possiblyRightTurn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPossibleLeftTurn() {
|
||||||
|
return possiblyLeftTurn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPossibleRightTurn() {
|
||||||
|
return possiblyRightTurn;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean keepLeft() {
|
public boolean keepLeft() {
|
||||||
return value == KL;
|
return value == KL;
|
||||||
}
|
}
|
||||||
|
@ -270,32 +288,39 @@ public class TurnType {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
String vl = null;
|
||||||
if (isRoundAbout()) {
|
if (isRoundAbout()) {
|
||||||
return "Take " + getExitOut() + " exit";
|
vl = "Take " + getExitOut() + " exit";
|
||||||
} else if (value == C) {
|
} else if (value == C) {
|
||||||
return "Go ahead";
|
vl = "Go ahead";
|
||||||
} else if (value == TSLL) {
|
} else if (value == TSLL) {
|
||||||
return "Turn slightly left";
|
vl = "Turn slightly left";
|
||||||
} else if (value == TL) {
|
} else if (value == TL) {
|
||||||
return "Turn left";
|
vl = "Turn left";
|
||||||
} else if (value == TSHL) {
|
} else if (value == TSHL) {
|
||||||
return "Turn sharply left";
|
vl = "Turn sharply left";
|
||||||
} else if (value == TSLR) {
|
} else if (value == TSLR) {
|
||||||
return "Turn slightly right";
|
vl = "Turn slightly right";
|
||||||
} else if (value == TR) {
|
} else if (value == TR) {
|
||||||
return "Turn right";
|
vl = "Turn right";
|
||||||
} else if (value == TSHR) {
|
} else if (value == TSHR) {
|
||||||
return "Turn sharply right";
|
vl = "Turn sharply right";
|
||||||
} else if (value == TU) {
|
} else if (value == TU) {
|
||||||
return "Make uturn";
|
vl = "Make uturn";
|
||||||
} else if (value == TRU) {
|
} else if (value == TRU) {
|
||||||
return "Make uturn";
|
vl = "Make uturn";
|
||||||
} else if (value == KL) {
|
} else if (value == KL) {
|
||||||
return "Keep left";
|
vl = "Keep left";
|
||||||
} else if (value == KR) {
|
} else if (value == KR) {
|
||||||
return "Keep right";
|
vl = "Keep right";
|
||||||
} else if (value == OFFR) {
|
} else if (value == OFFR) {
|
||||||
return "Off route";
|
vl = "Off route";
|
||||||
|
}
|
||||||
|
if(vl != null) {
|
||||||
|
if(lanes != null) {
|
||||||
|
vl += "(" + toString(lanes) +")";
|
||||||
|
}
|
||||||
|
return vl;
|
||||||
}
|
}
|
||||||
return super.toString();
|
return super.toString();
|
||||||
}
|
}
|
||||||
|
@ -364,4 +389,5 @@ public class TurnType {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -965,12 +965,15 @@ public class OpeningHoursParser {
|
||||||
|
|
||||||
public static OpeningHoursParser.OpeningHoursRule parseRuleV2(String r) {
|
public static OpeningHoursParser.OpeningHoursRule parseRuleV2(String r) {
|
||||||
r = r.toLowerCase();
|
r = r.toLowerCase();
|
||||||
|
|
||||||
final String[] daysStr = new String[]{"mo", "tu", "we", "th", "fr", "sa", "su"};
|
final String[] daysStr = new String[]{"mo", "tu", "we", "th", "fr", "sa", "su"};
|
||||||
final String[] monthsStr = new String[]{"jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"};
|
final String[] monthsStr = new String[]{"jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"};
|
||||||
final String[] holidayStr = new String[]{"ph", "sh", "easter"};
|
final String[] holidayStr = new String[]{"ph", "sh", "easter"};
|
||||||
String sunrise = "07:00";
|
String sunrise = "07:00";
|
||||||
String sunset = "21:00";
|
String sunset = "21:00";
|
||||||
String endOfDay = "24:00";
|
String endOfDay = "24:00";
|
||||||
|
r = r.replace('(', ' '); // avoid "(mo-su 17:00-20:00"
|
||||||
|
r = r.replace(')', ' ');
|
||||||
String localRuleString = r.replaceAll("sunset", sunset).replaceAll("sunrise", sunrise)
|
String localRuleString = r.replaceAll("sunset", sunset).replaceAll("sunrise", sunrise)
|
||||||
.replaceAll("\\+", "-" + endOfDay);
|
.replaceAll("\\+", "-" + endOfDay);
|
||||||
BasicOpeningHourRule basic = new BasicOpeningHourRule();
|
BasicOpeningHourRule basic = new BasicOpeningHourRule();
|
||||||
|
|
|
@ -103,7 +103,7 @@ public class RouteResultPreparationTest {
|
||||||
if(!Algorithms.objectEquals(expectedResult, turnLanes) &&
|
if(!Algorithms.objectEquals(expectedResult, turnLanes) &&
|
||||||
!Algorithms.objectEquals(expectedResult, lanes) &&
|
!Algorithms.objectEquals(expectedResult, lanes) &&
|
||||||
!Algorithms.objectEquals(expectedResult, turn)) {
|
!Algorithms.objectEquals(expectedResult, turn)) {
|
||||||
Assert.assertEquals("Segment " + segmentId, expectedResult, turnLanes);
|
Assert.assertEquals("Segment " + segmentId, turnLanes, expectedResult);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue