summaryrefslogtreecommitdiff
path: root/jstests/geo_poly_edge.js
diff options
context:
space:
mode:
authorgregs <greg@10gen.com>2011-08-22 17:01:38 -0400
committergregs <greg@10gen.com>2011-08-22 17:03:56 -0400
commit18fa82a72b791289f3f4dfc5f3e3f2e998788c4a (patch)
tree75d4525920cf70f07646d3d28f91aa407ca134f3 /jstests/geo_poly_edge.js
parentafa9b2b469b9f31ddb33d644de2d468c3a42c549 (diff)
downloadmongo-18fa82a72b791289f3f4dfc5f3e3f2e998788c4a.tar.gz
SERVER-3670 polygon edge case fixes
Diffstat (limited to 'jstests/geo_poly_edge.js')
-rw-r--r--jstests/geo_poly_edge.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/jstests/geo_poly_edge.js b/jstests/geo_poly_edge.js
new file mode 100644
index 00000000000..0f0619b17ae
--- /dev/null
+++ b/jstests/geo_poly_edge.js
@@ -0,0 +1,21 @@
+//
+// Tests polygon edge cases
+//
+
+var coll = db.getCollection( jsTestName() )
+
+coll.ensureIndex({ loc : "2d" })
+
+coll.insert({ loc : [10, 10] })
+coll.insert({ loc : [10, -10] })
+
+assert.eq( coll.find({ loc : { $within : { $polygon : [[ 10, 10 ], [ 10, 10 ], [ 10, -10 ]] } } }).itcount(), 2 )
+
+assert.eq( coll.find({ loc : { $within : { $polygon : [[ 10, 10 ], [ 10, 10 ], [ 10, 10 ]] } } }).itcount(), 1 )
+
+
+coll.insert({ loc : [179, 0] })
+coll.insert({ loc : [0, 179] })
+
+assert.eq( coll.find({ loc : { $within : { $polygon : [[0, 0], [1000, 0], [1000, 1000], [0, 1000]] } } }).itcount(), 3 )
+