summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSiyuan Zhou <siyuan.zhou@mongodb.com>2015-02-10 17:37:56 -0500
committerRamon Fernandez <ramon.fernandez@mongodb.com>2015-02-11 18:21:17 -0500
commit5e579b03fb55259037d0f348ee0c7c1d702b69c9 (patch)
treee22132be552f3638f967a1b401835e0263b46435
parentc531604572ce408502dea9a3468b9a1c69639dd3 (diff)
downloadmongo-5e579b03fb55259037d0f348ee0c7c1d702b69c9.tar.gz
SERVER-17241 Verify number of loops of polygon
(cherry picked from commit 76e7106f2577d9911bc6694bab0d1166b58cd977)
-rw-r--r--jstests/core/geo_validate.js5
-rw-r--r--src/mongo/db/geo/geoparser.cpp4
2 files changed, 9 insertions, 0 deletions
diff --git a/jstests/core/geo_validate.js b/jstests/core/geo_validate.js
index 86eaeb59a22..2d3782e233a 100644
--- a/jstests/core/geo_validate.js
+++ b/jstests/core/geo_validate.js
@@ -86,3 +86,8 @@ assert.commandFailed(db.runCommand({geoNear: coll.getName(),
// NaN is interpreted as limit 0
assert.commandWorked(db.runCommand({geoNear: coll.getName(),
near: [0,0], spherical: true, num: NaN}));
+
+
+//
+// SERVER-17241 Polygon has no loop
+assert.writeError(coll.insert({ geo : { type: 'Polygon', coordinates: [] } }));
diff --git a/src/mongo/db/geo/geoparser.cpp b/src/mongo/db/geo/geoparser.cpp
index df8914e3469..db03fe66c12 100644
--- a/src/mongo/db/geo/geoparser.cpp
+++ b/src/mongo/db/geo/geoparser.cpp
@@ -197,6 +197,10 @@ namespace mongo {
}
}
+ if (loops.empty()) {
+ return BAD_VALUE("Polygon has no loops.");
+ }
+
// Check if the given loops form a valid polygon.
// 1. If a loop contains an edge AB, then no other loop may contain AB or BA.
// 2. No loop covers more than half of the sphere.