I would like to log relative altitude changes on apple watch 3 using the CMAltimeter class. On simulator the isRelativeAltitudeAvailable() function returns false, so I tested on real device. Here I noticed, that information is provided, but by far too much alt meters (e.g. making 100-1000 m just by moving around on same level). What point I am missing?
- expecting that first point is 0
- following relativeAltitudes are changes relative to this in meters.
Thanks for you help!
You should use CLLocation see this for more information.
Related
I am developing a project in augmented reality where a compass shows the direction to the destination.That works fine but i want to check whether the current heading is pointing towards the destination or not.
Can any one suggest me a method to do it?
I have searched a lot in Google couldn't find any method?
Thanks in advance
You need the absolute bearing from your location to your target location
Unfortunately CLLocation doesn't have a call for this but you can find the algo in this question.
CLLocation Category for Calculating Bearing w/ Haversine function
So lets say the bearing is 90 degrees
Then you get the phone bearing to north.
While you are getting location updates you also have course update with CLLocation.
The course might also be 90 degrees
SO find the difference between the two, 90 - 90 = 0! you are dead on target :) You will need to rationalise the numbers to 0 - 360 in the event say you are facing north (0 degrees) and your target is behind you (180 degrees) resulting in -180. If you end up with a negative number just add 360.
I find the magnetic field compass to be very very fidgety, so it looks much nicer if you have some sort of exponential moving average for changes in the phones bearing.
I have create a program to find out my current location using IOS corelocation framework.It works fine.
I need to create a program that list nearest branchaes of a shop chain, while a user travel with the phone.My data base contains the branches details with Latitude and lognitude.How i compare with these details to find out the nearest branch.
Help is highly appreciated.Anybody knows any example program
Thanks,
VKS
You can make use of distanceFromLocation: method of CLLocation.
distanceFromLocation:
Returns the distance (in meters) from the receiver’s location to the
specified location.
(CLLocationDistance)distanceFromLocation:(const CLLocation
*)location
Parameters
location
The other location.
Return Value
The distance (in meters) between the two locations.
Discussion
This method measures the distance between the two locations by tracing
a line between them that follows the curvature of the Earth. The
resulting arc is a smooth curve and does not take into account
specific altitude changes between the two locations.
Availability
Available in iOS 3.2 and later.
By using this method to get the distances of the shops with your current location, you can then sort the list based on the distance to get the nearest branch
VKS, I got to solve the exact same problem too now (using apptarget iOS 5). Do you have any example code / snippets / tips to share for this problem, that I assumed you solved a long time ago? The above is very good explanation from 7KV7, but some examples will speed up my process a lot. Thank's :-)
I've a GPS tracker that now works great, except when iPhone lost GPS connection.
When the connection is lost, the track makes one or more points to a random location, as you can see in this image:
(source: alluneed.it)
In which way can I discard these bad values?
I've thought about doing it this way:
before save my data, I can do a sum of my integer values of current latitude and longitude and compare with integer values of my old latitude and longitude; if the difference is bigger than some value, I discard my data.
Will it be a good thing?
Are there some other nice tricks to do this?
maybe i've found my fault:
in
locationManager:didFailWithError:
when i receive a kCLErrorNetwork or any other error except kCLErrorDenied i perform a stopupdatinglocation and a startupdatinglocation.
Now the app works good, i make some other test tomorrow and post here the result.
Try to check the time of the location update while the GPS has no signal (the time is provided within the location parameter if I recall correctly).
Maybe the time is some constant , and that way you can check if the difference between the current time and the location time is more then some value, to know if the location is real or not.
You can sanity check points before using them. If the accuracy level suddenly jumps up and then back down again, you can throw away that one point. If the timestamp says the user is suddenly moving at supersonic speeds to get to the new location after calculating the distance over time from any previous points, then the point is likely bogus. etc.
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.
I'd like to use reliable locations, even on an old iphone. However, many readings (particularly from cell towers) are too inaccurate. I think.
When I plot my position + accuracy radius (or look at google maps app), I notice the center of the estimated circle is generally close to my physical location. I'm guessing that if I cut the "accuracy" number in half, I'll still be in the circle 99% of the time.
I believe this is a probabilistic game - the location manager is trying to provide an estimate that's correct 99.99999% of the time, so they give a deliberately wide margin. Any thoughts/info?
The CoreLocation framework gives you the radius of the circle for every CLLocation you get using the horizontalAccuracy/verticalAccuracy properties. You can specify to the CLLocationManager a desiredAccuracy property that use these types:
kCLLocationAccuracyNearestTenMeters, kCLLocationAccuracyHundredMeters, kCLLocationAccuracyKilometer, kCLLocationAccuracyThreeKilometers;
So you get notifications when you get inside your desired range. That said, when you use the CLLocationManager the first event is given to you ASAP, and then the proceeding events are the ones that satisfy your conditions.
When you're using CoreLocation, you're getting back "answers" that get better and better. I've noticed that the "best" answer is almost always accurate to within 100m, so theoretically you could probably cut down on the "buffer" that you're normally given. The only way to really know, though, and this is what I would do, is to test test test. Find iphones and ipods from all generations and see what types of accuracies you're getting and what types of results you're getting. In a lot of ways, it depends on the type of app you're making, but if you want to deliver sensitive or important information based on where the user is, you should really wait for the framework to give you a nearly exact location.