Currently, a 2dsphere-indexed collection has the following behavior:
> db.geo.ensureIndex({geo: "2dsphere"});
> db.geo.insert({geo:{ type: "Point", coordinates: [ -73.97, 40.77 ] }})
> db.geo.findOne({geo:{ "$geoWithin" : { "$centerSphere" : [ [ NaN, 4 ], Infinity ] } }});
2015-01-15T16:35:01.239-0500 I QUERY Error: error: {
"$err" : "Can't canonicalize query: BadValue longitude/latitude is out of bounds, lng: nan lat: 4",
"code" : 17287
}
at Error (<anonymous>)
at DBQuery.next (src/mongo/shell/query.js:259:15)
at DBCollection.findOne (src/mongo/shell/collection.js:187:22)
at (shell):1:8 at src/mongo/shell/query.js:259
Which makes sense! However, if instead of using $centerSphere we use $center as the query specifier:
> db.geo.findOne({geo:{ "$geoWithin" : { "$center" : [ [ NaN, 4 ], Infinity ] } }});
null
I think that the bad lat/long should return an error similar to the one for $centerSphere instead of null for the $center specifier.
Similar behavior occurs when Infinity or -Infinity is passed as the lat/long for the $center and $centerSphere specifiers: it returns null for $center and an error for $centerSphere.
- related to
-
SERVER-17576 Typo in parseFlatPoint error message
-
- Closed
-