[SERVER-3051] Spherical query assertions should provide useful information in case of long/lat order issues. Created: 05/May/11  Updated: 12/Jul/16  Resolved: 06/May/11

Status: Closed
Project: Core Server
Component/s: Geo
Affects Version/s: None
Fix Version/s: 1.9.1

Type: Bug Priority: Major - P3
Reporter: Bernie Hackett Assignee: Greg Studer
Resolution: Done Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

ALL


Operating System: ALL
Participants:

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

 Comments   
Comment by Greg Studer [ 06/May/11 ]

related to SERVER-2980

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