Fix critical bug with roundabout

This commit is contained in:
Victor Shcherb 2012-10-18 18:42:44 +02:00
parent 5808b7fd83
commit 06af098c61

View file

@ -284,7 +284,7 @@ public class RoutingContext {
for (RouteDataObject ro : routes) { for (RouteDataObject ro : routes) {
for (int i = 0; i < ro.pointsX.length; i++) { for (int i = 0; i < ro.pointsX.length; i++) {
if (ro.getPoint31XTile(i) == x31 && ro.getPoint31YTile(i) == y31) { if (ro.getPoint31XTile(i) == x31 && ro.getPoint31YTile(i) == y31) {
excludeDuplications.put(ro.id, ro); excludeDuplications.put(calcRouteId(ro, i), ro);
RouteSegment segment = new RouteSegment(ro, i); RouteSegment segment = new RouteSegment(ro, i);
segment.next = original; segment.next = original;
original = segment; original = segment;
@ -544,6 +544,10 @@ public class RoutingContext {
return usedMem1; return usedMem1;
} }
private static long calcRouteId(RouteDataObject o, int ind) {
return (o.getId() << 10) + ind;
}
public static class RoutingSubregionTile { public static class RoutingSubregionTile {
@ -598,9 +602,9 @@ public class RoutingContext {
RouteSegment segment = routes.get(l); RouteSegment segment = routes.get(l);
while (segment != null) { while (segment != null) {
RouteDataObject ro = segment.road; RouteDataObject ro = segment.road;
RouteDataObject toCmp = excludeDuplications.get(ro.id); RouteDataObject toCmp = excludeDuplications.get(calcRouteId(ro, segment.getSegmentStart()));
if (toCmp == null || toCmp.getPointsLength() < ro.getPointsLength()) { if (toCmp == null || toCmp.getPointsLength() < ro.getPointsLength()) {
excludeDuplications.put(ro.id, ro); excludeDuplications.put(calcRouteId(ro, segment.getSegmentStart()), ro);
RouteSegment s = new RouteSegment(ro, segment.getSegmentStart()); RouteSegment s = new RouteSegment(ro, segment.getSegmentStart());
s.next = original; s.next = original;
original = s; original = s;
@ -613,18 +617,21 @@ public class RoutingContext {
RouteDataObject[] res = ctx.nativeLib.getDataObjects(searchResult, x31, y31); RouteDataObject[] res = ctx.nativeLib.getDataObjects(searchResult, x31, y31);
if (res != null) { if (res != null) {
for (RouteDataObject ro : res) { for (RouteDataObject ro : res) {
RouteDataObject toCmp = excludeDuplications.get(ro.id);
boolean accept = ro != null && (toCmp == null || toCmp.getPointsLength() < ro.getPointsLength()); boolean accept = ro != null;
if (ctx != null && accept) { if (ctx != null) {
accept = ctx.getRouter().acceptLine(ro); accept = ctx.getRouter().acceptLine(ro);
} }
if (accept) { if (accept) {
excludeDuplications.put(ro.id, ro);
for (int i = 0; i < ro.pointsX.length; i++) { for (int i = 0; i < ro.pointsX.length; i++) {
if (ro.getPoint31XTile(i) == x31 && ro.getPoint31YTile(i) == y31) { if (ro.getPoint31XTile(i) == x31 && ro.getPoint31YTile(i) == y31) {
RouteSegment segment = new RouteSegment(ro, i); RouteDataObject toCmp = excludeDuplications.get(calcRouteId(ro, i));
segment.next = original; if (toCmp == null || toCmp.getPointsLength() < ro.getPointsLength()) {
original = segment; RouteSegment segment = new RouteSegment(ro, i);
segment.next = original;
original = segment;
excludeDuplications.put(calcRouteId(ro, i), ro);
}
} }
} }
} }