From 2c4402631e190d882c89dcfbdf4fc798297d1588 Mon Sep 17 00:00:00 2001 From: MadWasp79 Date: Fri, 10 Apr 2020 15:52:40 +0300 Subject: [PATCH] testing --- .../java/net/osmand/router/TransportRoutePlanner.java | 7 +++++-- .../net/osmand/plus/routing/TransportRoutingHelper.java | 9 ++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/router/TransportRoutePlanner.java b/OsmAnd-java/src/main/java/net/osmand/router/TransportRoutePlanner.java index aa90331e0d..2bd48506b2 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/TransportRoutePlanner.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/TransportRoutePlanner.java @@ -40,9 +40,11 @@ public class TransportRoutePlanner { public static final long STOPS_WAY_ID = -2; public List buildRoute(TransportRoutingContext ctx, LatLon start, LatLon end) throws IOException, InterruptedException { + /**delete*/ int cnt = 0; ctx.startCalcTime = System.currentTimeMillis(); List startStops = ctx.getTransportStops(start); List endStops = ctx.getTransportStops(end); + /** delete */ cnt = 2; /** delete */System.out.println(String.format("startStops/endStops: %d / %d", startStops.size(), endStops.size())); TLongObjectHashMap endSegments = new TLongObjectHashMap(); 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 routes1 = new ArrayList<>(); +// List 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 diff --git a/OsmAnd/src/net/osmand/plus/routing/TransportRoutingHelper.java b/OsmAnd/src/net/osmand/plus/routing/TransportRoutingHelper.java index ee62fadfdf..274ae39dcf 100644 --- a/OsmAnd/src/net/osmand/plus/routing/TransportRoutingHelper.java +++ b/OsmAnd/src/net/osmand/plus/routing/TransportRoutingHelper.java @@ -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 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); }