iosswiftwatchkitcllocationdidfailwitherror

Why do I receive a wrong GPS position after didFailWithError?


I have developed an app for Apple Watch 2-3 that use the internal GPS to save the track and get speed, distance etc.

The app is written in Swift, XCODE 9 and using CLLocation.

Sometime CLLocation sends didFailWithError, the next 3-5 GPS locations are completely wrong, hundreds of meters far from the real point. I setup BestForNavigation and I check the horizontalAccuracy < 32m. I filter Locations in the past.

It happens mainly with the watch in the water, even a few centimeter.

Anybody experienced that?

Thanks


Solution

  • GPS satellite signals are pretty weak; They are transmitted from satellites orbiting about 20,000 km above you. To get an accurate fix a GPS receiver needs to get a signal from 4 satellites (a less accurate fix can be obtained using just 3 satellites).

    To make things worse, the watch has a fairly small GPS antenna and the microwave signals used by the GPS system are absorbed by things like buildings, trees, the human body and, especially, water.

    To be honest when you consider the difficulties, it is amazing that this little thing on your wrist can get a location at all, let alone to within 10 meters accuracy.

    You just have to do the best you can with the data you get.