Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2015-01-16 02:14:27 +01:00
commit 29f83a6f81
3 changed files with 90 additions and 39 deletions

View file

@ -60,13 +60,14 @@ public class BinaryInspector {
// test cases show info // test cases show info
if(args.length == 1 && "test".equals(args[0])) { if(args.length == 1 && "test".equals(args[0])) {
in.inspector(new String[]{ in.inspector(new String[]{
"-vpoi", // "-vpoi",
// "-vmap", "-vmapobjects", // "-vmap", "-vmapobjects",
// "-vrouting", // "-vrouting",
// "-vaddress", "-vcities", "-vstreets", "-vstreetgroups","-vbuildings", // "-vaddress", "-vcities","-vstreetgroups",
// "-vstreets", "-vbuildings", "-vintersections",
// "-zoom=16", // "-zoom=16",
// "-bbox=1.74,51.17,1.75,51.16", // "-bbox=1.74,51.17,1.75,51.16",
"/home/victor/projects/osmand/osm-gen/Map.obf" // "/home/victor/projects/osmand/osm-gen/Map.obf"
}); });
} else { } else {
in.inspector(args); in.inspector(args);
@ -566,7 +567,7 @@ public class BinaryInspector {
} }
println(":"); println(":");
for (City c : cities) { for (City c : cities) {
int size = index.preloadStreets(c, null); int size = index.preloadStreets(c, null);
List<Street> streets = new ArrayList<Street>(c.getStreets()); List<Street> streets = new ArrayList<Street>(c.getStreets());
print(MessageFormat.format("\t\t''{0}'' [{1,number,#}], {2,number,#} street(s) size {3,number,#} bytes", print(MessageFormat.format("\t\t''{0}'' [{1,number,#}], {2,number,#} street(s) size {3,number,#} bytes",

View file

@ -494,6 +494,33 @@ public class BinaryRoutePlanner {
} }
return directionAllowed; return directionAllowed;
} }
private boolean checkViaRestrictions(RouteSegment from, RouteSegment to) {
if(from != null && to != null) {
long fid = to.getRoad().getId();
for(int i = 0; i < from.getRoad().getRestrictionLength(); i++) {
long id = from.getRoad().getRestrictionId(i);
if(fid == id) {
int tp = from.getRoad().getRestrictionType(i);
if(tp == MapRenderingTypes.RESTRICTION_NO_LEFT_TURN ||
tp == MapRenderingTypes.RESTRICTION_NO_RIGHT_TURN ||
tp == MapRenderingTypes.RESTRICTION_NO_STRAIGHT_ON ||
tp == MapRenderingTypes.RESTRICTION_NO_U_TURN) {
return false;
}
break;
}
}
}
return true;
}
private RouteSegment getParentDiffId(RouteSegment s) {
while(s.getParentRoute() != null && s.getParentRoute().getRoad().getId() == s.getRoad().getId()) {
s = s.getParentRoute();
}
return s.getParentRoute();
}
private boolean checkIfOppositieSegmentWasVisited(final RoutingContext ctx, boolean reverseWaySearch, private boolean checkIfOppositieSegmentWasVisited(final RoutingContext ctx, boolean reverseWaySearch,
PriorityQueue<RouteSegment> graphSegments, RouteSegment segment, TLongObjectHashMap<RouteSegment> oppositeSegments, PriorityQueue<RouteSegment> graphSegments, RouteSegment segment, TLongObjectHashMap<RouteSegment> oppositeSegments,
@ -502,20 +529,24 @@ public class BinaryRoutePlanner {
long opp = calculateRoutePointId(road, segment.isPositive() ? segmentPoint - 1 : segmentPoint, !segment.isPositive()); long opp = calculateRoutePointId(road, segment.isPositive() ? segmentPoint - 1 : segmentPoint, !segment.isPositive());
if (oppositeSegments.containsKey(opp)) { if (oppositeSegments.containsKey(opp)) {
RouteSegment opposite = oppositeSegments.get(opp); RouteSegment opposite = oppositeSegments.get(opp);
FinalRouteSegment frs = new FinalRouteSegment(road, segmentPoint); RouteSegment to = reverseWaySearch ? getParentDiffId(segment) : getParentDiffId(opposite);
float distStartObstacles = segment.distanceFromStart RouteSegment from = !reverseWaySearch ? getParentDiffId(segment) : getParentDiffId(opposite);
+ calculateTimeWithObstacles(ctx, road, segmentDist, obstaclesTime); if (checkViaRestrictions(from, to)) {
frs.setParentRoute(segment); FinalRouteSegment frs = new FinalRouteSegment(road, segmentPoint);
frs.setParentSegmentEnd(segmentPoint); float distStartObstacles = segment.distanceFromStart
frs.reverseWaySearch = reverseWaySearch; + calculateTimeWithObstacles(ctx, road, segmentDist, obstaclesTime);
frs.distanceFromStart = opposite.distanceFromStart + distStartObstacles; frs.setParentRoute(segment);
frs.distanceToEnd = 0; frs.setParentSegmentEnd(segmentPoint);
frs.opposite = opposite; frs.reverseWaySearch = reverseWaySearch;
graphSegments.add(frs); frs.distanceFromStart = opposite.distanceFromStart + distStartObstacles;
if(TRACE_ROUTING){ frs.distanceToEnd = 0;
printRoad(" >> Final segment : ", frs, reverseWaySearch); frs.opposite = opposite;
graphSegments.add(frs);
if (TRACE_ROUTING) {
printRoad(" >> Final segment : ", frs, reverseWaySearch);
}
return true;
} }
return true;
} }
return false; return false;
} }
@ -554,17 +585,30 @@ public class BinaryRoutePlanner {
} }
private boolean proccessRestrictions(RoutingContext ctx, RouteDataObject road, RouteSegment inputNext, boolean reverseWay) { private boolean proccessRestrictions(RoutingContext ctx, RouteSegment segment, RouteSegment inputNext, boolean reverseWay) {
ctx.segmentsToVisitPrescripted.clear();
ctx.segmentsToVisitNotForbidden.clear();
boolean exclusiveRestriction = false;
RouteSegment next = inputNext;
if (!reverseWay && road.getRestrictionLength() == 0) {
return false;
}
if(!ctx.getRouter().restrictionsAware()) { if(!ctx.getRouter().restrictionsAware()) {
return false; return false;
} }
RouteDataObject road = segment.getRoad();
RouteSegment parent = getParentDiffId(segment);
if (!reverseWay && road.getRestrictionLength() == 0 &&
(parent == null || parent.getRoad().getRestrictionLength() == 0)) {
return false;
}
ctx.segmentsToVisitPrescripted.clear();
ctx.segmentsToVisitNotForbidden.clear();
processRestriction(ctx, inputNext, reverseWay, false, road);
if(parent != null) {
processRestriction(ctx, inputNext, reverseWay, true, parent.getRoad());
}
return true;
}
protected void processRestriction(RoutingContext ctx, RouteSegment inputNext, boolean reverseWay, boolean via,
RouteDataObject road) {
RouteSegment next = inputNext;
boolean exclusiveRestriction = false;
while (next != null) { while (next != null) {
int type = -1; int type = -1;
if (!reverseWay) { if (!reverseWay) {
@ -607,26 +651,32 @@ public class BinaryRoutePlanner {
} else if (type == MapRenderingTypes.RESTRICTION_NO_LEFT_TURN || type == MapRenderingTypes.RESTRICTION_NO_RIGHT_TURN } else if (type == MapRenderingTypes.RESTRICTION_NO_LEFT_TURN || type == MapRenderingTypes.RESTRICTION_NO_RIGHT_TURN
|| type == MapRenderingTypes.RESTRICTION_NO_STRAIGHT_ON || type == MapRenderingTypes.RESTRICTION_NO_U_TURN) { || type == MapRenderingTypes.RESTRICTION_NO_STRAIGHT_ON || type == MapRenderingTypes.RESTRICTION_NO_U_TURN) {
// next = next.next; continue; // next = next.next; continue;
if(via) {
ctx.segmentsToVisitPrescripted.remove(next);
}
} else if (type == -1) { } else if (type == -1) {
// case no restriction // case no restriction
ctx.segmentsToVisitNotForbidden.add(next); ctx.segmentsToVisitNotForbidden.add(next);
} else { } else {
// case exclusive restriction (only_right, only_straight, ...) if (!via) {
// 1. in case we are going backward we should not consider only_restriction // case exclusive restriction (only_right, only_straight, ...)
// as exclusive because we have many "in" roads and one "out" // 1. in case we are going backward we should not consider only_restriction
// 2. in case we are going forward we have one "in" and many "out" // as exclusive because we have many "in" roads and one "out"
if (!reverseWay) { // 2. in case we are going forward we have one "in" and many "out"
exclusiveRestriction = true; if (!reverseWay) {
ctx.segmentsToVisitNotForbidden.clear(); exclusiveRestriction = true;
ctx.segmentsToVisitPrescripted.add(next); ctx.segmentsToVisitNotForbidden.clear();
} else { ctx.segmentsToVisitPrescripted.add(next);
ctx.segmentsToVisitNotForbidden.add(next); } else {
ctx.segmentsToVisitNotForbidden.add(next);
}
} }
} }
next = next.next; next = next.next;
} }
ctx.segmentsToVisitPrescripted.addAll(ctx.segmentsToVisitNotForbidden); if(!via) {
return true; ctx.segmentsToVisitPrescripted.addAll(ctx.segmentsToVisitNotForbidden);
}
} }
@ -643,7 +693,7 @@ public class BinaryRoutePlanner {
if(inputNext != null && inputNext.getRoad().getId() == segment.getRoad().getId() && inputNext.next == null) { if(inputNext != null && inputNext.getRoad().getId() == segment.getRoad().getId() && inputNext.next == null) {
thereAreRestrictions = false; thereAreRestrictions = false;
} else { } else {
thereAreRestrictions = proccessRestrictions(ctx, segment.road, inputNext, reverseWaySearch); thereAreRestrictions = proccessRestrictions(ctx, segment, inputNext, reverseWaySearch);
if (thereAreRestrictions) { if (thereAreRestrictions) {
nextIterator = ctx.segmentsToVisitPrescripted.iterator(); nextIterator = ctx.segmentsToVisitPrescripted.iterator();
if (TRACE_ROUTING) { if (TRACE_ROUTING) {

View file

@ -793,7 +793,7 @@ public class RouteResultPreparation {
// sometimes slight right turn goes to the road with 2 lanes // sometimes slight right turn goes to the road with 2 lanes
// the better situation to group all the lanes and // the better situation to group all the lanes and
// when ';' we know for sure the lane combines 2 group // when ';' we know for sure the lane combines 2 group
roads -= 2; roads --;
} }
lanes -= cnt; lanes -= cnt;
// we already found slight turn others are turn in different direction // we already found slight turn others are turn in different direction