This commit is contained in:
MadWasp79 2020-04-14 14:59:33 +03:00
parent 2c4402631e
commit a128455d7e
7 changed files with 9 additions and 23 deletions

View file

@ -25,7 +25,7 @@ import net.osmand.data.MapObject;
import net.osmand.data.QuadRect;
import net.osmand.render.RenderingRuleSearchRequest;
import net.osmand.render.RenderingRulesStorage;
import net.osmand.router.ptresult.NativeTransportRoutingResult;
import net.osmand.router.NativeTransportRoutingResult;
import net.osmand.router.PrecalculatedRouteDirection;
import net.osmand.router.RouteCalculationProgress;
import net.osmand.router.RouteSegmentResult;

View file

@ -1,4 +1,4 @@
package net.osmand.router.ptresult;
package net.osmand.router;
public class NativeTransportRoute {
//MapObject part:

View file

@ -1,4 +1,4 @@
package net.osmand.router.ptresult;
package net.osmand.router;
public class NativeTransportRouteResultSegment {
public NativeTransportRoute route;

View file

@ -1,4 +1,4 @@
package net.osmand.router.ptresult;
package net.osmand.router;
public class NativeTransportRoutingResult {

View file

@ -1,4 +1,4 @@
package net.osmand.router.ptresult;
package net.osmand.router;
public class NativeTransportStop {
//MapObject part:

View file

@ -27,10 +27,6 @@ import net.osmand.data.TransportStop;
import net.osmand.data.TransportStopExit;
import net.osmand.osm.edit.Node;
import net.osmand.osm.edit.Way;
import net.osmand.router.ptresult.NativeTransportRoute;
import net.osmand.router.ptresult.NativeTransportRouteResultSegment;
import net.osmand.router.ptresult.NativeTransportRoutingResult;
import net.osmand.router.ptresult.NativeTransportStop;
import net.osmand.util.MapUtils;
public class TransportRoutePlanner {
@ -40,12 +36,10 @@ 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) {
endSegments.put(s.getId(), s);
@ -120,7 +114,6 @@ 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) {
@ -190,7 +183,6 @@ public class TransportRoutePlanner {
updateCalculationProgress(ctx, queue);
}
System.out.println(String.format("Count calls getTransportStop %d", cnt));
return prepareResults(ctx, results);
}
@ -981,7 +973,7 @@ public class TransportRoutePlanner {
public static List<TransportRouteResult> convertToTransportRoutingResult(NativeTransportRoutingResult[] res,
TransportRoutingConfiguration cfg) {
List<TransportRouteResult> convertedRes = new ArrayList<TransportRouteResult>();
for (net.osmand.router.ptresult.NativeTransportRoutingResult ntrr : res) {
for (NativeTransportRoutingResult ntrr : res) {
TransportRouteResult trr = new TransportRouteResult(cfg);
trr.setFinishWalkDist(ntrr.finishWalkDist);
trr.setRouteTime(ntrr.routeTime);

View file

@ -31,7 +31,7 @@ import net.osmand.router.TransportRoutePlanner.TransportRouteResult;
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.router.NativeTransportRoutingResult;
import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils;
@ -502,13 +502,7 @@ public class TransportRoutingHelper {
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 res;
} else {
return planner.buildRoute(ctx, params.start, params.end);
}