I've stuck with a problem of matching items inside a polygon (simple box). I can't figure out why the item which is inside the queried box is not resulting. So here what i have:
>db.testing.getIndexes();
{
"0" : {
"v" : 1,
"key" : {
"_id" : 1
},
"ns" : "test.testing",
"name" : "_id_"
},
"1" : {
"v" : 1,
"key" : {
"point" : "2dsphere"
},
"ns" : "test.testing",
"name" : "2dsphere_index"
}
}
Here is my documents (i've tested different formats):
>db.testing.find();
{
"_id" : ObjectId("5439c9c61120c95f4c50a369"),
"point" : {
"lng" : -80.087535,
"lat" : 42.054246
}
}
{
"_id" : ObjectId("5439cc6d1120c95f4c50a36a"),
"point" : {
"type" : "Point",
"coordinates" : [
-80.087535,
42.054246
]
}
}
And here is query:
>db.testing.find({"point": {"$geoWithin": {
"$geometry": {
"type": "Polygon",
"coordinates": [
[
[-80.267831,42.050312],
[-80.267831,45.003652],
[-73.362579,45.003652],
[-73.362579,42.050312],
[-80.267831,42.050312]
]
]
}
}}})
But the problem is that it returns zero results!
If you not sure, that point is really in square, than copy this:
{"type":"GeometryCollection","geometries":[{"type":"Point","coordinates":[-80.087535,42.054246]},{"type":"Polygon","coordinates":[[[-80.267831,42.050312],[-80.267831,45.003652],[-73.362579,45.003652],[-73.362579,42.050312],[-80.267831,42.050312]]]}]}
and check it here.
I'm confused, could somebody help me with this please?
Thanks in advance!
Update:
Also, those points is got found when we decrease polygon area, for example, to:
[[-80.159937,42.050312],[-80.05204,42.050312],[-80.05204,42.09646],[-80.159937,42.09646],[-80.159937,42.050312]]
If it's needed i could provide like 100 of such points. For example one more strange point:
{"type":"Point","coordinates":[-76.537071,42.058731]}
Update:
Here is a file with points collection dump (around 700 points).