
We planned to create an application for search games - games in which you need to find places in the real world.
The first thing we needed was a precise tool for collecting points and creating routes. A simple indication of them on the map did not fit, because the error of the geotags reaches 200 meters - a person could come to the coordinates in search of a small thing, but it turned out that there were hundreds of steps to the place. In order not to force users to roam, it was decided to develop a system for removing coordinates by phones right on the spot.
Having experience in developing such a system for Android and having suffered from its geolocation services, we assumed that it would be easier to do this on iOS (iPhones seem to be very similar) and more precisely (ideally, we should not be afraid to drop an iPhone in the forest, then to find it compass).
To test these assumptions, we wrote a prototype that led the user to the point where the coordinates were removed, and at the same time made interesting conclusions about the accuracy of the built-in compass and GPS.
Coordinate Accuracy
Our checks showed that the maximum accuracy of GPS on different iPhones is different, after all, chip makers are not standing still.
Here is the maximum accuracy we received in good reception conditions:
- iPhone 3Gs - 17m,
- iPhone 4 - 10m,
- iPhone 4s and 5 - 5m (does GLONASS affect ?!).
We asked this accuracy for the phone itself via location.horizontalAccuracy, and the location was obtained from the LocationManager at the maximum accuracy and update frequency. All of this was pretty good.
Many instructions write that good conditions also imply the absence of trees. But our summer tests in the coniferous-deciduous forest did not show any noticeable deviations.
It was interesting to understand how iPhones give coordinates where GPS is not received. There are no surprises here.
There are quite a few good articles that describe how GPS and geolocation work in smartphones in the absence of GPS.
An example from Yandex .
It turns out that when the phone does not catch GPS, then in the location.horizontalAcuracy is issued ± 1414 meters, using information from the operator’s base station. Such accuracy is produced by GSM networks.
If there are Wi-Fi points nearby, in accordance with which geographic coordinates are established, then, as a rule, the accuracy increases to hundreds of meters, if there is one Wi-Fi point, or tens of meters, if there are several of them.
We did not notice the difference between the iPhone 4S and 5, but we noticed that they update the location much more often. Therefore, when approaching the point taken, it is possible to see how the figure showing the distance to the target decreases (30, 29, 28 ...). This creates a pleasant feeling of coming to success.
')
Direction

Further, in order to bring a person to a place, besides the coordinates of the destination point, you also need to know the direction in which to go. We do not consider the task of carrying a person through the transport network, as navigators do, we solve the problem of bringing a person to a place, even if we do not know anything about the transport networks surrounding him.
To display an arrow pointing to a place, information about the orientation of the phone relative to the North Pole is used. This information is given by the device’s compass, which appeared in iPhones, starting with the 3GS.
On this we built a compass navigator, the arrow which indicates the place.
What can be improved
Interestingly, compass accuracy is the bottleneck of the entire guidance system.
We can arbitrarily know how we are moving at the moment, but in order to show this information to the user in the form of an arrow, it is necessary to understand as accurately as possible the orientation to the north of the apparatus itself. Although the compass does not have zones where it does not work, but it readily responds to various interferences and anomalies, as well as tilt angles of the device, and this is especially noticeable in motion. We decided to fight this problem.
For clarification, a travel angle, or location.course, was used, speaking in terms of the iOS API. This allowed to significantly increase the accuracy of the compass in motion.
But there were problems. The amendment works on the assumption that people walk with the phone, holding its upper side forward (according to the results of various experiments, we realized that this is true for foot iPhones, for example). But if a person travels by car or public transport, then the situation when the phone is located sideways relative to the direction of movement occurs much more often. Therefore, the amendment must be disabled:
- at high speed (since the phone quickly flies over various interferences and anomalies and reacting to them means interfering with interference);
- if the amendment is more than 75gr. (because here you have to shrug it off, you can hardly offer something more precise).
There are, of course, more sophisticated methods for clarifying the readings of the arrow — you can implement the real dead run (link that you haven’t yet found). But we hope that this task will be better solved by iron producers. Yes, and our testing showed that the compass, with minor programmatic amendments, performs its function - it leads a person to the place.
Experiment
To check the accuracy of the prototype, we decided to conduct a small experiment (oh, how many experiments we conducted).
Belief in the reliability of the developed prototype caused controversy in the team. Therefore, the colleague who most believed in him (he developed it) dared to bury his iPhone in the forest as evidence of its reliability (nothing unusual, this is what everyone does). He left with two devices, took the place and, returning, gave one iphone to me.
I walked through the forest, following the arrow on the screen. When the screen showed the remaining distance of 0 meters, I looked down and saw the photographed place. It turned out that a colleague decided not to risk his phone, but put on a dummy (scoundrel), but the experiment was certainly a success.

This prototype turned out to be a useful application for sharing sites, but it is a topic for another post.
UPDA small addition, in response to comments received.
We did not seek to compare the GPS iPhon readings with any reference values.
We tried to evaluate the results obtained from different iPhons, who were in the same situation, but at different times.
We investigated how the results of the first measurement differ from the results of subsequent ones made on similar or identical phones.
Dozens of tests were conducted in different conditions. Briefly summarize the experience obtained in two sentences:
- If you remove the coordinates on one phone, and come to them with the help of another, then under good conditions, you'll be at a distance of 3-10 meters from the target.
- The value of location.horizontalAccuracy fairly accurately reflects reality, assuming that it shows the maximum distance to a point obtained using another phone.