为什么我的lineString没有在geoSwift中转换为mapShape?(仅在一次特定搜索中发生),可能是外部库错误?
我正在使用GEOSwift库: 我最好的猜测是,如果你看链接的字符串图像,它看起来好像不是一个正确的圆,所以它可能是库中的一个bug?但我一点也不确定 只有当我输入一个特定的行字符串时,我才有问题。 我的应用程序获取路线坐标数组,将它们转换为WKT字符串(表示一条线)。然后,它围绕这条线创建一个缓冲区,然后将其转换为mapShape 它运行良好,直到我搜索一条特定路线 它在这里失败了:为什么我的lineString没有在geoSwift中转换为mapShape?(仅在一次特定搜索中发生),可能是外部库错误?,swift,error-handling,geos,geoswift,Swift,Error Handling,Geos,Geoswift,我正在使用GEOSwift库: 我最好的猜测是,如果你看链接的字符串图像,它看起来好像不是一个正确的圆,所以它可能是库中的一个bug?但我一点也不确定 只有当我输入一个特定的行字符串时,我才有问题。 我的应用程序获取路线坐标数组,将它们转换为WKT字符串(表示一条线)。然后,它围绕这条线创建一个缓冲区,然后将其转换为mapShape 它运行良好,直到我搜索一条特定路线 它在这里失败了: func bufferPolyline(routeCoords: [CLLocationCoordin
func bufferPolyline(routeCoords: [CLLocationCoordinate2D], completion: @escaping (_ bufferCoordsArray: [LatLng]) -> ()) {
var wktString = ""
var i = 0
while i < routeCoords.count {
let lat = routeCoords[i].latitude
let lng = routeCoords[i].longitude
if i == routeCoords.count-1 {
let wktLast = " \(lng) \(lat)"
wktString += "\(wktLast)"
i += 1
}
if i >= 1 && i <= routeCoords.count-2 {
let wktMid = " \(lng) \(lat),"
wktString += "\(wktMid)"
i += 1
}
if i == 0 {
let wktFirst = "\(lng) \(lat),"
wktString += "\(wktFirst)"
i += 1
}
}
let linestring = Geometry.create("LINESTRING(\(wktString))")!
let string = linestring.buffer(width: 0.05)!
guard let shapeLine = string.mapShape() as? MKPolygon else {
preconditionFailure() // FAILURE HAPPENS HERE.
}
}
func-bufferPolyline(routewords:[cllocationcoordinae2d],completion:@escaping(uu-bufferCoordsArray:[LatLng])->()){
var wktString=“”
变量i=0
当我数的时候{
设lat=routeCoords[i]。纬度
设lng=routeCoords[i]。经度
如果i==routeCoords.count-1{
让wktLast=“\(lng)\(lat)”
wktString+=“\(wktLast)”
i+=1
}
如果i>=1&&i,您可以共享导致错误发生的routeCoords的输入值吗?您可以共享导致错误发生的routeCoords的输入值吗?