Fix route calculation

This commit is contained in:
Victor Shcherb 2020-06-04 18:37:49 +02:00
parent 5afe3a90ad
commit c638e01dfd
2 changed files with 6 additions and 5 deletions

View file

@ -1,5 +1,6 @@
package net.osmand.router;
import net.osmand.NativeLibrary;
import net.osmand.PlatformUtil;
import net.osmand.binary.BinaryMapIndexReader;
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteTypeRule;
@ -1721,7 +1722,7 @@ public class RouteResultPreparation {
}
}
Iterator<RouteSegment> it;
if(rr.getPreAttachedRoutes(pointInd) != null) {
if (rr.getPreAttachedRoutes(pointInd) != null) {
final RouteSegmentResult[] list = rr.getPreAttachedRoutes(pointInd);
it = new Iterator<BinaryRoutePlanner.RouteSegment>() {
int i = 0;
@ -1740,7 +1741,7 @@ public class RouteResultPreparation {
public void remove() {
}
};
} else if (recalculation) {
} else if (recalculation || ctx.nativeLib == null) {
RouteSegment rt = ctx.loadRouteSegment(road.getPoint31XTile(pointInd), road.getPoint31YTile(pointInd), ctx.config.memoryLimitation);
it = rt == null ? null : rt.getIterator();
} else {

View file

@ -403,7 +403,7 @@ public class RouteSegmentResult implements StringExternalizable<RouteDataBundle>
}
public void copyPreattachedRoutes(RouteSegmentResult toCopy, int shift) {
if(toCopy.preAttachedRoutes != null) {
if (toCopy.preAttachedRoutes != null) {
int l = toCopy.preAttachedRoutes.length - shift;
preAttachedRoutes = new RouteSegmentResult[l][];
System.arraycopy(toCopy.preAttachedRoutes, shift, preAttachedRoutes, 0, l);
@ -412,7 +412,7 @@ public class RouteSegmentResult implements StringExternalizable<RouteDataBundle>
public RouteSegmentResult[] getPreAttachedRoutes(int routeInd) {
int st = Math.abs(routeInd - startPointIndex);
if(preAttachedRoutes != null && st < preAttachedRoutes.length) {
if (preAttachedRoutes != null && st < preAttachedRoutes.length) {
return preAttachedRoutes[st];
}
return null;
@ -421,7 +421,7 @@ public class RouteSegmentResult implements StringExternalizable<RouteDataBundle>
public List<RouteSegmentResult> getAttachedRoutes(int routeInd) {
int st = Math.abs(routeInd - startPointIndex);
List<RouteSegmentResult> list = attachedRoutes[st];
if(list == null) {
if (list == null) {
return Collections.emptyList();
}
return list;