Fix lots of unnecessary Keep left and keep right

This commit is contained in:
Victor Shcherb 2012-09-06 11:54:51 +02:00
parent df33571d12
commit 6ffaaa8bec
2 changed files with 38 additions and 20 deletions

View file

@ -231,7 +231,17 @@ public class RouteDataObject {
py = getPoint31YTile(nx);
// translate into meters
total += Math.abs(px - x) * 0.011d + Math.abs(py - y) * 0.01863d;
} while (total < 70);
// Victor : the problem to put more than 5 meters that BinaryRoutePlanner will treat
// 2 consequent Turn Right as UT and here 2 points will have same turn angle
// So it should be fix in both places
} while (total < 5);
return -Math.atan2( x - px, y - py );
}
@Override
public String toString() {
String name = getName();
String rf = getRef();
return String.format("Road id %s name %s ref %s", getId()+"", name == null ? "" : name, rf == null ? "" : rf);
}
}

View file

@ -982,12 +982,16 @@ public class BinaryRoutePlanner {
}
}
private boolean highwayLowEnd(String highway) {
if (highway == null || highway.endsWith("_link") || highway.endsWith("services") || highway.endsWith("service")
|| highway.endsWith("unclassified") || highway.endsWith("road")) {
return true;
private static final int MAX_SPEAK_PRIORITY = 5;
private int highwaySpeakPriority(String highway) {
if(highway == null || highway.endsWith("track") || highway.endsWith("services") || highway.endsWith("service")
|| highway.endsWith("path")) {
return MAX_SPEAK_PRIORITY;
}
return false;
if (highway.endsWith("_link") || highway.endsWith("unclassified") || highway.endsWith("road") ) {
return 1;
}
return 0;
}
@ -1078,25 +1082,29 @@ public class BinaryRoutePlanner {
int ls = prev.getObject().getLanes();
int left = 0;
int right = 0;
boolean speak = highwayLowEnd(prev.getObject().getHighway()) || highwayLowEnd(rr.getObject().getHighway());
boolean speak = false;
int speakPriority = Math.max(highwaySpeakPriority(prev.getObject().getHighway()), highwaySpeakPriority(rr.getObject().getHighway()));
if (attachedRoutes != null) {
for (RouteSegmentResult rs : attachedRoutes) {
double ex = MapUtils.degreesDiff(rs.getBearingBegin(), rr.getBearingBegin());
double mpi = Math.abs(MapUtils.degreesDiff(prev.getBearingEnd(), rs.getBearingBegin()));
if ((ex < TURN_DEGREE_MIN || mpi < TURN_DEGREE_MIN) && ex >= 0) {
kl = true;
int lns = rs.getObject().getLanes();
if (lns > 0) {
right += lns;
int rsSpeakPriority = highwaySpeakPriority(rs.getObject().getHighway());
if (rsSpeakPriority != MAX_SPEAK_PRIORITY || speakPriority == MAX_SPEAK_PRIORITY) {
if ((ex < TURN_DEGREE_MIN || mpi < TURN_DEGREE_MIN) && ex >= 0) {
kl = true;
int lns = rs.getObject().getLanes();
if (lns > 0) {
right += lns;
}
speak = speak || rsSpeakPriority <= speakPriority;
} else if ((ex > -TURN_DEGREE_MIN || mpi < TURN_DEGREE_MIN) && ex <= 0) {
kr = true;
int lns = rs.getObject().getLanes();
if (lns > 0) {
left += lns;
}
speak = speak || rsSpeakPriority <= speakPriority;
}
speak = speak || !highwayLowEnd(rs.getObject().getHighway());
} else if ((ex > -TURN_DEGREE_MIN || mpi < TURN_DEGREE_MIN) && ex <= 0) {
kr = true;
int lns = rs.getObject().getLanes();
if (lns > 0) {
left += lns;
}
speak = speak || !highwayLowEnd(rs.getObject().getHighway());
}
}
}