Skip to content

Commit

Permalink
Merge branch 'master' of github.com:osmandapp/OsmAnd
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-osm committed Sep 26, 2024
2 parents a42f1f7 + 8b20df1 commit 895fe35
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 4 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
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
});
Expand Down

0 comments on commit 895fe35

Please sign in to comment.