Reputation: 1569
I have a collection that has a 2d geospatial index on a field (center) which is an array of long/lat, the collection also has a radius field. So each item can represent a circle. I know that mongodb has a operator $within, and I want to get a list of all items that contain a specific point [long,lat], but it seems that I can only check which points are within a specific shape.
Upvotes: 0
Views: 465
Reputation: 8500
This is how I solved it (i.e. get a shape that covers a given point) in my situation, using a basic grid. It has a limited accuracy, depending on the grid resolution:
To see in what shape(s) a point lies, search for the closest grid point, and return its assigned shape(s) property. First check for the common bounding box, because points outside it should always return 'not in any shape', and not use the closest grid point.
Depending on the precision you need, this might or might not be a usable solution. The accuracy depends on how many points you put in your grid, and you may be able to do something smart with local densities of your grid.
Upvotes: 0
Reputation: 36784
You are correct, right now, you can't do what you want. Please file a feature request at http://jira.mongodb.org as I can't find one already existing for this.
Upvotes: 2