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_occured">Could not calculate route</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="invalid_locations">Invalid coordinates</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.routing.AlarmInfo.AlarmInfoType;
import net.osmand.router.RouteSegmentResult;
import net.osmand.router.RoutingContext;
import net.osmand.router.TurnType;
import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils;
@ -36,7 +37,11 @@ public class RouteCalculationResult {
private final String errorMessage;
private final int[] listDistance;
private final int[] intermediatePoints;
// Route information
private final float routingTime;
private final int visitedSegments;
private final int loadedTiles;
protected int cacheCurrentTextDirectionInfo = -1;
protected List<RouteDirectionInfo> cacheAgreggatedDirections;
@ -54,6 +59,8 @@ public class RouteCalculationResult {
public RouteCalculationResult(String errorMessage) {
this.errorMessage = errorMessage;
this.routingTime = 0;
this.loadedTiles = 0;
this.visitedSegments = 0;
this.intermediatePoints = new int[0];
this.locations = new ArrayList<Location>();
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) {
this.routingTime = 0;
this.loadedTiles = 0;
this.visitedSegments = 0;
this.errorMessage = null;
this.intermediatePoints = new int[params.intermediates == null ? 0 : params.intermediates.size()];
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,
OsmandApplication ctx, boolean leftSide, float routingTime, List<LocationPoint> waypoints, ApplicationMode mode) {
this.routingTime = routingTime;
OsmandApplication ctx, boolean leftSide, RoutingContext rctx, List<LocationPoint> waypoints, ApplicationMode mode) {
this.routingTime = rctx.routingTime;
this.visitedSegments = rctx.visitedSegments;
this.loadedTiles = rctx.loadedTiles;
if(waypoints != null) {
this.locationPoints.addAll(waypoints);
}
@ -807,6 +818,13 @@ public class RouteCalculationResult {
return routingTime;
}
public int getVisitedSegments() {
return visitedSegments;
}
public int getLoadedTiles() {
return loadedTiles;
}
public int getWholeDistance() {
if(listDistance.length > 0) {

View file

@ -769,7 +769,7 @@ public class RouteProvider {
return emptyResult();
} else {
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);
return res;
}

View file

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