我在地理栅栏上工作,我必须做区域监测。我对geofence主题是个新手。我有bounds(最小-最大坐标)和geometry数据(所有位置坐标)。在下面的bounds中,我创建了CLCircularRegion。
"bounds":{"minlat":50.7238333,"minlon":-1.8716499,"maxlat":50.7248599,"maxlon":-1.8683962} 要初始化CLCircularRegion,我们需要center和radius。我已经使用以下公式计算了centerpoint:
center = CLLocationCoordinate2D(latitude: CLLocationDegrees((minLat + maxLat) / 2), longitude: CLLocationDegrees((minLng + maxLng) / 2))但是我不知道如何计算半径。你知道怎么做吗?
发布于 2020-05-28 16:20:50
你只需要计算从中心到一点的距离。使用CLLocation方法距离(从:)。您可以使用经度和纬度创建CLLocation实例。
https://stackoverflow.com/questions/62059706
复制相似问题