I'm using the CLLocationManager in Swift.
When I display location.coordinate, it provides me with the result:
37.787358900000001, longitude: -122.408227
However, if I display. location.coordinate.latitude, the result is
37.7873589
Do you know how I can get all the decimals?
Thanks,
Thomas
You are seeing 37.787358900000001 instead of 37.7873589 because of the nature of representing floating point numbers in a computer.
That said, it is pointless to worry about decimal places beyond the 6th position because even changing the 9 to an 8 would result in a change of about 1 centimeter. The GPS system is currently accurate to about +/- 5 meters, and with new chips being deployed by Broadcom that can be reduced to about +/- 30 centimeters in the near future.
By the way, do you know why the altitude keeps updating/changing, even
when the device is standing still on a table?
Altitude calculations are done by computing the distance to the visible GPS satellites which orbit the Earth every 12 hours. Since the satellites are constantly moving, and different satellites come into view, these calculations do tend to fluctuate. This article though a bit dated is enlightening.
Related
I am programming an iPhone app in ios 6 where I obtain the heading information and then using simple calculations, I convert that information to words, as "You are facing west". Now my problem is, when I rotate my phone from (say) north to east, phone will point out: 1. You are facing north-east (3-4 times) then at last when the phone settles, it says 2. You are facing east. The problem is I am converting all the commands to speech, and it turns out to be confusing and disturbing.
One way is to increase the value of heading filter, but I can't do that since I need precision of 20 degrees. I tried to use timestamps of headings, but no use. I tried usleep() but no use since the entire program stops. Is there any way I could tell phone to take information at 1.5 seconds interval from location manager, or can the location manager itself be programmed to check for heading after the phone's rotation has stabilized.
Update: How I failed in using timestamps ->
Suppose I move my phone fast my north to east. The difference in stamps look like this:
(all values in seconds, this value can be arbitrarily large or even undefined since I am moving the phone for the first time, in this case, it is 10 seconds which indicates I rotated the phone from west to north 10 seconds before)
10, 0.0012, 0.012, 0.005 (phone settles and the location manager is not called again). I do not know how to detect that I should take the value corresponding to 0.005.
i am developing an app which is particularly dependent upon the distance between two iOS devices. I am using GPS location of devices to calculate the distance between them.
To calculate distance, i am using cllocation -distanceFromLocation method but the values generated by method is fluctuating and differs from actual distance between devices and cannot be considered even as an approximate result.
For example, if the actual distance between devices is 2 to 3 meters, it gives me the result around 14 meters at some point and 43 meters at another point. Is the the function -distanceFromLocation: is not so precise and accurate????
Is there any better alternative for calculating distance using GPS latitude and longitude of devices???
Please help me out.
Thanx in advance.
The accuracy of CoreLocation GPS varies greatly depending on your surroundings.
At it's most accurate it can go down to a couple of metres resolution (I'm not sure exactly) but if you're indoors it will be more like 20-50 metres.
I'm guessing that you're developing and testing the app indoors and so the fluctuations would be about normal.
Even outdoors in perfect weather CoreLocation will struggle to accurately tell you the distance between two devices over a short distance. (i.e. a couple metres).
For short range you might be better using wifi signal strength instead. Although this can also change from room to room.
Essentially, it's difficult to accurately detect the distance between two devices.
I am developing one iphone application which contains maps. Starting screen is navigation screen where user can select location, lets say florida. Now when User selects florida i want to pick up at least six random points (latitude and longitude of points so that I can put annotation) from florida only.
I do not have DB so that I can not fetch 5 points from DB for florida and place them.
Any ideas?
Thanks,
This is going to be quite hard if you don't have anything to tell you the shape and size of the area you are trying to produce random points within. Harikrishnan had given you a good start, though increasing the lat and long by 0.0001 each time is hardly random. At Florida's coordintes (28.0908° N, 81.9604° W according to Google) moving 0.0001 in both directions is only 14m away, so you're unlikely to leave Florida at that speed.
You could adjust Harikirshnan's method by using a random number instead of 0.0001, but you still need to know how big the area is that your user is looking at. Having 5 points all 14m when you're looking at a state, or even a city, is not much good.
Maybe you need to look more closely at what you are trying to achieve. If the points don't represent geographical data then why are you putting them on a map. If they do and they represent the entire area and not a single point then the best I can think of is to generate random points based on the maprect that Apple returns for the location the user has chosen. (roughly speaking that would be mapX = random*maprect.size.width + maprect.origin.x). And then incase you have an area like Florida that is not perfectly shaped like your MKMapView you'd need to reverse geocode to see if the point you picked really is within Florida (i.e. send the coords to Apple and check the address).
Or, you could consider now showing the data on the map
Try this
NSInteger i;
double offset=0.0001;
for(i=1;i<=5;i++){
double newlatitude=location.coordinate.longitude+offset;
double newlongitude=location.coordinate.longitude+offset;
NSLog(#"%f ,%f",newlatitude,newlongitude );
offset+=0.0001;
}
I made a simple app which displays the altitude according to the GPS position on iPhone.
How is the altitude obtained?
Does it get the altitude of the land at the coordinates I am or does it get the actual altitude? (I tried the same application in the same building; once at ground floor and once on the third floor but the same altitude is displayed)
Is it possible to obtain a different altitude on different floors? (Like my android phone has a barometer sensor and I calculate the elevation by the atmospheric pressure; but none of the iPhones has a barometer sensor)
The altitude as read by the gps receiver depends on the positions of the satellites over the horizon, relative to each other. It is possible then for the altitude reading to be unreliable when either there are not enough satellites in the sky or they are too close together. This then depends on the time of day, or date.
The signals from the satellites are very weak once they have reached the Earth's surface, and may not be received correctly inside buildings, or where there are other tall buildings nearby, such as a city centre like Manhattan.
Barometer readings will vary according to the weather and so an absolute reading can't be applied to a specific floor. However relative readings may be reliable enough for floor to floor changes, e.g. a lower value means going up.
Like any other device that uses GPS to calculate altitude, it's measuring the user's distance from the center of the satellites' orbits.
Your smartphone uses GPS technology to calculate your altitude depending on where you are. It measures how far away you are from the satilites which is calculating this information.
Note that newer IPhones (>= 6) have a barometer sensor which in my experience is significantly more accurate than GPS. With a barometers the accuracy appears to be within a foot whereas with GPS it would bounce around by 3-4 meters even when standing still.
http://www.iphonetricks.org/iphone-6-barometer-sensor-features/
Using iPhone's SDK GPS API, how accurate can I get? Is it within a few meters or kilometers? I'm interested in the accuracy when it is indoor. My software will only be used in door.
The best possible accuracy seems to be 9 meters. Common values (outdoor, good coverage) is 17 m, 23 m and 49 meters. With trees covering the sky you'll probably stay under a hundred meters, but hardly accurate enough for GIS or anything like that.
The API has a property or method that returns the current accuracy of the location measurement. If your goal is only to use the location if accuracy is within some limit then you should make sure that you check the returned accuracy, since the location may be only accurate to within a few thousand meters initially as its just using your location from the cell towers, and it will typically get better and better accuracy as the GPS powers up and starts getting a fix.
Most standard GPS chips (and the iphone is that) can get around 10 meters accuracy.
Best results are outside on a clear sky obviously.
The difference between GPS chips is usually how quickly they can reception and how well they can hold it. Accuracy is pretty constant except for those using WAAS sattelite (which the iphone GPS doesn't do)
Based on my own experience it's within meters.