How can I get 5 decimal places of accuracy for latitude and longitude from locationservice?
Edit: Originally my question was "Why am I getting different lat and longitude readings at same exact spot when I query locationservices?" I have changed it now that I understand more about the issue.
I am using the script from https://docs.unity3d.com/ScriptReference/LocationService.Start.html . The only pertinent difference is I have commented out the first yield statement because it prevents the service from starting at all on iOS >= 10.3.1 as far as I can tell. I call the script from other scripts when things happen, like when the user taps a button. I also call it in one of the scripts' Awake() method to make sure iOS asks for the location permission when the app is first run. I call the script like so:
public string location = "not-yet-set location" ;
TestLocationService tls;
TestLocationService TLS = GetComponent<TestLocationService> ();
tls = TLS;
location = tls.locationString;
// (locationString is a concatenation of lat and lon in my TestLocationService script.)
The problem I am having is every time I open the app in the exact same location (at my desk) I get different readings. But if I move down the street, beyond the default 10 meters laterally, I still get the same reading from when I started the app.
What am I doing wrong?
Thanks!
Answer by agentargyle · May 23, 2017 at 05:23 PM
@Talimar solves it at the bottom of this post: https://forum.unity3d.com/threads/precision-of-location-longitude-is-worse-when-longitude-is-beyond-100-degrees.133192/
The solution is to use .ToString("R")
Done.
Answer by agentargyle · May 21, 2017 at 03:19 PM
I should add that I tried using 1 meter desiredAccuracyInMeters and .1 meters updateDistanceInMeters and it did not change the accuracy. I get up to 5 decimal places for latitude and only 4 for longitude.
So really my question is now:
How can I get 5 decimal places of accuracy for both lat and long? (Pretty sure that is what I need for my level of accuracy.
I think once I have that I can deal with the slight discrepancies programatically.
Thanks!
I don't think this answers it, since I can get 5 decimal places with latitude, just not longitude. But, apparently, the script Unity uses to get the data from the iOS device uses floats not double for the type so maybe that has something to do with it? https://forum.unity3d.com/threads/gps-float-precision-issue.275180/