GeoFire and non-point-based data

109 views
Skip to first unread message

Ab Scond

unread,
Nov 23, 2015, 6:24:00 PM11/23/15
to Firebase Google Group

(Is this the right place to ask GeoFire questions?)

If I understand it correctly, GeoFire allows you to store and query for 2D point-based data within a circle defined by a center and radius.

Can GeoFire also be used to store and query for 2D non-point based data?  For example, instead of a bunch of single points, I'd like to store a bunch of bounding boxes (ie: ((xmin, ymin), (xmax, ymax)).  Then I'd like to query to see which of those bounding boxes intersect with the circle.

Point-in-circle is a relatively simple operation.  Checking to see if a bounding box intersects with a circle is only slightly harder: you need to make sure that at least one of the four corners of the bounding box is in the circle.  So you take all 4 permutations of ((xmin, ymin), (xmax, ymax)) and see if any of them are in the circle.

Is this kind of thing supported by GeoFire right now?  Is it something GeoFire is considering in the future?

Thank you!

- Ab Scond

Ab Scond

unread,
Nov 23, 2015, 10:07:39 PM11/23/15
to Firebase Google Group
I knew I missed something.

I'm betting GeoFire doesn't support anything but point data, because the test isn't nearly as simple as I made it out to be.  Yeah, you can check to see if any of the corners of a bounding box are in the circle... but you also need to check if the circle is partially or fully in the bounding box.

You have to do this to handle cases like:
- The edge of the circle just crosses the edge of the bounding box, without the circle containing any of the corners,
- The circle is entirely inside the bounding box.

So, yeah, harder.

With just the corner test, GeoFire could have been modified to handle it.  But when you're doing a full circle-rectangle intersection test, it's going to be a lot harder to structure the data such it's searchable in Firebase to accommodate the test.  You can make it slightly simpler if you change the circle to be another rectangle (so you have a rectangle-rectangle intersection test)... but only slightly. 

Has anyone thought about how this might be done in Firebase?

Tom Larkworthy

unread,
Nov 24, 2015, 12:21:44 PM11/24/15
to Firebase Google Group
Hi Ab,

The fastest path for generalizing GeoFire would be to inflate the circle radius to encompass an arbitrary polygon and prune the events client side with a more accurate method. Or cover a polygon with several packed circles to reduce the false positive rate. 

I believe it is possible to do better but time consuming work, I don't think anyone has convincingly solved it yet. Developing collision detection libraries is hard. There is some discussion on general purpose collision detection on Firebase though here: https://mail.google.com/mail/u/0/#search/spatial++from%3A+me/14e74e130aed7a3e .


 

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/9f1e9b99-e6fa-4c3d-9124-00c71d333951%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Abscond

unread,
Nov 25, 2015, 4:29:35 PM11/25/15
to fireba...@googlegroups.com
Thanks for the info, Tom. I'd definitely like to learn more about what people have already done... Can you double check that link you posted to make sure it's right?

Thanks again!
You received this message because you are subscribed to a topic in the Google Groups "Firebase Google Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/firebase-talk/7vEnb91XfeI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to firebase-tal...@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages