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

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • 1.9.1
    • Affects Version/s: None
    • Component/s: Geo
    • None
    • Environment:
      ALL
    • ALL
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      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 ] }

            Assignee:
            Greg Studer (Inactive)
            Reporter:
            Bernie Hackett
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: