问题
I'm using the simulator to test region monitoring. Using CoreLocation
with region monitoring and the Freeway Drive test location path in the Simulator (Debug > Location > Freeway Drive) I'm able to simulate, at least visually the path of the Freeway Drive as it intersects with various overlays. Those overlays are converted to regions and monitored as soon as I start monitoring the user's location. Anyway, this doesn't seem to work very well. The regions represented by my overlays don't cause didEnter/didExit events when you "think" they would. The regions seem to be much wider in size than the distances I specified. I'm guess this is because of the cushion the system applies.
Apple's Region Monitoring documentation states that:
The system does not report boundary crossings until the boundary plus a system-defined cushion distance is exceeded. This cushion value prevents the system from generating numerous entered and exited events in quick succession while the user is traveling close the edge of the boundary.
The docs don't seem to state what this cushion is, exactly. Nor how it is calculated. Does anyone know what the system defined cushion is?
回答1:
I think it's 200m. At the bottom of the Region Monitoring documentation there's a paragraph that loosely explains how to test:
When testing your region monitoring code in iOS Simulator or on a device, realize that region events may not happen immediately after a region boundary is crossed. 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.
The specific threshold distances are determined by the hardware and the location technologies that are currently available. For example, if Wi-Fi is disabled, region monitoring is significantly less accurate. However, for testing purposes, you can assume that the minimum distance is approximately 200 meters.
来源:https://stackoverflow.com/questions/21297021/what-is-corelocations-region-monitoring-system-defined-cushion