【问题标题】:How to check if a location lies within the "accuracy" of the polygon.- e.g. if the accuracy of the function is 30m如何检查位置是否在多边形的“精度”范围内。-例如如果函数的精度是30m
【发布时间】:2017-06-26 03:03:21
【问题描述】:

这个功能是检查纬度或经度是否在多边形内部或外部。

 func isAvalibleinsidePolygone{
            let latitude = lat?.text
            let longitude = lon?.text
            if latitude != "" && longitude != "" {
                //            pathOfPolygon.removeAllCoordinates()
                for p in places {
                    pathOfPolygon.add(p.coordinate)
                }
    ifGMSGeometryContainsLocation(CLLocationCoordinate2DMake(Double(latitude!)!, Double(longitude!)!), pathOfPolygon, true) {
                    alert(title:`enter code here` "YEAH!!!", msg: "You are inside the polygon")

                } else {
                 alert(title: "OPPS!!!", msg: "You are outside the polygon")
                }
            }
        }

但即使我想检查一个位置是否在多边形的“准确性”之内 - 例如如果函数的精度为 30m,则多边形 30m 范围内的任何位置仍应返回 true。所以参数会像纬度,经度,准确度 例如:

func withinAccuracy(latitude:Double,longitude:Double,accuracy:Double){
//....
}

【问题讨论】:

  • 它对我有用。谢谢
  • 我很高兴听到这个消息。将评论作为答案发布,以便您接受。

标签: swift swift3 google-maps-sdk-ios


【解决方案1】:

看看函数 GMSGeometryIsLocationOnPathTolerance(_ point: CLLocationCoordinate2D, _ path: GMSPath, _ geodesic: Bool, _ tolerance: CLLocationDistance) -> Bool 它完全符合您的要求。 link

【讨论】:

    猜你喜欢
    • 2017-08-08
    • 1970-01-01
    • 1970-01-01
    • 2018-08-27
    • 1970-01-01
    • 2015-02-18
    • 2010-09-20
    • 1970-01-01
    • 2012-07-15
    相关资源
    最近更新 更多