[SERVER-16883] Geo Query $center with "NaN" coordinate does not error Created: 15/Jan/15  Updated: 25/Jan/17  Resolved: 05/Feb/15

Status: Closed
Project: Core Server
Component/s: Geo
Affects Version/s: None
Fix Version/s: 3.0.0-rc9, 3.1.0

Type: Bug Priority: Minor - P4
Reporter: Amalia Hawkins Assignee: Siyuan Zhou
Resolution: Done Votes: 0
Labels: 28qa
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-17576 Typo in parseFlatPoint error message Closed
Tested
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Completed:
Participants:

 Description   

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.



 Comments   
Comment by Githook User [ 06/Feb/15 ]

Author:

{u'username': u'visualzhou', u'name': u'Siyuan Zhou', u'email': u'siyuan.zhou@mongodb.com'}

Message: SERVER-16883 Geo Query $center with "NaN" coordinate does not error

(cherry picked from commit 68fe6570d19c744f84861b70d541e8b46ac24935)
Branch: v3.0
https://github.com/mongodb/mongo/commit/dadc36a4cd0cc13e260c705ce3143ebe57d60c88

Comment by Githook User [ 05/Feb/15 ]

Author:

{u'username': u'visualzhou', u'name': u'Siyuan Zhou', u'email': u'siyuan.zhou@mongodb.com'}

Message: SERVER-16883 Geo Query $center with "NaN" coordinate does not error
Branch: master
https://github.com/mongodb/mongo/commit/68fe6570d19c744f84861b70d541e8b46ac24935

Generated at Thu Feb 08 03:42:35 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.