Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not a valid geo location for a huge radius #64

Open
zgosalvez opened this issue Sep 11, 2016 · 18 comments
Open

Not a valid geo location for a huge radius #64

zgosalvez opened this issue Sep 11, 2016 · 18 comments

Comments

@zgosalvez
Copy link

I'm making a global app that requires schools to be sorted from nearest to farthest, based on the user's location. To do this, I set geoFire.queryAtLocation(location, withRadius: 40075)

This causes a precision error ('Precision must be less than 23!') which I don't understand. So I reduced the radius to 4000. This time I'm getting a 'Not a valid geo location: [100.062421,-21.955856]' error. I hard coded the user's location to be somewhere in Iceland CLLocation(latitude: 63.8875517, longitude: -21.9558564)

It seems that this error shows up when the radius hits one of the poles, in this case the north pole, since I don't get the same error when I change the user's location to somewhere nearer the equator.

@JPROFFICIAL
Copy link

JPROFFICIAL commented Sep 13, 2016

Hey @zgosalvez, I had the same type of thing happen where I had to query a large radius, and what I ended up doing was using the GFRegionQuery. This fixed this issue from happening to me. If I am off and that is not the answer you're looking for, take a look at #27. Hope it helps!

@b992
Copy link

b992 commented Oct 8, 2016

+1

@ahaverty
Copy link

I'm hitting the same issues here in Ireland. The iOS app reviewers in Cupertino, CA are unable to view my locations and are failing the app review. I'm trying to set the radius to global but hitting the same precision error @zgosalvez hit. I need a quick fix before the reviews close for christmas, did you make any progress @zgosalvez , the GFRegionQuery @JPROFFICIAL suggested seems suitable for use with a map, but I'm only using the user's current location.

@zgosalvez
Copy link
Author

@ahaverty Sorry for not getting back to you sooner. This is the only time I got to go back to my project. I used region query instead of radius. This gives a bigger section of the globe without extending beyond acceptable values. The only drawback is that it still isn't the entire globe.

let span = MKCoordinateSpanMake(90 - userCurrentLocation.coordinate.latitude, 180 - userCurrentLocation.coordinate.longitude)
let region = MKCoordinateRegionMake(userCurrentLocation.coordinate, span)

regionQuery = geoFire!.query(with: region)

@Ekhoo
Copy link

Ekhoo commented Mar 29, 2017

@ahaverty did found a solution ?

@ahaverty
Copy link

Thanks @zgosalvez ! That's progress
@Ekhoo no other than limiting the distance. It's strange, as geofire android supports a full globe 🤔

@grantkemp
Copy link

grantkemp commented Apr 9, 2017

This is a breaking feature for one of my apps. Thanks for the span idea though.
@zgosalvez why did you use 90 - and 180 in to calculate the span?

@ThorvaldAagaard
Copy link

Anyone found a solution on IOS for this, where the entire world is covered?

@farzaa
Copy link

farzaa commented Feb 16, 2018

Any updates on this? When I run this code:

let loc = CLLocation(latitude: 28.548529, longitude: 81.194081)
guard let circleQuery = geofire.query(at: loc, withRadius: 10000) else { return }

I get the error

 *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Precision must be less than 23!'

I want to be able to query a region of 10,000 m around a user. The fix above using MKCoordinateSpanMake doesn't seem to fix this and will just query everything.

@beatTheSystem42
Copy link

beatTheSystem42 commented May 14, 2018

@farzaa
I ran into this issue, but was able to overcome it simply by dividing my radius by 1000.
I noticed in the GeoFire usage example they were representing 600 meters as 0.6 when initializing the circle query object.

let loc = CLLocation(latitude: 28.548529, longitude: 81.194081)
let rad = 10000
let circleQuery = geoFire.query(at: loc, withRadius: rad / 1000)

hope this helps.

https://github.com/firebase/geofire-objc

@VeganEngineer
Copy link

+FratGodLordOfBeer Hey...so this keeps the radius as 10000 units even though you're dividing rad by 1000? that is odd.

@LanceSamaria
Copy link

LanceSamaria commented Nov 3, 2018

Follow this guy's answer to get convert your miles to meters

1 mile is 1609.344 meters
To have your query coverage area match what's on your mapView you have double the number of miles then multiply it by meters

For eg. if the user choose 30 miles

let result = (30 * 2) * 1609.344

Use MKCoordinateRegionMakeWithDistance() to set your location and plug the result from above into it then use GeoFire's .query(with: region) to run the query

Basically set the region MKCoordinateRegionMakeWithDistance() into the .query(with: region)

// 1.
let searchRegion = MKCoordinateRegionMakeWithDistance(usersLocation.coordinate, result, result)
// 2.
geoFire.query(with: searchRegion)

For a more detailed answer Here's my SO question and answer

@vaibhav-jhaveri-ds
Copy link

vaibhav-jhaveri-ds commented Nov 19, 2019

@zgosalvez @LanceSamaria @Primate92587 @FratGodLordOfBeer @farzaa

Any solution for this other than limiting the radius?

@zgosalvez
Copy link
Author

@vaibhav-jhaveri-ds, the team decided to switch queries to Algolia, which allows for more complex queries on top of geo location.

@vaibhav-jhaveri-ds
Copy link

@zgosalvez Which product do you use in place of GeoFire?

@zgosalvez
Copy link
Author

@vaibhav-jhaveri-ds
Copy link

vaibhav-jhaveri-ds commented Dec 13, 2019

@morganchen12 Will there be any solution for this particular issue?

@nicooliver
Copy link

any update on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests