Note, this other question is not what I'm looking for. It is looking for all points within the intersection of two queries. I merely want to check to see if two circles/polygons intersect in the first place.
My application allows users nearby to meet in person. When users sign up for my application, they provide their location. Thereafter, they define a circle of a particular radius within which they might be willing to meet other users. That is, they tell my server the radius, and it can use that later with
When a user searches for users to meet near them, I want to return all those users whose radius within which they will be willing to meet intersects the radius of the user making the search.
That is, suppose, in the diagram below, the circles represent radii within which Users Alice, Bob, and Charlie will be willing to meet, respectively.
If User Alice searches for nearby users, she should see Charlie as a result, but not Bob, for the bounds of Alice and Bob intersect. If Bob searches for nearby users, he will see Charlie, but not Alice. Finally, if Charlie searches for nearby users, he will see both Alice and Bob.
I'm wondering if it is possible to perform this kind of query with MongoDB.
Here is a potential approach I had figured. When a user defines a meeting area (choosing the radius based on their location), approximate that circle to a polygon - with more than 32 edges, for example. Store that polygon as GeoJSON in the user's document.
When another user is making a search, query for
$centerSphere, which should return all users whose intersects the center sphere. Does that sound right?