diff --git a/OsmAnd-shared/src/commonMain/kotlin/net/osmand/shared/gpx/GpxDatabase.kt b/OsmAnd-shared/src/commonMain/kotlin/net/osmand/shared/gpx/GpxDatabase.kt index 6fdde56729e..19b28731512 100644 --- a/OsmAnd-shared/src/commonMain/kotlin/net/osmand/shared/gpx/GpxDatabase.kt +++ b/OsmAnd-shared/src/commonMain/kotlin/net/osmand/shared/gpx/GpxDatabase.kt @@ -23,7 +23,7 @@ class GpxDatabase { companion object { val log = LoggerFactory.getLogger("GpxDatabase") - const val DB_VERSION = 30 + const val DB_VERSION = 29 const val DB_NAME = "gpx_database" const val GPX_TABLE_NAME = "gpxTable" const val GPX_DIR_TABLE_NAME = "gpxDirTable" diff --git a/OsmAnd-shared/src/commonMain/kotlin/net/osmand/shared/gpx/GpxFile.kt b/OsmAnd-shared/src/commonMain/kotlin/net/osmand/shared/gpx/GpxFile.kt index 33bb6057c07..b79d879a1d4 100644 --- a/OsmAnd-shared/src/commonMain/kotlin/net/osmand/shared/gpx/GpxFile.kt +++ b/OsmAnd-shared/src/commonMain/kotlin/net/osmand/shared/gpx/GpxFile.kt @@ -276,14 +276,8 @@ class GpxFile : GpxExtensions { analysis.wptPoints = points.size analysis.setWptCategoryNames(getWaypointCategories()) - val generalTrack = getGeneralTrack() - val generalSegment = getGeneralSegment() - if (!isShowCurrentTrack() && generalTrack != null && generalSegment != null) { - analysis.prepareInformation(fileTimestamp, pointsAnalyzer, SplitSegment(generalSegment)) - } else { - val segments = getSplitSegments(analysis, fromDistance, toDistance) - analysis.prepareInformation(fileTimestamp, pointsAnalyzer, *segments.toTypedArray()) - } + val segments = getSplitSegments(analysis, fromDistance, toDistance) + analysis.prepareInformation(fileTimestamp, pointsAnalyzer, *segments.toTypedArray()) return analysis } diff --git a/OsmAnd-shared/src/commonMain/kotlin/net/osmand/shared/gpx/GpxParameter.kt b/OsmAnd-shared/src/commonMain/kotlin/net/osmand/shared/gpx/GpxParameter.kt index d56235b79cf..487285c68f0 100644 --- a/OsmAnd-shared/src/commonMain/kotlin/net/osmand/shared/gpx/GpxParameter.kt +++ b/OsmAnd-shared/src/commonMain/kotlin/net/osmand/shared/gpx/GpxParameter.kt @@ -13,7 +13,6 @@ enum class GpxParameter( FILE_NAME("fileName", "TEXT", String::class, null, false), FILE_DIR("fileDir", "TEXT", String::class, null, false), TOTAL_DISTANCE("totalDistance", "double", Double::class, 0.0, true), - TOTAL_DISTANCE_WITHOUT_GAPS("totalDistanceWithoutGaps", "double", Double::class, 0.0, true), TOTAL_TRACKS("totalTracks", "int", Int::class, 0, true), START_TIME("startTime", "bigint", Long::class, Long.MAX_VALUE, true), END_TIME("endTime", "bigint", Long::class, Long.MIN_VALUE, true), diff --git a/OsmAnd-shared/src/commonMain/kotlin/net/osmand/shared/gpx/GpxTrackAnalysis.kt b/OsmAnd-shared/src/commonMain/kotlin/net/osmand/shared/gpx/GpxTrackAnalysis.kt index 999a843cad5..9db953765e8 100644 --- a/OsmAnd-shared/src/commonMain/kotlin/net/osmand/shared/gpx/GpxTrackAnalysis.kt +++ b/OsmAnd-shared/src/commonMain/kotlin/net/osmand/shared/gpx/GpxTrackAnalysis.kt @@ -24,6 +24,7 @@ class GpxTrackAnalysis { } var name: String? = null + var totalDistanceWithoutGaps = 0f var timeSpanWithoutGaps: Long = 0 var expectedRouteDuration: Long = 0 var timeMovingWithoutGaps: Long = 0 @@ -168,10 +169,6 @@ class GpxTrackAnalysis { get() = (getGpxParameter(GpxParameter.TOTAL_DISTANCE) as Double).toFloat() set(value) = setGpxParameter(GpxParameter.TOTAL_DISTANCE, value.toDouble()) - var totalDistanceWithoutGaps: Float - get() = (getGpxParameter(GpxParameter.TOTAL_DISTANCE_WITHOUT_GAPS) as Double).toFloat() - set(value) = setGpxParameter(GpxParameter.TOTAL_DISTANCE_WITHOUT_GAPS, value.toDouble()) - fun isTimeSpecified(): Boolean { val startTime = startTime val endTime = endTime @@ -298,7 +295,6 @@ class GpxTrackAnalysis { var totalSensorCadenceSum = 0.0 var _totalDistance = 0.0f - var _totalDistanceWithoutGaps = 0.0f points = 0 @@ -406,7 +402,7 @@ class GpxTrackAnalysis { distanceMovingOfSingleSegment = 0f } if (point.lastPoint) { - _totalDistanceWithoutGaps += distanceOfSingleSegment + totalDistanceWithoutGaps += distanceOfSingleSegment timeMovingWithoutGaps += timeMovingOfSingleSegment totalDistanceMovingWithoutGaps += distanceMovingOfSingleSegment } @@ -450,11 +446,8 @@ class GpxTrackAnalysis { } processElevationDiff(s) } - totalDistanceWithoutGaps = _totalDistanceWithoutGaps + totalDistance = _totalDistance - if(splitSegments.size == 1 && !splitSegments[0].segment.isGeneralSegment()) { - totalDistanceWithoutGaps = totalDistance - } checkUnspecifiedValues(fileTimeStamp) processAverageValues(totalElevation, elevationPoints, totalSpeedSum, speedCount) diff --git a/OsmAnd-shared/src/commonMain/kotlin/net/osmand/shared/gpx/filters/TrackFolderAnalysis.kt b/OsmAnd-shared/src/commonMain/kotlin/net/osmand/shared/gpx/filters/TrackFolderAnalysis.kt index be0613db818..3cfc13033a2 100644 --- a/OsmAnd-shared/src/commonMain/kotlin/net/osmand/shared/gpx/filters/TrackFolderAnalysis.kt +++ b/OsmAnd-shared/src/commonMain/kotlin/net/osmand/shared/gpx/filters/TrackFolderAnalysis.kt @@ -1,7 +1,6 @@ package net.osmand.shared.gpx.filters import net.osmand.shared.extensions.format -import net.osmand.shared.gpx.GpxParameter import net.osmand.shared.gpx.TrackItem import net.osmand.shared.gpx.data.TrackFolder import net.osmand.shared.gpx.data.TracksGroup @@ -35,10 +34,9 @@ class TrackFolderAnalysis(folder: TracksGroup) { var timeSpanSum = 0.0 for (trackItem in items) { val dataItem = trackItem.dataItem - val joinSegments = dataItem?.getParameter(GpxParameter.JOIN_SEGMENTS) == true val analysis = dataItem?.getAnalysis() if (analysis != null) { - totalDistanceSum += if (joinSegments) analysis.totalDistance else analysis.totalDistanceWithoutGaps + totalDistanceSum += analysis.totalDistance diffElevationUp += analysis.diffElevationUp diffElevationDown += analysis.diffElevationDown val file: KFile? = trackItem.getFile() diff --git a/OsmAnd/src/net/osmand/plus/configmap/tracks/viewholders/TrackViewHolder.java b/OsmAnd/src/net/osmand/plus/configmap/tracks/viewholders/TrackViewHolder.java index 0f4addf787f..7000e74ed10 100644 --- a/OsmAnd/src/net/osmand/plus/configmap/tracks/viewholders/TrackViewHolder.java +++ b/OsmAnd/src/net/osmand/plus/configmap/tracks/viewholders/TrackViewHolder.java @@ -24,7 +24,6 @@ import net.osmand.plus.shared.SharedUtil; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; -import net.osmand.shared.gpx.GpxParameter; import net.osmand.shared.gpx.TrackItem; import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.settings.backend.OsmandSettings; @@ -176,7 +175,7 @@ private void buildDescriptionRow(@NonNull TracksSortMode sortMode, @NonNull Trac } else if (sortMode == DURATION_ASCENDING || sortMode == DURATION_DESCENDING) { appendDurationDescription(builder, trackItem, analysis, shouldShowFolder); } else if (sortMode == NEAREST) { - appendNearestDescription(builder, trackItem, analysis, cityName); + appendNearestDescription(builder, analysis, cityName); } else if (sortMode == LAST_MODIFIED) { appendLastModifiedDescription(builder, trackItem, analysis); } @@ -198,7 +197,7 @@ private void setupIcon(Integer color, String width, boolean showArrows) { private void appendNameDescription(@NonNull SpannableStringBuilder builder, @NonNull TrackItem trackItem, @NonNull GpxTrackAnalysis analysis, boolean shouldShowFolder) { - builder.append(OsmAndFormatter.getFormattedDistance(getDistance(trackItem, analysis), app)); + builder.append(OsmAndFormatter.getFormattedDistance(analysis.getTotalDistance(), app)); if (analysis.isTimeSpecified()) { builder.append(" • "); appendDuration(builder, analysis); @@ -216,7 +215,7 @@ private void appendCreationTimeDescription(@NonNull SpannableStringBuilder build setupTextSpan(builder); builder.append(" | "); } - builder.append(OsmAndFormatter.getFormattedDistance(getDistance(trackItem, analysis), app)); + builder.append(OsmAndFormatter.getFormattedDistance(analysis.getTotalDistance(), app)); if (analysis.isTimeSpecified()) { builder.append(" • "); appendDuration(builder, analysis); @@ -232,7 +231,7 @@ private void appendLastModifiedDescription(@NonNull SpannableStringBuilder build setupTextSpan(builder); builder.append(" | "); } - builder.append(OsmAndFormatter.getFormattedDistance(getDistance(trackItem, analysis), app)); + builder.append(OsmAndFormatter.getFormattedDistance(analysis.getTotalDistance(), app)); if (analysis.isTimeSpecified()) { builder.append(" • "); appendDuration(builder, analysis); @@ -242,7 +241,7 @@ private void appendLastModifiedDescription(@NonNull SpannableStringBuilder build private void appendDistanceDescription(@NonNull SpannableStringBuilder builder, @NonNull TrackItem trackItem, @NonNull GpxTrackAnalysis analysis, boolean shouldShowFolder) { - builder.append(OsmAndFormatter.getFormattedDistance(getDistance(trackItem, analysis), app)); + builder.append(OsmAndFormatter.getFormattedDistance(analysis.getTotalDistance(), app)); setupTextSpan(builder); if (analysis.isTimeSpecified()) { @@ -253,12 +252,6 @@ private void appendDistanceDescription(@NonNull SpannableStringBuilder builder, appendFolderName(builder, trackItem, shouldShowFolder); } - private float getDistance(@NonNull TrackItem trackItem, @NonNull GpxTrackAnalysis analysis) { - GpxDataItem dataItem = trackItem.getDataItem(); - boolean joinSegments = dataItem != null && (boolean) dataItem.getParameter(GpxParameter.JOIN_SEGMENTS); - return joinSegments ? analysis.getTotalDistance() : analysis.getTotalDistanceWithoutGaps(); - } - private void appendDurationDescription(@NonNull SpannableStringBuilder builder, @NonNull TrackItem trackItem, @NonNull GpxTrackAnalysis analysis, boolean shouldShowFolder) { if (analysis.isTimeSpecified()) { @@ -266,14 +259,13 @@ private void appendDurationDescription(@NonNull SpannableStringBuilder builder, setupTextSpan(builder); builder.append(" • "); } - builder.append(OsmAndFormatter.getFormattedDistance(getDistance(trackItem, analysis), app)); + builder.append(OsmAndFormatter.getFormattedDistance(analysis.getTotalDistance(), app)); appendPoints(builder, analysis); appendFolderName(builder, trackItem, shouldShowFolder); } private void appendNearestDescription(@NonNull SpannableStringBuilder builder, - @NonNull TrackItem trackItem, @NonNull GpxTrackAnalysis analysis, @Nullable String cityName) { KLatLon latLon = analysis.getLatLonStart(); @@ -287,7 +279,7 @@ private void appendNearestDescription(@NonNull SpannableStringBuilder builder, builder.append(" | "); UpdateLocationUtils.updateDirectionDrawable(app, directionIcon, locationInfo, locationViewCache); } - builder.append(OsmAndFormatter.getFormattedDistance(getDistance(trackItem, analysis), app)); + builder.append(OsmAndFormatter.getFormattedDistance(analysis.getTotalDistance(), app)); if (analysis.isTimeSpecified()) { builder.append(" • "); appendDuration(builder, analysis); diff --git a/OsmAnd/src/net/osmand/plus/track/GpxBlockStatisticsBuilder.java b/OsmAnd/src/net/osmand/plus/track/GpxBlockStatisticsBuilder.java index 918618c3ba6..c8b330259ca 100644 --- a/OsmAnd/src/net/osmand/plus/track/GpxBlockStatisticsBuilder.java +++ b/OsmAnd/src/net/osmand/plus/track/GpxBlockStatisticsBuilder.java @@ -164,8 +164,7 @@ public void initItems(@Nullable GpxTrackAnalysis initAnalysis) { if (app == null || gpxFile == null) { return; } - GpxDisplayItem displayItem = getDisplayItem(); - boolean withoutGaps = !selectedGpxFile.isJoinSegments() && displayItem != null && displayItem.isGeneralTrack(); + boolean withoutGaps = false; if (initAnalysis == null) { withoutGaps = true; if (gpxFile.equals(app.getSavingTrackHelper().getCurrentGpx())) { @@ -174,6 +173,7 @@ public void initItems(@Nullable GpxTrackAnalysis initAnalysis) { withoutGaps = !selectedGpxFile.isJoinSegments() && (Algorithms.isEmpty(currentGpx.getTracks()) || currentGpx.getTracks().get(0).isGeneralTrack()); } else { + GpxDisplayItem displayItem = getDisplayItem(); if (displayItem != null) { analysis = displayItem.analysis; withoutGaps = !selectedGpxFile.isJoinSegments() && displayItem.isGeneralTrack();