This commit is contained in:
MadWasp79 2020-04-10 15:52:40 +03:00
parent 53d64e8306
commit 2c4402631e
2 changed files with 13 additions and 3 deletions

View file

@ -40,9 +40,11 @@ public class TransportRoutePlanner {
public static final long STOPS_WAY_ID = -2;
public List<TransportRouteResult> buildRoute(TransportRoutingContext ctx, LatLon start, LatLon end) throws IOException, InterruptedException {
/**delete*/ int cnt = 0;
ctx.startCalcTime = System.currentTimeMillis();
List<TransportRouteSegment> startStops = ctx.getTransportStops(start);
List<TransportRouteSegment> endStops = ctx.getTransportStops(end);
/** delete */ cnt = 2;
/** delete */System.out.println(String.format("startStops/endStops: %d / %d", startStops.size(), endStops.size()));
TLongObjectHashMap<TransportRouteSegment> endSegments = new TLongObjectHashMap<TransportRouteSegment>();
for(TransportRouteSegment s : endStops) {
@ -118,6 +120,7 @@ public class TransportRoutePlanner {
}
sgms.clear();
sgms = ctx.getTransportStops(stop.x31, stop.y31, true, sgms);
/**delete*/cnt++;
ctx.visitedStops++;
for (TransportRouteSegment sgm : sgms) {
if (ctx.calculationProgress != null && ctx.calculationProgress.isCancelled) {
@ -187,7 +190,7 @@ public class TransportRoutePlanner {
updateCalculationProgress(ctx, queue);
}
System.out.println(String.format("Count calls getTransportStop %d", cnt));
return prepareResults(ctx, results);
}
@ -1067,7 +1070,7 @@ public class TransportRoutePlanner {
s.distance = ns.distance;
s.x31 = ns.x31;
s.y31 = ns.y31;
List<TransportRoute> routes1 = new ArrayList<>();
// List<TransportRoute> routes1 = new ArrayList<>();
//cache routes to avoid circular conversion and just search them by id
for (int i = 0; i < ns.routes.length; i++) {
if (s.getRoutesIds().length == ns.routes.length && convertedRoutesCache != null

View file

@ -32,6 +32,7 @@ import net.osmand.router.TransportRoutePlanner.TransportRouteResultSegment;
import net.osmand.router.TransportRoutePlanner.TransportRoutingContext;
import net.osmand.router.TransportRoutingConfiguration;
import net.osmand.router.ptresult.NativeTransportRoutingResult;
import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils;
import java.io.IOException;
@ -500,8 +501,14 @@ public class TransportRoutingHelper {
MapUtils.get31TileNumberX(params.end.getLongitude()),
MapUtils.get31TileNumberY(params.end.getLatitude()),
cfg, ctx.calculationProgress);
List<TransportRouteResult> res = TransportRoutePlanner.convertToTransportRoutingResult(nativeRes, cfg);
if (!Algorithms.isEmpty(res)) {
return res;
} else {
app.showToastMessage("Can't find route with NativeLib, switching to Java");
return planner.buildRoute(ctx, params.start, params.end);
}
return TransportRoutePlanner.convertToTransportRoutingResult(nativeRes, cfg);
} else {
return planner.buildRoute(ctx, params.start, params.end);
}