Skip to content

Commit

Permalink
Merge pull request #20906 from osmandapp/show_sensor_data_recording_t…
Browse files Browse the repository at this point in the history
…rack

Show sensor data for recording track
  • Loading branch information
Chumva authored Sep 26, 2024
2 parents af053b3 + dacbbd4 commit ff5b7f9
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,7 @@ object GpxUtilities {
} else {
regularExtensions[key] = value
}
wptPt.getDeferredExtensionsToWrite()[key] = value
}
if (regularExtensions.isNotEmpty()) {
wptPt.setExtensionsWriter("extensions", createExtensionsWriter(regularExtensions, true))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import net.osmand.shared.util.KAlgorithms

open class GpxExtensions {
var extensions: MutableMap<String, String>? = null
var deferredExtensions: MutableMap<String, String>? = null
var extensionsWriters: MutableMap<String, GpxUtilities.GpxExtensionsWriter>? = null

fun getExtensionsToRead(): Map<String, String> {
Expand All @@ -18,6 +19,17 @@ open class GpxExtensions {
return extensions!!
}

fun getDeferredExtensionsToRead(): Map<String, String> {
return deferredExtensions ?: emptyMap()
}

fun getDeferredExtensionsToWrite(): MutableMap<String, String> {
if (deferredExtensions == null) {
deferredExtensions = LinkedHashMap()
}
return deferredExtensions!!
}

fun getExtensionsWritersToWrite(): MutableMap<String, GpxUtilities.GpxExtensionsWriter> {
if (extensionsWriters == null) {
extensionsWriters = LinkedHashMap()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import com.github.mikephil.charting.listener.OnChartGestureListener;
import com.github.mikephil.charting.listener.OnChartValueSelectedListener;

import net.osmand.plus.plugins.PluginsHelper;
import net.osmand.plus.settings.backend.preferences.CommonPreference;
import net.osmand.plus.settings.backend.preferences.ListStringPreference;
import net.osmand.shared.gpx.GpxFile;
Expand Down Expand Up @@ -174,7 +175,7 @@ private void updateAnalysis() {
if (isShowCurrentTrack()) {
GpxFile gpxFile = displayHelper.getGpx();
if (gpxFile != null && !gpxFile.isEmpty()) {
analysis = gpxFile.getAnalysis(0);
analysis = gpxFile.getAnalysis(0, null, null, PluginsHelper.getTrackPointsAnalyser());
gpxItem = GpxUiHelper.makeGpxDisplayItem(app, gpxFile, GPX, analysis);
}
} else if (getFilteredGpxFile() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ public static boolean hasTemperatureData(@NonNull GpxTrackAnalysis analysis) {
}

public static float getPointAttribute(@NonNull WptPt wptPt, @NonNull String key, float defaultValue) {
return Algorithms.parseFloatSilently(wptPt.getExtensionsToRead().get(key), defaultValue);
String value = wptPt.getDeferredExtensionsToRead().get(key);
if (Algorithms.isEmpty(value)) {
value = wptPt.getExtensionsToRead().get(key);
}
return Algorithms.parseFloatSilently(value, defaultValue);
}

public static void getAvailableGPXDataSetTypes(@NonNull GpxTrackAnalysis analysis, @NonNull List<GPXDataSetType[]> availableTypes) {
Expand Down

0 comments on commit ff5b7f9

Please sign in to comment.