I have a collection with documents and each has a field array with polygons.
I want to test if my polygon geoIntersects any of those polygons. They are all box-shaped if it helps.
I will add bounty points if you add in the possibility of having my polygon in that array I'm testing. I wouldn't want it intersect with itself...
Cities:
{_id, buildings:[ {coo:{shape:"Polygon", coordinates:[ [0,0], [4,0], [4,5], [5,0],[0,0] ] }, {coo:{shape:"Polygon", coordinates:[ [0,0], [4,0], [4,5], [5,0],[0,0] ] } ] }}
Imagine I have around 100 or so elements in the array. I want to determine if, for a given shape, that might be included inside the array, if it intersects any or none of the other polygons (again, excluding itself it is in there).
This page will help you make the geospatial index on your compound spatial documents:
http://docs.mongodb.org/manual/core/geospatial-indexes/
And then you can use this page to figure out your query
http://docs.mongodb.org/manual/reference/operator/box/#op._S_box