Introduce more info for debug

This commit is contained in:
Victor Shcherb 2019-08-05 15:09:43 +02:00
parent a18a346788
commit d62494a8c4
4 changed files with 29 additions and 13 deletions

View file

@ -2911,7 +2911,7 @@
<string name="error_calculating_route">Could not calculate route</string> <string name="error_calculating_route">Could not calculate route</string>
<string name="error_calculating_route_occured">Could not calculate route</string> <string name="error_calculating_route_occured">Could not calculate route</string>
<string name="empty_route_calculated">Calculated route is empty</string> <string name="empty_route_calculated">Calculated route is empty</string>
<string name="new_route_calculated_dist">New route calculated, distance</string> <string name="new_route_calculated_dist_dbg">Route calculated (internal): distance %s, router time %s (%d tiles, %d segments)</string>
<string name="arrived_at_destination">You have arrived at your destination</string> <string name="arrived_at_destination">You have arrived at your destination</string>
<string name="invalid_locations">Invalid coordinates</string> <string name="invalid_locations">Invalid coordinates</string>
<string name="go_back_to_osmand">Go back to OsmAnd map</string> <string name="go_back_to_osmand">Go back to OsmAnd map</string>

View file

@ -15,6 +15,7 @@ import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.routing.AlarmInfo.AlarmInfoType; import net.osmand.plus.routing.AlarmInfo.AlarmInfoType;
import net.osmand.router.RouteSegmentResult; import net.osmand.router.RouteSegmentResult;
import net.osmand.router.RoutingContext;
import net.osmand.router.TurnType; import net.osmand.router.TurnType;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils; import net.osmand.util.MapUtils;
@ -36,7 +37,11 @@ public class RouteCalculationResult {
private final String errorMessage; private final String errorMessage;
private final int[] listDistance; private final int[] listDistance;
private final int[] intermediatePoints; private final int[] intermediatePoints;
// Route information
private final float routingTime; private final float routingTime;
private final int visitedSegments;
private final int loadedTiles;
protected int cacheCurrentTextDirectionInfo = -1; protected int cacheCurrentTextDirectionInfo = -1;
protected List<RouteDirectionInfo> cacheAgreggatedDirections; protected List<RouteDirectionInfo> cacheAgreggatedDirections;
@ -54,6 +59,8 @@ public class RouteCalculationResult {
public RouteCalculationResult(String errorMessage) { public RouteCalculationResult(String errorMessage) {
this.errorMessage = errorMessage; this.errorMessage = errorMessage;
this.routingTime = 0; this.routingTime = 0;
this.loadedTiles = 0;
this.visitedSegments = 0;
this.intermediatePoints = new int[0]; this.intermediatePoints = new int[0];
this.locations = new ArrayList<Location>(); this.locations = new ArrayList<Location>();
this.segments = new ArrayList<RouteSegmentResult>(); this.segments = new ArrayList<RouteSegmentResult>();
@ -64,6 +71,8 @@ public class RouteCalculationResult {
public RouteCalculationResult(List<Location> list, List<RouteDirectionInfo> directions, RouteCalculationParams params, List<LocationPoint> waypoints, boolean addMissingTurns) { public RouteCalculationResult(List<Location> list, List<RouteDirectionInfo> directions, RouteCalculationParams params, List<LocationPoint> waypoints, boolean addMissingTurns) {
this.routingTime = 0; this.routingTime = 0;
this.loadedTiles = 0;
this.visitedSegments = 0;
this.errorMessage = null; this.errorMessage = null;
this.intermediatePoints = new int[params.intermediates == null ? 0 : params.intermediates.size()]; this.intermediatePoints = new int[params.intermediates == null ? 0 : params.intermediates.size()];
List<Location> locations = list == null ? new ArrayList<Location>() : new ArrayList<Location>(list); List<Location> locations = list == null ? new ArrayList<Location>() : new ArrayList<Location>(list);
@ -93,8 +102,10 @@ public class RouteCalculationResult {
} }
public RouteCalculationResult(List<RouteSegmentResult> list, Location start, LatLon end, List<LatLon> intermediates, public RouteCalculationResult(List<RouteSegmentResult> list, Location start, LatLon end, List<LatLon> intermediates,
OsmandApplication ctx, boolean leftSide, float routingTime, List<LocationPoint> waypoints, ApplicationMode mode) { OsmandApplication ctx, boolean leftSide, RoutingContext rctx, List<LocationPoint> waypoints, ApplicationMode mode) {
this.routingTime = routingTime; this.routingTime = rctx.routingTime;
this.visitedSegments = rctx.visitedSegments;
this.loadedTiles = rctx.loadedTiles;
if(waypoints != null) { if(waypoints != null) {
this.locationPoints.addAll(waypoints); this.locationPoints.addAll(waypoints);
} }
@ -807,6 +818,13 @@ public class RouteCalculationResult {
return routingTime; return routingTime;
} }
public int getVisitedSegments() {
return visitedSegments;
}
public int getLoadedTiles() {
return loadedTiles;
}
public int getWholeDistance() { public int getWholeDistance() {
if(listDistance.length > 0) { if(listDistance.length > 0) {

View file

@ -769,7 +769,7 @@ public class RouteProvider {
return emptyResult(); return emptyResult();
} else { } else {
RouteCalculationResult res = new RouteCalculationResult(result, params.start, params.end, RouteCalculationResult res = new RouteCalculationResult(result, params.start, params.end,
params.intermediates, params.ctx, params.leftSide, ctx.routingTime, params.gpxRoute == null? null: params.gpxRoute.wpt, params.intermediates, params.ctx, params.leftSide, ctx, params.gpxRoute == null? null: params.gpxRoute.wpt,
params.mode); params.mode);
return res; return res;
} }

View file

@ -732,11 +732,9 @@ public class RoutingHelper {
} }
} }
if (showToast.value && OsmandPlugin.isDevelopment()) { if (showToast.value && OsmandPlugin.isDevelopment()) {
String msg = app.getString(R.string.new_route_calculated_dist) + ": " String msg = app.getString(R.string.new_route_calculated_dist_dbg,
+ OsmAndFormatter.getFormattedDistance(res.getWholeDistance(), app); OsmAndFormatter.getFormattedDistance(res.getWholeDistance(), app),
if (res.getRoutingTime() != 0f) { ((int)res.getRoutingTime()) + " sec", res.getVisitedSegments(), res.getLoadedTiles());
msg += " (" + Algorithms.formatDuration((int) res.getRoutingTime(), app.accessibilityEnabled()) + ")";
}
app.showToastMessage(msg); app.showToastMessage(msg);
} }
} }