objective-cgeolocationcore-locationregion

How to detect if the current location is inside an area with CoreLocation


I want my application to know if the user is inside a particular area. I've been learning about geofences but I don't want the device to be constantly checking if it's entering or leaving an area, I just want to know if it's on it at that concrete moment. Plus, I've reading that geofencing has (it seems) low accuracy, and I need more than cellular tower precision.
So the idea is to do this using the "standard" kind of location, but I don't know how to, given a new current location, check if it's inside a (circular, rectangular, polygonal?) area.
It maybe has to be done using pure mathematics, checking if the altitude is between 2 parameters, and so for the longitude? Is there a simpler way?

Thanks!


Solution

  • Use CLLocations's distanceFromLocation

    http://developer.apple.com/library/ios/#DOCUMENTATION/CoreLocation/Reference/CLLocation_Class/CLLocation/CLLocation.html