Creating a location based reminder: what to do with horizontal accuracy? - iphone

I'm creating a location-based reminder, EKReminder.
For the coordinates I'm using CLGeocoder to convert an address into a CLLocation.
When it comes to the reminder itself, I think that there are two factors involved that determine the 'area' (radius/circle) in which the reminder will fire.
1) the Horizontal accuracy of the CLLocation.
The docs describe the horizontalAccuracy property as "The radius of uncertainty for the location, measured in meters. (read-only)".
There's more good information about this in a previous question:
What do horizontalAccuracy and verticalAccuracy of a CLLocation refer to?
As suggested in that answer, the horizontalAccuracy is 100m.
2) the radius property on the EKStructuredLocation. The discussion notes for this property read "To use the default radius, set this property to 0."
If I create a location-based reminder in the stock, Reminders app from Apple, it comes out with radius = 0 and horizontalAccuracy = 0. So it's using the default 'reminder radius' (don't know what that is) with a value of 0 for the uncertainty in the horizontal location...
I want to avoid having two margins in my reminder. I think there are two options to achieve this:
a) use the default radius for the EKStructuredLocation by setting it to 0 and change the result coming back from the CLGeocoder to have a horizontalAccuracy of 0m.
b) keep the horizontalAccuracy (100m, or different, depending on circumstance) from the CLGeocoder - but not use the default radius for the EKStructuredLocation and set it to something small, like 1m.
Thoughts? Am I understanding these APIs correctly?
Will I get a 'double margin' if I use the returned horizontalAccuracy and the default value for radius?
Does the horizontalAccuracy for the CLLocation object introduce a radius from the coordinate, or is it purely giving information about the uncertainty of the location?
Cheers

As pointed out by progmr, horizontalAccuracy is purely an estimate of the uncertainty in the location.
To back this up, I did a couple of real-world tests where:
I created a location-based reminder in the Reminders app, which has radius = 0 but also reports horizontalAccuracy = 0.
I created a reminder using the same location in my own code, setting radius = 0, but the return from CLGeocoder reporting horizontalAccuracy = 100
With each test, the reminders fired at exactly the same position. horizontalAccuracy is purely for information.

Related

How to detect the accuracy margin of error using Core Location

I have an app that tracks user location using the following:
locationManager.distanceFilter = kCLDistanceFilterNone;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
According to Apple's documentation, Core Location will try to obtain the best possible reading until I tell it to stop. However, I realize the reading can be impaired by many uncontrollable things i.e. weather, device in a building, etc.
For the purposes of my app, I would like to store how accurate the reading actually was. For example, if I am in a field, I may get a reading that is accurate up to 10 meters, but if I were in that same field during a thunderstorm, I may get a reading that is accurate up to 100 meters.
Is there a way to detect how accurate my reading actually is?
CLLocation (the object that gets returned from the CLLocationManager) contains two properties, horizontalAccuracy and verticalAccuracy.
This is a value measured in metres that tells you how many metres radius around the given location you could be.
You can read more about CLLocation here... CLLocation Class Reference
I believe this is what Apple uses in its maps app to place the circle around the location to represent the area you could possibly be in.

Geo Fencing Identifier

How to specify the entire country as a region in region identifier.Wether it will accept the
identifier as :#"Uk"
here the code to reo identifier.How can i specify England or UK.Please help me to sort out
CLLocationCoordinate2D location2D = mapView.region.center;
CLRegion *regionForMonitoring = [[CLRegion alloc] initCircularRegionWithCenter:location2D radius:1 identifier:#"RegionIdentifier"];
[[Utils getLocationManager] startMonitoringForRegion:regionForMonitoring];
CLRegions are totally unsuitable for this purpose.
First of all, the radius specified is the distance in meters that the region covers - so in your case you are asking the system to monitor a region at a specific lat/long with a radius of 1 meter!
Also, system regions have a maximum number of regions that can be monitored (around 10 or so), and a maximum radius that can be used of around 400 meters after which the region will not work.
You really need to read the "Monitoring Shape Based Regions" section of this Apple document:
http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/LocationAwarenessPG/CoreLocation/CoreLocation.html
There are two other possible approaches to what you are trying to do:
1) Use Significant Location Updates, and test on each update if you are in an area with a shape you specify.
2) Use CoreTelephony to look up the cell carrier your device is on and see if the carrier number matches one in the country of interest. Of course, this will not work on some iPads or other iOS devices with no cell connection.
Neither of those approaches will be exact around the edges, but will also not consume nearly as much battery life as using the GPS.

difference between desiredAccuracy and distanceFilter

Sorry for being a noob here. I am not able to clearly differentiate between CLLocationManager's properties distanceFilter and desiredAccuracy.
If I want my application to give different coordinates for even small distances (say 100-200 metres) what values should i set for these properties.
Help would be greatly appreciated.
According to developer.apple.com
distanceFilter
The minimum distance (measured in meters) a device must move laterally
before an update event is generated.
That means, based on previous location event, another location update will only be received after exceeding distanceFilter value distance.
desiredAccuracy refers to how accurate your location data should be.
For example if you wish to see the exact street you're on you a high accuracy value for this parameter. (kCLLocationAccuracyBest)
If you only wish to see the approximate area (such as in which neighbourhood you're in) you'd set a lower accuracy value for this param. (kCLLocationAccuracyThreeKilometers)
Choose this to suit your needs, however be aware that the more precise you wish to be and the more often you request updates, the more power it will drain from your device.
Hope this helps,
Vlad
distanceFilter - this is minimal distance which device should pass from previous location which was passed to delegate with ...didUpdateToLocation:... method. And as soon as distance reached location service will invoke ...didUpdateToLocation... again and so on.
desiredAccuracy - tells to location service how accurate coordinate you want and this is minimal location error radius. If value is very low (ex. 5) radio will try to use GPS hardware and will keep powering it up hardly to make it give most accurate location. If value is large,than system may decide to use data which was retrieved from WiFi hotspots location triangulation.

IOS Core location - Find out nearest branch

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 :-)

Finding GPS signal strength

Is there any way to get an iPhone's GPS signal strength? I'd like to make some kind of display like this:
If GPS = 0 or No Signal: color = red / Poor or No Signal
If GPS = <140 m Signal: Color Orange /Fair Signal
If GPS = >140 m Signal: Color = Green / Good or Excellent Signal
No public API exists for checking GPS signal strength but it doesn't sound like that is what you are really looking for anyway. You absolutely can check the accuracy of the locations returned by CoreLocation.
Look at CLLocation, it has horizontalAccuracy and verticalAccuracy properties which indicate how accurate the device believes that location fix to be.
You should concentrate mainly on the CLLocation attribute horizontalAccuracy.
This value represents the estimated accuracy related to the current latitude, longitude coordinate.
verticalAccuracy represents the accuracy in altitude / height.
Generally, GPS devices are not well suitable for accurate height measurement, so concentrate on the horizontal attributes.