summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jstests/core/geo_s2near.js3
-rw-r--r--src/mongo/db/geo/geoquery.cpp7
2 files changed, 10 insertions, 0 deletions
diff --git a/jstests/core/geo_s2near.js b/jstests/core/geo_s2near.js
index 136e821b4b8..240e10d633a 100644
--- a/jstests/core/geo_s2near.js
+++ b/jstests/core/geo_s2near.js
@@ -82,3 +82,6 @@ testRadAndDegreesOK(1);
testRadAndDegreesOK(10)
testRadAndDegreesOK(50)
testRadAndDegreesOK(10000)
+
+// SERVER-13666 legacy coordinates must be in bounds for spherical near queries.
+assert.commandFailed(db.runCommand({geoNear : t.getName(), near: [1210.466, 31.2051], spherical: true, num: 10}));
diff --git a/src/mongo/db/geo/geoquery.cpp b/src/mongo/db/geo/geoquery.cpp
index 024129cd01e..cc1c0b45309 100644
--- a/src/mongo/db/geo/geoquery.cpp
+++ b/src/mongo/db/geo/geoquery.cpp
@@ -68,6 +68,13 @@ namespace mongo {
}
}
+ // The user-provided point can be flat. We need to make sure that it's in bounds.
+ if (isNearSphere) {
+ uassert(17444,
+ "Legacy point is out of bounds for spherical query",
+ centroid.flatUpgradedToSphere || (SPHERE == centroid.crs));
+ }
+
return hasGeometry;
}