Support Topics Documentation Slack YouTube Blog

iOS 13 Search in radius not working

Cant get search in radius to work on target platform iOS13
The response always return full list of the category"breadcrum" page by page.

The response doesn’t seem to be limited by radius :sob:

Here is my code to set up the query:

           firstResponse = true
           geoQuery.offset = 0
           geoQuery.categories = ["breadcrumb"]
           geoQuery.geoPoint = center
           geoQuery.pageSize = 50
           geoQuery.includemetadata = true
           geoQuery.radius = 1000
           geoQuery.setUnits(units:Units.METERS.rawValue)

Hello,

What SDK do you use, and what is its version?
Is this issue present on the earlier versions of iOS?

Regards,
Olha

The SDK version is 5.6.5
Sorry, I don’t know if it’s present on earlier iOS, as I just started trying to move to backendless :slight_smile:

I tired search in rectangle too, but it gave me a error: “The data couldn’t be read because it isn’t in the correct format”

Here is the code for rectangle:

let geoPoint1 = GeoPoint(latitude: (center.latitude+0.1).rounded(toPlaces: 2), longitude: (center.latitude-0.1).rounded(toPlaces: 2))
let geoPoint2 = GeoPoint(latitude:(center.latitude-0.1).rounded(toPlaces: 2), longitude: (center.latitude+0.1).rounded(toPlaces: 2))
geoQuery.rectangle = GeoQueryRectangle(nordWestPoint: geoPoint1, southEastPoint: geoPoint2)

It’s the backendlessswift sdk

We’ve created the internal ticket BKNDLSS-20099 to investigate this issue and will try to answer here as soon as possible.

Regards,
Olha

Issue with radius is fixed. Please try v5.6.6

I’ve set up the geoservice_sample catergory for my tests and everything works fine for me:

let geoQuery = BackendlessGeoQuery()
geoQuery.categories = ["geoservice_sample"]
geoQuery.geoPoint = GeoPoint(latitude: 40.37767, longitude: 49.89201)
geoQuery.radius = 1000
geoQuery.setUnits(units: Units.KILOMETERS.rawValue)
geoQuery.includemetadata = true
geoQuery.pageSize = 100

Backendless.shared.geo.getPoints(geoQuery: geoQuery, responseHandler: { geoPoints in
    print("Retrieved \(geoPoints.count) geoPoints:")
    for geoPoint in geoPoints {
        print("\(geoPoint.metadata ?? [String : String]())")
    }
}, errorHandler: { fault in
    print("Error: \(fault.message ?? "")")
})

Searching in rectangular area shoud work fine and this example works without any issues:

let nw = GeoPoint(latitude: 44.58883, longitude: 33.52240)
let se = GeoPoint(latitude: 40.18111, longitude: 44.51361)

let geoQuery = BackendlessGeoQuery()
geoQuery.categories = ["geoservice_sample"]
geoQuery.rectangle = GeoQueryRectangle(nordWestPoint: nw, southEastPoint: se)
geoQuery.includemetadata = true
geoQuery.pageSize = 100

Backendless.shared.geo.getPoints(geoQuery: geoQuery, responseHandler: { geoPoints in
	print("Retrieved \(geoPoints.count) geoPoints:")
    for geoPoint in geoPoints {
        print("\(geoPoint.metadata ?? [String : String]())")
    }
}, errorHandler: { fault in
    print("Error: \(fault.message ?? "")")
})

As for this error

The data couldn’t be read because it isn’t in the correct format

it seems like your nordWest and southEast points latitude and longitude are incorrect… what I mean to say - maybe your nordWest and southEast point are not actually nordWest and SouthEast.
my nw and se points belongs to Sevastoplol’ and Yerevan and they make the rectangle.

I assume something is incorrect in coordinates calculated here

let geoPoint1 = GeoPoint(latitude: (center.latitude+0.1).rounded(toPlaces: 2), longitude: (center.latitude-0.1).rounded(toPlaces: 2))
let geoPoint2 = GeoPoint(latitude:(center.latitude-0.1).rounded(toPlaces: 2), longitude: (center.latitude+0.1).rounded(toPlaces: 2))
geoQuery.rectangle = GeoQueryRectangle(nordWestPoint: geoPoint1, southEastPoint: geoPoint2)

Regards,
Olha