diff --git a/OsmAnd-shared/src/commonMain/kotlin/net/osmand/shared/gpx/GpxUtilities.kt b/OsmAnd-shared/src/commonMain/kotlin/net/osmand/shared/gpx/GpxUtilities.kt index 2ac69d55e8c..84b2911dd59 100644 --- a/OsmAnd-shared/src/commonMain/kotlin/net/osmand/shared/gpx/GpxUtilities.kt +++ b/OsmAnd-shared/src/commonMain/kotlin/net/osmand/shared/gpx/GpxUtilities.kt @@ -747,6 +747,7 @@ object GpxUtilities { } else { regularExtensions[key] = value } + wptPt.getDeferredExtensionsToWrite()[key] = value } if (regularExtensions.isNotEmpty()) { wptPt.setExtensionsWriter("extensions", createExtensionsWriter(regularExtensions, true)) diff --git a/OsmAnd-shared/src/commonMain/kotlin/net/osmand/shared/gpx/primitives/GpxExtensions.kt b/OsmAnd-shared/src/commonMain/kotlin/net/osmand/shared/gpx/primitives/GpxExtensions.kt index 167cadebf23..7c1ad4ffa4c 100644 --- a/OsmAnd-shared/src/commonMain/kotlin/net/osmand/shared/gpx/primitives/GpxExtensions.kt +++ b/OsmAnd-shared/src/commonMain/kotlin/net/osmand/shared/gpx/primitives/GpxExtensions.kt @@ -5,6 +5,7 @@ import net.osmand.shared.util.KAlgorithms open class GpxExtensions { var extensions: MutableMap? = null + var deferredExtensions: MutableMap? = null var extensionsWriters: MutableMap? = null fun getExtensionsToRead(): Map { @@ -18,6 +19,17 @@ open class GpxExtensions { return extensions!! } + fun getDeferredExtensionsToRead(): Map { + return deferredExtensions ?: emptyMap() + } + + fun getDeferredExtensionsToWrite(): MutableMap { + if (deferredExtensions == null) { + deferredExtensions = LinkedHashMap() + } + return deferredExtensions!! + } + fun getExtensionsWritersToWrite(): MutableMap { if (extensionsWriters == null) { extensionsWriters = LinkedHashMap() diff --git a/OsmAnd/src/net/osmand/plus/myplaces/tracks/dialogs/GPXItemPagerAdapter.java b/OsmAnd/src/net/osmand/plus/myplaces/tracks/dialogs/GPXItemPagerAdapter.java index 180f53ad299..c205302234f 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/tracks/dialogs/GPXItemPagerAdapter.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/tracks/dialogs/GPXItemPagerAdapter.java @@ -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; @@ -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) { diff --git a/OsmAnd/src/net/osmand/plus/plugins/externalsensors/SensorAttributesUtils.java b/OsmAnd/src/net/osmand/plus/plugins/externalsensors/SensorAttributesUtils.java index 6a52a882455..d3c36b73b25 100644 --- a/OsmAnd/src/net/osmand/plus/plugins/externalsensors/SensorAttributesUtils.java +++ b/OsmAnd/src/net/osmand/plus/plugins/externalsensors/SensorAttributesUtils.java @@ -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 availableTypes) { diff --git a/OsmAnd/test/java/net/osmand/test/activities/GPXTrackAnalysisUpdatesTest.java b/OsmAnd/test/java/net/osmand/test/activities/GPXTrackAnalysisUpdatesTest.java index f5dd4262835..41efdaadf1c 100644 --- a/OsmAnd/test/java/net/osmand/test/activities/GPXTrackAnalysisUpdatesTest.java +++ b/OsmAnd/test/java/net/osmand/test/activities/GPXTrackAnalysisUpdatesTest.java @@ -171,8 +171,9 @@ public boolean isCancelled() { @Override public void onGpxDataItemReady(@NotNull GpxDataItem item) { - if (analysis != item.getAnalysis()) { - throw new AssertionError("To many updates of analysis "); + GpxTrackAnalysis trackAnalysis = item.getAnalysis(); + if (analysis != null && trackAnalysis != null && analysis != trackAnalysis) { + throw new AssertionError("To many updates of analysis"); } } });