distanceFilter property use - objective-c

In the CLLocationManager class documentation, I find such explanation for the distanceFilter property:
This property is used only in conjunction with the standard location
services and is not used when monitoring significant location changes.
Can you please explain it?

In CLLocationManager, distanceFilter is used to notify changes when device has moved x meters. Default value is kCLDistanceFilterNone: all movements are reported.
From the docs
After returning a current location fix, the receiver generates update
events only when a significant change in the user’s location is
detected. For example, it might generate a new event when the device
becomes associated with a different cell tower. It does not rely on
the value in the distanceFilter property to generate events.
Start standard location services by calling the startUpdatingLocation
method. This service is most appropriate for applications that need
more fine-grained control over the delivery of location events.
Specifically, it takes into account the values in the desiredAccuracy
and distanceFilter property to determine when to deliver new events.
The precision of the standard location services are needed by
navigation applications or any application where high-precision
location data or a regular stream of updates is required. However,
these services typically require the location-tracking hardware to be
enabled for longer periods of time, which can result in higher power
usage.
That is why distanceFilter is used only in conjunction with the standard location services and is not used when monitoring significant location changes eg. desiredAccuracy or heading info.
This is because generally it is not really useful to know that a person has moved x meters. However, it is very valuable to know that a person has moved x meters in y heading with z accuracy.

Standard Location Changes: The regular GPS module is used. Battery intensive. If locationManager is your instance of CLLocationManager class start the service as follows
[locationManager startUpdatingLocation];
Significant Location Changes: Whenever the radio tower changes. Better for battery. Apple does not say that in the official documentation that is upon changes of radio towers but apparently that is what was said by Apple when the new feature came out.
[locationManager startMonitoringSignificantLocationChanges];
The property distanceFilter is disregarded by CLLocationManagerif you subscribe to significant location changes.

Related

Can I use only GPS to plot my current position instead of the cellular network

I am working on a scheduling and routing app that uses Google Maps to create my route to the appointment location. Upon arriving at the appointment location, the app sets up a geo-fence around that location. The app is designed to send an eta text to the next appointment when I leave out of the geo-fence. Since I am likely to drive through the geo-fence due to either missing the address or looking for a parking spot, I have a timer set for 3 minutes. This requires that I stay inside of the geo-fence for 3 minutes. Once the 3 minutes elapses, then the app is set to send my eta text to the next appointment once I leave out of the fence. My location on the map appears to be determined by the triangulation of the cell towers. Here's the problem, I'm testing in a rural area with poor cell signals and limited towers. This reduces the accuracy of my actual location as determined by the triangulation of the cell towers. It is causing the icon that represents my location to bounce in and out of the geo-fence without completing the 3 minute time requirement. This is most likely due to the poor cell connection and network. Is there a way for me use only the GPS feature of the phone/Google Maps and disable the cell network from trying to position me? This doesn't happen in urban areas where there are more towers and a strong network.

Ranging an iBeacon latency

I have been playing around with the new iBeacons in iOS 7. I have one device setup as a beacon, and the other device ranging to detect when I am near, far, immediate, etc. I'd like to know very quickly when I cross between these ranges. Is there any way to adjust the latency? I find that I have to move my device around very slowly or I will not know when I cross these thresholds.
No, you would not be able to adjust the beacon latency. As Apple says in Region Monitoring Guide:
To prevent spurious notifications, iOS does not deliver region
notifications until certain threshold conditions are met.
Specifically, the user’s location must cross the region boundary and
move away from that boundary by a minimum distance and remain at that
minimum distance for at least 20 seconds before the notifications are
reported.
Apple does not define what the latency is, it seems it's not fast enough for your application.
You can have a tradeoff - to implement beacon ranging yourself using Core Bluetooth and listen to the CBPeripheral advertisement events while scanning and range using RSSI:
centralManager:didDiscoverPeripheral:advertisementData:RSSI:
If you are using a custom beacon, such as the RadiusNetworks VirtualiBeacon VM image you can adjust the frequency of the advertisements. The flip side your app must run in the foreground opposed to CoreLocation delivering beacon events even when your app is not running.

CLLocationManager and distanceFilter?

i want to change the distanceFilter value on the basis of current speed. I try to change distanceFilter value after calling startUpdatinglocation on the basis of current speed, but it doesn't make any difference. Its giving location updates for every 10 meters because in starting i set distanceFilter value to 10. What i think i need to call stopUpdatingLocation and then startUpdatingLocation to make changes is distanceFilter value. But my concern is if i call stopUpdatingLocation and startUpdatingLocation frequently then will it drain more battery ? or in simple words if i try to start/stop GPS receiver more frequently then will it consume more power or not ?
yes it uses power to find satellites and lock on to them. I use a singleton for my location manager and it has a cllocation manager property I have tried to change to call
` [location.locationManager setDesiredAccuracy:100.0f];
[location.locationManager setDistanceFilter:100.0f];`
and Im not getting and errors so you can just change it on the fly

startMonitoringForRegion and iOS5: is accuracy better compared to iOS4?

Can this method use background GPS for this operation ?
I remember that on iOS4, the method was not very accurate (based on cell location)...
Any detailled information available ?
Short answer : No, but....
Long answer : Region monitoring works on cell+wifi analyzing by default , but by specifying a bigger radius , your app gets a callback (even if it's not suspended at the moment).
From my experience , you can use region monitoring just to cross a specific boundaries , and after entering a region you can "boost" location accuracy by using startUpdatingLocation + setting desired accuracy.
note: you should enter your code in application:didfinishLaunchingWithOptions as well , for the case where your app is not running, and of course stop updating location when crossing a boundary/recognizing an event that should return your app to previous "region monitoring" state, to conserve battery power.

Which gives a more accurate location?

Which of these two methods is the more accurate one in determining user location?
// First
[locationManager startUpdatingLocation]
// Second
[locationManager startMonitoringSignificantLocationChanges]
According to the Apple CoreLocation documentation, startUpdatingLocation is more accurate. From the documentation:
You start standard location services by calling the startUpdatingLocation method. This service is most appropriate for applications that need more fine-grained control over the delivery of location events. Specifically, it takes into account the values in the desiredAccuracy and distanceFilter property to determine when to deliver new events. This is most appropriate for navigation applications or any application where high-precision location data or a regular stream of updates is required.
Contrast this with startMonitoringSignificantLocationChanges, which, according to the documentation, is more coarse and less accurate:
For applications that do not need a regular stream of location events, you should consider using the startMonitoringSignificantLocationChanges method to start the delivery of events instead. This method is more appropriate for the majority of applications that just need an initial user location fix and need updates only when the user moves a significant distance. This interface delivers new events only when it detects changes to the device’s associated cell towers, resulting in less frequent updates and significantly better power usage.
You can control the accuracy of the location updates by using the desiredAccuracy property of the CLLocationManager class.
The first will give you updates in the desiredAccuracy set on the CLLocationManager class. Also note that the distanceFilter is also important.
The significant location changes only gets fired if you move a "significant" distance, meaning very few updates.
Find the documentation here: http://developer.apple.com/library/ios/#documentation/CoreLocation/Reference/CLLocationManager_Class/CLLocationManager/CLLocationManager.html