2013-04-18 23:35:02 +02:00
|
|
|
package net.osmand.router;
|
|
|
|
|
|
|
|
public class RouteCalculationProgress {
|
|
|
|
|
|
|
|
public int segmentNotFound = -1;
|
|
|
|
public float distanceFromBegin;
|
2014-02-02 14:06:09 +01:00
|
|
|
public float directDistance;
|
2013-04-18 23:35:02 +02:00
|
|
|
public int directSegmentQueueSize;
|
|
|
|
public float distanceFromEnd;
|
|
|
|
public int reverseSegmentQueueSize;
|
2014-02-02 14:06:09 +01:00
|
|
|
public float reverseDistance;
|
2013-04-18 23:35:02 +02:00
|
|
|
public float totalEstimatedDistance = 0;
|
|
|
|
|
|
|
|
public float routingCalculatedTime = 0;
|
|
|
|
public int loadedTiles = 0;
|
|
|
|
public int visitedSegments = 0;
|
|
|
|
|
2018-05-29 23:04:00 +02:00
|
|
|
public int totalIterations = 1;
|
2018-05-29 23:07:24 +02:00
|
|
|
public int iteration = -1;
|
2018-05-29 23:04:00 +02:00
|
|
|
|
2013-04-18 23:35:02 +02:00
|
|
|
public boolean isCancelled;
|
2017-04-11 17:28:58 +02:00
|
|
|
public boolean requestPrivateAccessRouting;
|
2018-05-29 23:15:59 +02:00
|
|
|
|
2018-05-30 11:45:19 +02:00
|
|
|
private static final float INITIAL_PROGRSS = 0.05f;
|
|
|
|
private static final float FIRST_ITERATION = 0.72f;
|
|
|
|
|
2018-05-29 23:15:59 +02:00
|
|
|
public float getLinearProgress() {
|
|
|
|
float p = Math.max(distanceFromBegin, distanceFromEnd);
|
|
|
|
float all = totalEstimatedDistance * 1.25f;
|
2018-05-30 11:45:19 +02:00
|
|
|
float pr = 0;
|
2018-05-29 23:15:59 +02:00
|
|
|
if (all > 0) {
|
2018-05-30 11:45:19 +02:00
|
|
|
pr = p * p / (all * all);
|
2018-05-29 23:15:59 +02:00
|
|
|
}
|
2018-05-30 11:45:19 +02:00
|
|
|
float progress = INITIAL_PROGRSS;
|
|
|
|
if (totalIterations > 1) {
|
|
|
|
if (iteration <= 0) {
|
|
|
|
progress = pr * FIRST_ITERATION + INITIAL_PROGRSS;
|
2018-05-29 23:15:59 +02:00
|
|
|
} else {
|
2018-05-30 11:45:19 +02:00
|
|
|
progress = (INITIAL_PROGRSS + FIRST_ITERATION) + pr * (1 - FIRST_ITERATION - INITIAL_PROGRSS);
|
2018-05-29 23:15:59 +02:00
|
|
|
}
|
2018-05-30 11:45:19 +02:00
|
|
|
} else {
|
|
|
|
progress = INITIAL_PROGRSS + pr * (1 - INITIAL_PROGRSS);
|
2018-05-29 23:15:59 +02:00
|
|
|
}
|
2018-05-30 11:45:19 +02:00
|
|
|
return Math.min(progress * 100f, 99);
|
2018-05-29 23:15:59 +02:00
|
|
|
}
|
2013-04-18 23:35:02 +02:00
|
|
|
}
|