diff options
author | Siyuan Zhou <siyuan.zhou@mongodb.com> | 2015-02-10 17:37:56 -0500 |
---|---|---|
committer | Ramon Fernandez <ramon.fernandez@mongodb.com> | 2015-02-11 18:21:17 -0500 |
commit | 5e579b03fb55259037d0f348ee0c7c1d702b69c9 (patch) | |
tree | e22132be552f3638f967a1b401835e0263b46435 | |
parent | c531604572ce408502dea9a3468b9a1c69639dd3 (diff) | |
download | mongo-5e579b03fb55259037d0f348ee0c7c1d702b69c9.tar.gz |
SERVER-17241 Verify number of loops of polygon
(cherry picked from commit 76e7106f2577d9911bc6694bab0d1166b58cd977)
-rw-r--r-- | jstests/core/geo_validate.js | 5 | ||||
-rw-r--r-- | src/mongo/db/geo/geoparser.cpp | 4 |
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. |