Select to view content in your preferred language

Improving GPS accuracy in .NET MAUI mobile app

493
6
Jump to solution
4 weeks ago
KevinCheriyan
Frequent Contributor

I have a mobile application built in .NET MAUI that has a hike tracking feature. Basically, the goal is to show the traversed path as a polyline on the map. This is the basic code I'm using to perform the calculation and do tracking using Maps SDK

 

MapPoint mp = e.Position; // e = Esri.ArcGISRuntime.Location.Location from location changed event
mp = (MapPoint)GeometryEngine.Project(e.Position, SpatialReferences.WebMercator);
polylineBuilder.AddPoint(mp);
trackedHikePolylineGraphicsOverlay.Graphics.Add(new Graphic(polylineBuilder.ToGeometry()));

 

I'm essentially adding the user's current location from the location changed event to the polyline builder and updating the graphics overlay. Nothing complicated. 

My problem is that when this is tested in the field, I end up with wildly zigzagging polylines because location gets miscalculated at times by the GPS. How do ESRI apps and even apps like Strava track breadcrumb path and show that on a map without erratic lines? I realize it is not a hardware problem, because other tracking apps on the same device can record a reasonably well polyline for the same activity. 

Thanks!

 


--------------------------------------------------
Application Developer, GeoMarvel
0 Kudos
1 Solution

Accepted Solutions
dotMorten_esri
Esri Notable Contributor

Yes that's one thing you can do. You can also look at the `AdditionalSourceProperties` dictionary which will tell you a little more about how the location was obtained. See https://developers.arcgis.com/net/api-reference/api/android/Esri.ArcGISRuntime/Esri.ArcGISRuntime.Lo...

Specifically the 'positionSource' key. Sometimes you might get a wifi or IP based location that you would want to ignore depending on use-case (note though that that should only happen if the device haven't been able to get a good GPS position in a while or the GPS position is estimated to be really really poor).

I would be careful with using simplify. It could preserve points that are very much off-center and should at least be weighted against estimated accuracy.

On a last note the Maps SDK doesn't do anything "smart" with the location (apart from switching between IP/Wifi and GPS positions as needed). It reports the GPS location as-received from the device.

View solution in original post

6 Replies
GKmieliauskas
Esri Regular Contributor

Hi,

You can use DGPS (Differential GPS) to improve your accuracy. I think, you could simplify your GPS data as suggested here. ArcGIS geoprocessing tool Simplify Line can help you, but it needs standard or advanced license. Ramer-Douglas-Peucker line simplification code you can find by web search or click on link

KevinCheriyan
Frequent Contributor

Thank you! This is incredibly helpful. There is indeed a Simplify method for Maps SDK for .NET I could use in conjunction with the RDP algorithm.


--------------------------------------------------
Application Developer, GeoMarvel
0 Kudos
dotMorten_esri
Esri Notable Contributor

You can use the HorizontalAccuracy property of the location to check if you're getting a bad measurement and ignore it.

KevinCheriyan
Frequent Contributor

Thanks @dotMorten_esri . Is HorizontalAccuracy something I have to test on the field with trial and error to see what the appropriate threshold is for different devices and platforms? Or is there a generally accepted accuracy to check against? 


--------------------------------------------------
Application Developer, GeoMarvel
0 Kudos
dotMorten_esri
Esri Notable Contributor

Yes that's one thing you can do. You can also look at the `AdditionalSourceProperties` dictionary which will tell you a little more about how the location was obtained. See https://developers.arcgis.com/net/api-reference/api/android/Esri.ArcGISRuntime/Esri.ArcGISRuntime.Lo...

Specifically the 'positionSource' key. Sometimes you might get a wifi or IP based location that you would want to ignore depending on use-case (note though that that should only happen if the device haven't been able to get a good GPS position in a while or the GPS position is estimated to be really really poor).

I would be careful with using simplify. It could preserve points that are very much off-center and should at least be weighted against estimated accuracy.

On a last note the Maps SDK doesn't do anything "smart" with the location (apart from switching between IP/Wifi and GPS positions as needed). It reports the GPS location as-received from the device.

KarenRobine1
Regular Contributor

I'm playing around with HorizontalAccuracy right now when saving my GPS coordinates to generate a track.  Currently I'm testing a Horizontal Accuracy of around 10.  I've noticed that when things are going well, HorizontalAccuracy is set to closer to 5.  Originally I had it set to 20, but then I get erratic behavior as you mentioned above.

0 Kudos