I have circular regions for a map (most have 30m radius). didEnterRegion
for the location manager trip in advance of entering the regions...
sometimes by many meters. Is there a way to enforce better accuracy? I
already use

locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation
locationManager.distanceFilter = kCLDistanceFilterNone

I have employed a little check that shows that indeed the userLocation is
NOT within the region when it's triggered for entry.

func locationManager(_ manager: CLLocationManager, didEnterRegion region:
CLRegion)
{
        var containsPoint = false
        var extraMessage = "Seems correct."
        if manager.location != nil
        {
            let locationCoordinate = manager.location!.coordinate
//userLocation
            let theRegion = region as! CLCircularRegion

            // + 50 below is to see if adding some to the radius helps.
Doesn't seem to.
            let circularRegion = CLCircularRegion(center: theRegion.center,
radius:theRegion.radius + 50 , identifier: theRegion.identifier)
            containsPoint = circularRegion.contains(locationCoordinate)

            let point1 = MKMapPointForCoordinate(locationCoordinate)
            let point2 = MKMapPointForCoordinate(theRegion.center)
            let distance:CLLocationDistance =
MKMetersBetweenMapPoints(point1, point2)
            let roundedDistance = Double(round(1000 * distance)/1000)
            let distanceString = "\(roundedDistance)m between points.
\(theRegion.radius)m radius."

            if containsPoint == false {
                extraMessage = "Doesn't seem accurate. \(distanceString)"
            }
        }
        ...

Since I need this to happen in the background or when the app isn't running
at all, I need to rely on didEnterRegion (startMonitoring for region). Do I
need to do something special?

Thanks,
Eric
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to