Fix distance in toolbar

This commit is contained in:
max-klaus 2020-08-22 16:26:28 +03:00
parent efa6c6fb4c
commit d0a274d877

View file

@ -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;
} }