Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-16883

Geo Query $center with "NaN" coordinate does not error

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.0.0-rc9, 3.1.0
    • Component/s: Geo
    • Labels:
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Backport Completed:

      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.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: