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

Polygon shaped geoqueries #46

Open
sauravbiswasiupr opened this issue Sep 9, 2014 · 10 comments
Open

Polygon shaped geoqueries #46

sauravbiswasiupr opened this issue Sep 9, 2014 · 10 comments

Comments

@sauravbiswasiupr
Copy link

What about support for polygon based geoQueries ? The current API seems to provide support only for circular geoQueries.

@jwngr
Copy link

jwngr commented Sep 10, 2014

Hey @sauravbiswasiupr, mind sharing your use case? We have considered adding rectangular GeoQueries but didn't think there was enough demand for them. I'm interested to hear your thoughts though.

@jeffcjohnson
Copy link

I too would like polygon search and not just rectangular. I want to draw a polygon around a specific neighborhood and find only data in that polygon for example.

Also I would think rectangular search would be needed in the vast majority of apps that simply want to display data on the current map which is always rectangular.

If polygon search is too hard I could try using https://github.com/firebase/flashlight for polygon search but would much prefer geofire.

@sauravbiswasiupr
Copy link
Author

Hi @jwngr , sorry for the late reply. Basically consider searching for some location ( lat, lon) that lies inside a polygon of n sides, where n is a finite number. Like @jeffcjohnson mentioned, basically you could draw a polygon of n sides ( say 4 ) on the map, and get a list of vehicles ( or data that you might have stored), in the callback. I think this feature would be pretty cool.

@jwngr
Copy link

jwngr commented Oct 30, 2014

Thanks for the feedback guys. Polygon-shaped geoqueries are going to be tricky! I think we will most likely implement rectangular geoqueries in the next major release, but I'm not sure exactly how we would implement arbitrary polygon queries. We will definitely need to go back to the drawing board on that one.

If this is really something you want to see, this is an open source project and I would be more than happy to review some code you submit. This is definitely not a small thing to add, but if you need it/want to see it, feel free to throw some code around. I can answer any questions about the code that you have.

I'll keep this issue open until we add some more query types.

@cxz
Copy link

cxz commented Feb 14, 2015

I need to do polygon-based geoqueries too.

What do you think if we reduce this problem to:

  • find a rectangular/circle boundary for the polygon
  • use current geohash method to query for this boundary
  • post-process returned results with a PIP (point in polygon) algorithm?

@jwngr
Copy link

jwngr commented Feb 14, 2015

I think that kind of solution would work well in the average case. I unfortunately don't think I'll have a chance to implement this kind of functionality any time soon, but I would gladly review any PRs that come my way.

@stevepepple
Copy link

Here's an example of how to use Turf.js for reducing a query to a rectangle or polygon shape. Seems like this technique would work well in the Geofire library:
http://s.codepen.io/stevepepple/debug/ByVyYX?

Another option would be to take the area of your polygon (or the "extent" of the feature) and create a circle (query) around it.

@gigablox
Copy link

gigablox commented Oct 2, 2015

You guys are talking about a Ray-Casting algorithm found in Google Maps JS API - aka "point in polygon". I agree a feature like this would be absolutely killer.

https://developers.google.com/maps/documentation/javascript/examples/poly-containsLocation

@adamduren
Copy link

👍

@steffenfrost
Copy link

@gigablox , great suggestion.

Hi @jwngr , we are urrently at the Launch Hackathon, and we could use this feature. Can't you go visit your Google Maps colleagues and ask them how to do it? There a many geodata application which could use this feature.

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

No branches or pull requests

8 participants