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

Spherical query assertions should provide useful information in case of long/lat order issues.

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • 1.9.1
    • None
    • Geo
    • None
    • ALL
    • ALL

    Description

      Users are being tripped up by the caveats related to spherical queries, especially the long/lat order requirement. If you use lat/long order queries will raise an assertion similar to this:

      error:

      { "$err" : "assertion db/geo/2d.cpp:1385" }

      This is so common that the assert should really give a hint as to what the problem is.

      Here's some example code for repro steps:

      // Wrong!
      switched to db mygeo
      > var earthRadius = 6378;
      > db.points.insert(

      {location: [37.762, -122.441]}

      );
      > db.points.insert(

      {location: [37.804, -122.270]}

      );
      > db.points.ensureIndex(

      {location:"2d"}

      );
      > db.points.find({location:{$nearSphere: [37.762,-122.441], $maxDistance: 1/earthRadius}});
      error:

      { "$err" : "assertion db/geo/2d.cpp:1385" }

      // Correct

      > db.points.drop()
      true
      > db.points.insert(

      {location: [-122.441, 37.762]}

      );
      > db.points.insert(

      {location: [-122.270, 37.802]}

      );
      > db.points.ensureIndex(

      {location:"2d"}

      );
      > db.points.find({location:{$nearSphere: [-122.441, 37.762], $maxDistance: 1/earthRadius}});

      { "_id" : ObjectId("4dc2e010c545b10a39a72bb3"), "location" : [ -122.441, 37.762 ] }

      Attachments

        Activity

          People

            greg_10gen Greg Studer
            bernie@mongodb.com Bernie Hackett
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: