diff --git a/Directory.Build.props b/Directory.Build.props
index 423df1b..76ca1ea 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -9,8 +9,8 @@
disable
latest
- 5.8.0
- 46
+ 5.8.1
+ 47
FitEdit
EnduraByte LLC 2024
diff --git a/Ui/FitEdit.Ui.iOS/Info.plist b/Ui/FitEdit.Ui.iOS/Info.plist
index ef1cd36..a97e3e9 100644
--- a/Ui/FitEdit.Ui.iOS/Info.plist
+++ b/Ui/FitEdit.Ui.iOS/Info.plist
@@ -7,7 +7,7 @@
CFBundleIdentifier
com.endurabyte.fitedit
CFBundleShortVersionString
- 5.8.0
+ 5.8.1
LSRequiresIPhoneOS
MinimumOSVersion
@@ -57,6 +57,6 @@
CFBundleVersion
- 46
+ 47
diff --git a/Ui/FitEdit.Ui/ViewModels/MapViewModel.cs b/Ui/FitEdit.Ui/ViewModels/MapViewModel.cs
index 04e4a19..9e71b03 100644
--- a/Ui/FitEdit.Ui/ViewModels/MapViewModel.cs
+++ b/Ui/FitEdit.Ui/ViewModels/MapViewModel.cs
@@ -408,19 +408,39 @@ private ILayer? AddTrace
int count = -1
)
{
- var range = Enumerable.Range(index < 0 ? 0 : index, count < 0 ? fit.Records.Count : count);
+ var range = Enumerable
+ .Range(index < 0 ? 0 : index, count < 0 ? fit.Records.Count : count)
+ .ToList();
Coordinate[] coords = range
.Select(i => fit.Records[i])
.Select(r => r.MapCoordinate())
- .Where(c => c.X != 0 && c.Y != 0)
.ToArray();
+ // Prevent zero lat lon
+ foreach (int i in range.Skip(1))
+ {
+ PreventZeroLatLon(coords, i);
+ }
+
return editable
? AddEditTrace(coords, name, color, FitColor.RedCrayon)
: AddTrace(coords, name, layer, color, lineWidth);
}
+ private static void PreventZeroLatLon(Coordinate[] coords, int i)
+ {
+ Coordinate coord = coords[i];
+ Coordinate prev = coords[i - 1];
+
+ const double tol = 1e-6;
+ if (Math.Abs(coord.X) < tol && Math.Abs(coord.Y) < tol)
+ {
+ coord.X = prev.X;
+ coord.Y = prev.Y;
+ }
+ }
+
private ILayer? AddTrace(Coordinate[] coords, string name, int layer, Avalonia.Media.Color color, int lineWidth)
{
if (coords.Length < 2) { return null; }