Fix distance in toolbar
This commit is contained in:
parent
efa6c6fb4c
commit
d0a274d877
1 changed files with 11 additions and 2 deletions
|
@ -210,8 +210,17 @@ public class MeasurementEditingContext {
|
||||||
|
|
||||||
public double getRouteDistance() {
|
public double getRouteDistance() {
|
||||||
double distance = 0;
|
double distance = 0;
|
||||||
for (RoadSegmentData data : roadSegmentData.values()) {
|
for (List<WptPt> points : Arrays.asList(before.points, after.points)) {
|
||||||
distance += data.getDistance();
|
for (int i = 0; i < points.size() - 1; i++) {
|
||||||
|
Pair<WptPt, WptPt> pair = new Pair<>(points.get(i), points.get(i + 1));
|
||||||
|
RoadSegmentData data = this.roadSegmentData.get(pair);
|
||||||
|
if (data == null) {
|
||||||
|
distance += MapUtils.getDistance(pair.first.getLatitude(), pair.first.getLongitude(),
|
||||||
|
pair.second.getLatitude(), pair.second.getLongitude());
|
||||||
|
} else {
|
||||||
|
distance += data.getDistance();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return distance;
|
return distance;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue