I have stored polygons in a MongoDB database that cross over the X and Y axes and I want to search for polygons that contain a given point. To do so, I am using the $geoIntersects operator to specify a point, however, MongoDB does not return any polygons when they cross over an axis.
One of the objects in the collection:
{
"_id" : ObjectId("59caabf5f3c18e787b5df921"),
"polygons" : {
"type" : "Polygon",
"coordinates" : [
[
[
-100.31350135803223,
25.7219723533502
],
[
-100.31290054321289,
25.72386681990707
],
[
-100.31036853790283,
25.72332554682729
],
[
-100.31116247177124,
25.721102435127573
]
]
]
}
}
These coordinates correspond to a polygon surrounding this location, now, I'm querying to see if the stadium itself is inside the polygon (which it obviously is), like this:
db.testzones.find({
polygons:{
$geoIntersects:{
$geometry:{
"type" : "Point",
"coordinates" : [-100.312060, 25.722381]
}
}
}
});
But I'm not getting anything, however if I try with the exact data of this question's accepted answer I do get a result, notice the absence of negative coordinates, this is what leads me to believe that those are what cause the problem.
I found this question from last year (the problem is so similar to mine that I practically copied the title and the first paragraph) however it got no answer. Am I doing something wrong here? Or how could I go about solving this? I appreciate any help, I'm completely lost right now!