diff --git a/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java b/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java index 97100d0850..d496a65683 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java @@ -1230,7 +1230,7 @@ public class GpxUiHelper { } private static List calculateElevationArray(GPXTrackAnalysis analysis, GPXDataSetAxisType axisType, - float divX, float convEle, boolean useGeneralTrackPoints, boolean calcGaps) { + float divX, float convEle, boolean useGeneralTrackPoints, boolean calcWithoutGaps) { List values = new ArrayList<>(); List elevationData = analysis.elevationData; float nextX = 0; @@ -1252,7 +1252,7 @@ public class GpxUiHelper { x = e.distance; } if (x > 0) { - if (!(!calcGaps && e.firstPoint && lastEntry != null)) { + if (!(calcWithoutGaps && e.firstPoint && lastEntry != null)) { nextX += x / divX; } if (!Float.isNaN(e.elevation)) { @@ -1386,7 +1386,7 @@ public class GpxUiHelper { @NonNull GPXDataSetAxisType axisType, boolean useRightAxis, boolean drawFilled, - boolean calcGaps) { + boolean calcWithoutGaps) { OsmandSettings settings = ctx.getSettings(); OsmandSettings.MetricsConstants mc = settings.METRIC_SYSTEM.get(); boolean useFeet = (mc == OsmandSettings.MetricsConstants.MILES_AND_FEET) || (mc == OsmandSettings.MetricsConstants.MILES_AND_YARDS); @@ -1396,11 +1396,11 @@ public class GpxUiHelper { float divX; XAxis xAxis = mChart.getXAxis(); if (axisType == GPXDataSetAxisType.TIME && analysis.isTimeSpecified()) { - divX = setupXAxisTime(xAxis, calcGaps ? analysis.timeSpan : analysis.timeSpanWithoutGaps); + divX = setupXAxisTime(xAxis, calcWithoutGaps ? analysis.timeSpanWithoutGaps : analysis.timeSpan); } else if (axisType == GPXDataSetAxisType.TIMEOFDAY && analysis.isTimeSpecified()) { divX = setupXAxisTimeOfDay(xAxis, analysis.startTime); } else { - divX = setupAxisDistance(ctx, xAxis, calcGaps ? analysis.totalDistance : analysis.totalDistanceWithoutGaps); + divX = setupAxisDistance(ctx, xAxis, calcWithoutGaps ? analysis.totalDistanceWithoutGaps : analysis.totalDistance); } final String mainUnitY = useFeet ? ctx.getString(R.string.foot) : ctx.getString(R.string.m); @@ -1424,7 +1424,7 @@ public class GpxUiHelper { } }); - List values = calculateElevationArray(analysis, axisType, divX, convEle, true, calcGaps); + List values = calculateElevationArray(analysis, axisType, divX, convEle, true, calcWithoutGaps); OrderedLineDataSet dataSet = new OrderedLineDataSet(values, "", GPXDataSetType.ALTITUDE, axisType); dataSet.priority = (float) (analysis.avgElevation - analysis.minElevation) * convEle; @@ -1471,22 +1471,23 @@ public class GpxUiHelper { } public static OrderedLineDataSet createGPXSpeedDataSet(@NonNull OsmandApplication ctx, - @NonNull LineChart mChart, - @NonNull GPXTrackAnalysis analysis, - @NonNull GPXDataSetAxisType axisType, - boolean useRightAxis, - boolean drawFilled) { + @NonNull LineChart mChart, + @NonNull GPXTrackAnalysis analysis, + @NonNull GPXDataSetAxisType axisType, + boolean useRightAxis, + boolean drawFilled, + boolean calcWithoutGaps) { OsmandSettings settings = ctx.getSettings(); boolean light = settings.isLightContent(); float divX; XAxis xAxis = mChart.getXAxis(); if (axisType == GPXDataSetAxisType.TIME && analysis.isTimeSpecified()) { - divX = setupXAxisTime(xAxis, analysis.timeSpan); + divX = setupXAxisTime(xAxis, calcWithoutGaps ? analysis.timeSpanWithoutGaps : analysis.timeSpan); } else if (axisType == GPXDataSetAxisType.TIMEOFDAY && analysis.isTimeSpecified()) { divX = setupXAxisTimeOfDay(xAxis, analysis.startTime); } else { - divX = setupAxisDistance(ctx, xAxis, analysis.totalDistance); + divX = setupAxisDistance(ctx, xAxis, calcWithoutGaps ? analysis.totalDistanceWithoutGaps : analysis.totalDistance); } OsmandSettings.SpeedConstants sps = settings.SPEED_SYSTEM.get(); @@ -1546,7 +1547,9 @@ public class GpxUiHelper { values.add(new Entry(nextX + 1, 0)); values.add(new Entry(nextX + x - 1, 0)); } - nextX += x / divX; + if (!(calcWithoutGaps && s.firstPoint)) { + nextX += x / divX; + } if (Float.isNaN(divSpeed)) { nextY = s.speed * mulSpeed; } else { @@ -1644,7 +1647,7 @@ public class GpxUiHelper { @Nullable List eleValues, boolean useRightAxis, boolean drawFilled, - boolean calcGaps) { + boolean calcWithoutGaps) { if (axisType == GPXDataSetAxisType.TIME || axisType == GPXDataSetAxisType.TIMEOFDAY) { return null; } @@ -1653,10 +1656,10 @@ public class GpxUiHelper { OsmandSettings.MetricsConstants mc = settings.METRIC_SYSTEM.get(); boolean useFeet = (mc == OsmandSettings.MetricsConstants.MILES_AND_FEET) || (mc == OsmandSettings.MetricsConstants.MILES_AND_YARDS); final float convEle = useFeet ? 3.28084f : 1.0f; - final float totalDistance = calcGaps ? analysis.totalDistance : analysis.totalDistanceWithoutGaps; + final float totalDistance = calcWithoutGaps ? analysis.totalDistanceWithoutGaps : analysis.totalDistance; XAxis xAxis = mChart.getXAxis(); - float divX = setupAxisDistance(ctx, xAxis, calcGaps ? analysis.totalDistance : analysis.totalDistanceWithoutGaps); + float divX = setupAxisDistance(ctx, xAxis, calcWithoutGaps ? analysis.totalDistanceWithoutGaps : analysis.totalDistance); final String mainUnitY = "%"; @@ -1681,7 +1684,7 @@ public class GpxUiHelper { List values; if (eleValues == null) { - values = calculateElevationArray(analysis, GPXDataSetAxisType.DISTANCE, 1f, 1f, false, calcGaps); + values = calculateElevationArray(analysis, GPXDataSetAxisType.DISTANCE, 1f, 1f, false, calcWithoutGaps); } else { values = new ArrayList<>(eleValues.size()); for (Entry e : eleValues) { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/TrackDetailsMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/TrackDetailsMenu.java index 1377914957..5f4e0a75b0 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/TrackDetailsMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/TrackDetailsMenu.java @@ -590,7 +590,7 @@ public class TrackDetailsMenu { break; case SPEED: dataSet = GpxUiHelper.createGPXSpeedDataSet(app, chart, analysis, - gpxItem.chartAxisType, gpxItem.chartTypes.length > 1, true); + gpxItem.chartAxisType, gpxItem.chartTypes.length > 1, true, false); break; case SLOPE: dataSet = GpxUiHelper.createGPXSlopeDataSet(app, chart, analysis, diff --git a/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java index c4aa6a9931..e39de1c4b3 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java @@ -426,19 +426,19 @@ public class TrackSegmentFragment extends OsmAndListFragment implements TrackBit if (dataSets == null && chart != null) { dataSets = new ArrayList<>(); GPXTrackAnalysis analysis = gpxItem.analysis; + GpxDataItem gpxDataItem = getGpxDataItem(); + boolean calcWithoutGaps = gpxItem.isGeneralTrack() && gpxDataItem != null && !gpxDataItem.isJoinSegments(); switch (tabType) { case GPX_TAB_ITEM_GENERAL: { OrderedLineDataSet speedDataSet = null; OrderedLineDataSet elevationDataSet = null; if (analysis.hasSpeedData) { speedDataSet = GpxUiHelper.createGPXSpeedDataSet(app, chart, - analysis, GPXDataSetAxisType.DISTANCE, true, true); + analysis, GPXDataSetAxisType.DISTANCE, true, true, calcWithoutGaps); } if (analysis.hasElevationData) { - GpxDataItem gpxDataItem = getGpxDataItem(); - boolean calcGaps = gpxDataItem != null && gpxDataItem.isJoinSegments() && gpxItem.isGeneralTrack() || !gpxItem.isGeneralTrack(); elevationDataSet = GpxUiHelper.createGPXElevationDataSet(app, chart, - analysis, GPXDataSetAxisType.DISTANCE, false, true, calcGaps); + analysis, GPXDataSetAxisType.DISTANCE, false, true, calcWithoutGaps); } if (speedDataSet != null) { dataSets.add(speedDataSet); @@ -453,17 +453,15 @@ public class TrackSegmentFragment extends OsmAndListFragment implements TrackBit break; } case GPX_TAB_ITEM_ALTITUDE: { - GpxDataItem gpxDataItem = getGpxDataItem(); - boolean calcGaps = gpxDataItem != null && gpxDataItem.isJoinSegments() && gpxItem.isGeneralTrack() || !gpxItem.isGeneralTrack(); OrderedLineDataSet elevationDataSet = GpxUiHelper.createGPXElevationDataSet(app, chart, - analysis, GPXDataSetAxisType.DISTANCE, false, true, calcGaps); + analysis, GPXDataSetAxisType.DISTANCE, false, true, calcWithoutGaps); if (elevationDataSet != null) { dataSets.add(elevationDataSet); } if (analysis.hasElevationData) { List eleValues = elevationDataSet != null && !gpxItem.isGeneralTrack() ? elevationDataSet.getValues() : null; OrderedLineDataSet slopeDataSet = GpxUiHelper.createGPXSlopeDataSet(app, chart, - analysis, GPXDataSetAxisType.DISTANCE, eleValues, true, true, calcGaps); + analysis, GPXDataSetAxisType.DISTANCE, eleValues, true, true, calcWithoutGaps); if (slopeDataSet != null) { dataSets.add(slopeDataSet); } @@ -473,7 +471,7 @@ public class TrackSegmentFragment extends OsmAndListFragment implements TrackBit } case GPX_TAB_ITEM_SPEED: { OrderedLineDataSet speedDataSet = GpxUiHelper.createGPXSpeedDataSet(app, chart, - analysis, GPXDataSetAxisType.DISTANCE, false, true); + analysis, GPXDataSetAxisType.DISTANCE, false, true, calcWithoutGaps); if (speedDataSet != null) { dataSets.add(speedDataSet); } diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/RouteStatisticCard.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/RouteStatisticCard.java index 4c02d15ee7..28138b32a5 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/RouteStatisticCard.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/RouteStatisticCard.java @@ -22,7 +22,6 @@ import com.github.mikephil.charting.interfaces.datasets.ILineDataSet; import com.github.mikephil.charting.listener.ChartTouchListener.ChartGesture; import com.github.mikephil.charting.listener.OnChartGestureListener; import com.github.mikephil.charting.listener.OnChartValueSelectedListener; -import com.github.mikephil.charting.utils.MPPointD; import net.osmand.AndroidUtils; import net.osmand.GPXUtilities.GPXFile;