Skip to content

Commit

Permalink
Revert "#3533: Fixed getting track analysis; fixed display track info…
Browse files Browse the repository at this point in the history
… according to join segments setting"

This reverts commit a2fdd4f.
  • Loading branch information
Corwin-Kh committed Dec 18, 2024
1 parent a2fdd4f commit 813e982
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -298,7 +295,6 @@ class GpxTrackAnalysis {
var totalSensorCadenceSum = 0.0

var _totalDistance = 0.0f
var _totalDistanceWithoutGaps = 0.0f

points = 0

Expand Down Expand Up @@ -406,7 +402,7 @@ class GpxTrackAnalysis {
distanceMovingOfSingleSegment = 0f
}
if (point.lastPoint) {
_totalDistanceWithoutGaps += distanceOfSingleSegment
totalDistanceWithoutGaps += distanceOfSingleSegment
timeMovingWithoutGaps += timeMovingOfSingleSegment
totalDistanceMovingWithoutGaps += distanceMovingOfSingleSegment
}
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -35,10 +34,9 @@ class TrackFolderAnalysis(folder: TracksGroup) {
var timeSpanSum = 0.0
for (trackItem in items) {
val dataItem = trackItem.dataItem
val joinSegments = dataItem?.getParameter<Boolean>(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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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()) {
Expand All @@ -253,27 +252,20 @@ 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()) {
appendDuration(builder, analysis);
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();
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())) {
Expand All @@ -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();
Expand Down

0 comments on commit 813e982

Please sign in to comment.