This commit is contained in:
Vitaliy 2020-07-10 16:56:55 +03:00
parent 666258230e
commit f479debb79
3 changed files with 13 additions and 14 deletions

View file

@ -932,7 +932,6 @@ public class GPXUtilities {
sp = new SplitSegment(segment, k - 1, cf); sp = new SplitSegment(segment, k - 1, cf);
currentMetricEnd += metricLimit; currentMetricEnd += metricLimit;
prev = sp.get(0);
} }
total += currentSegment; total += currentSegment;
} }

View file

@ -46,6 +46,7 @@ import net.osmand.plus.helpers.GpxUiHelper.OrderedLineDataSet;
import net.osmand.plus.views.GPXLayer; import net.osmand.plus.views.GPXLayer;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory; import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController; import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController;
import net.osmand.util.MapUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@ -312,18 +313,15 @@ public class TrackDetailsMenu {
} }
} else { } else {
float distance = pos * dataSet.getDivX(); float distance = pos * dataSet.getDivX();
double previousSplitDistance = 0; double totalDistance = 0;
WptPt previousPoint = null; WptPt previousPoint = null;
for (int i = 0; i < segment.points.size(); i++) { for (int i = 0; i < segment.points.size(); i++) {
WptPt currentPoint = segment.points.get(i); WptPt currentPoint = segment.points.get(i);
if (previousPoint != null) { if (previousPoint != null) {
if (currentPoint.distance < previousPoint.distance) { totalDistance += MapUtils.getDistance(previousPoint.lat, previousPoint.lon, currentPoint.lat, currentPoint.lon);
previousSplitDistance += previousPoint.distance;
}
} }
double totalDistance = previousSplitDistance + currentPoint.distance; if (currentPoint.distance >= distance || Math.abs(totalDistance - distance) < 0.1) {
if (totalDistance >= distance) { if (previousPoint != null && currentPoint.distance >= distance) {
if (previousPoint != null) {
double percent = 1 - (totalDistance - distance) / (currentPoint.distance - previousPoint.distance); double percent = 1 - (totalDistance - distance) / (currentPoint.distance - previousPoint.distance);
double dLat = (currentPoint.lat - previousPoint.lat) * percent; double dLat = (currentPoint.lat - previousPoint.lat) * percent;
double dLon = (currentPoint.lon - previousPoint.lon) * percent; double dLon = (currentPoint.lon - previousPoint.lon) * percent;
@ -500,6 +498,9 @@ public class TrackDetailsMenu {
} else { } else {
mapActivity.getMapLayers().getGpxLayer().setTrackChartPoints(trackChartPoints); mapActivity.getMapLayers().getGpxLayer().setTrackChartPoints(trackChartPoints);
} }
if (location != null) {
mapActivity.refreshMap();
}
fitTrackOnMap(chart, location, forceFit); fitTrackOnMap(chart, location, forceFit);
} }

View file

@ -57,7 +57,6 @@ import net.osmand.plus.GpxSelectionHelper.GpxDisplayItemType;
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.UiUtilities; import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
@ -70,12 +69,14 @@ import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetType;
import net.osmand.plus.helpers.GpxUiHelper.OrderedLineDataSet; import net.osmand.plus.helpers.GpxUiHelper.OrderedLineDataSet;
import net.osmand.plus.measurementtool.NewGpxData; import net.osmand.plus.measurementtool.NewGpxData;
import net.osmand.plus.myplaces.TrackBitmapDrawer.TrackBitmapDrawerListener; import net.osmand.plus.myplaces.TrackBitmapDrawer.TrackBitmapDrawerListener;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.views.controls.PagerSlidingTabStrip; import net.osmand.plus.views.controls.PagerSlidingTabStrip;
import net.osmand.plus.views.controls.PagerSlidingTabStrip.CustomTabProvider; import net.osmand.plus.views.controls.PagerSlidingTabStrip.CustomTabProvider;
import net.osmand.plus.views.controls.WrapContentHeightViewPager; import net.osmand.plus.views.controls.WrapContentHeightViewPager;
import net.osmand.plus.views.controls.WrapContentHeightViewPager.ViewAtPositionInterface; import net.osmand.plus.views.controls.WrapContentHeightViewPager.ViewAtPositionInterface;
import net.osmand.plus.widgets.IconPopupMenu; import net.osmand.plus.widgets.IconPopupMenu;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils;
import java.io.File; import java.io.File;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
@ -525,16 +526,14 @@ public class TrackSegmentFragment extends OsmAndListFragment implements TrackBit
} }
} else { } else {
float distance = pos * dataSet.getDivX(); float distance = pos * dataSet.getDivX();
double previousSplitDistance = 0; double totalDistance = 0;
for (int i = 0; i < segment.points.size(); i++) { for (int i = 0; i < segment.points.size(); i++) {
WptPt currentPoint = segment.points.get(i); WptPt currentPoint = segment.points.get(i);
if (i != 0) { if (i != 0) {
WptPt previousPoint = segment.points.get(i - 1); WptPt previousPoint = segment.points.get(i - 1);
if (currentPoint.distance < previousPoint.distance) { totalDistance += MapUtils.getDistance(previousPoint.lat, previousPoint.lon, currentPoint.lat, currentPoint.lon);
previousSplitDistance += previousPoint.distance;
}
} }
if (previousSplitDistance + currentPoint.distance >= distance) { if (currentPoint.distance >= distance || Math.abs(totalDistance - distance) < 0.1) {
wpt = currentPoint; wpt = currentPoint;
break; break;
} }