Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Query keys within an arbitrary shape? #17

Open
janakagamini opened this issue Apr 5, 2016 · 8 comments
Open

Query keys within an arbitrary shape? #17

janakagamini opened this issue Apr 5, 2016 · 8 comments

Comments

@janakagamini
Copy link

This might be a stretch, but in addition to querying for keys within a radius, will it be possible (in the future perhaps) to query for keys within an arbitrary shape (possibly defined as a list of GeoLocations)?

E.g. usage: Check if a point is within a certain city (given that I know a list of GeoLocations that outlines the city).

@jwngr
Copy link

jwngr commented Apr 5, 2016

Thanks for the feature request! It is pretty much equivalent to firebase/geofire-js#46. Unfortunately, I don't see this happening any time soon unless someone from the community wants to take a crack at it and send us a PR.

@janakagamini
Copy link
Author

Yes, exactly that. I'll give it a try. From a cursory glance at the code it seems I should probably be looking at private boolean locationIsInQuery(GeoLocation location) @ GeoQuery.java

Shout out if I'm way off. Thanks :)

@jwngr
Copy link

jwngr commented Apr 6, 2016

Yup, that is the right place. Thanks for taking a crack at this!

A couple notes:

  • You will also need a new constructor since the current one just takes a center and radius. You will need a constructor which takes in the coordinates for the arbitrary shape of our GeoQuery.
  • You will need to update locationIsInQuery() to do something different depending on if it's a circular GeoQuery or a polygonal GeoQuery. Defining Firebase queries for a polygonal GeoQuery will be tough (which is why we haven't tackled it yet) and may end up be wildly inefficient, but hopefully you can figure out the math behind it!

@janakagamini
Copy link
Author

Thanks for the tips jwngr, I will certainly try, but I can't guarantee anything.

@vanniktech
Copy link
Contributor

The objective C implementaton for geofire has support for bounding boxes AFAIK.

@samtstern
Copy link
Contributor

@vanniktech that's good to know. We can use that code as a reference.

@samtstern
Copy link
Contributor

I think it would be reasonable to try and support bounding boxes, but I don't think we should get into the math of doing arbitrary polygonal geo computations in this library. It's probably much better for everyone to just use a bounding box and then use some client-side logic to narrow that down to the polygon.

@vanniktech
Copy link
Contributor

Totally agree, bounding box and circular shape should be good enough.

@samtstern samtstern added the api label Nov 27, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants