summaryrefslogtreecommitdiff
path: root/jstests/core/geo_big_polygon3.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/core/geo_big_polygon3.js')
-rw-r--r--jstests/core/geo_big_polygon3.js286
1 files changed, 104 insertions, 182 deletions
diff --git a/jstests/core/geo_big_polygon3.js b/jstests/core/geo_big_polygon3.js
index bf155c842ae..049064ebc5b 100644
--- a/jstests/core/geo_big_polygon3.js
+++ b/jstests/core/geo_big_polygon3.js
@@ -12,21 +12,15 @@
var crs84CRS = {
type: "name",
- properties: {
- name: "urn:ogc:def:crs:OGC:1.3:CRS84"
- }
+ properties: {name: "urn:ogc:def:crs:OGC:1.3:CRS84"}
};
var epsg4326CRS = {
type: "name",
- properties: {
- name: "EPSG:4326"
- }
+ properties: {name: "EPSG:4326"}
};
var strictCRS = {
type: "name",
- properties: {
- name: "urn:x-mongodb:crs:strictwinding:EPSG:4326"
- }
+ properties: {name: "urn:x-mongodb:crs:strictwinding:EPSG:4326"}
};
var coll = db.geo_bigpoly_edgecases;
@@ -35,59 +29,39 @@ coll.drop();
// Edge cases producing error
// These non-polygon objects cannot be queried because they are strictCRS
var objects = [
+ {name: "point with strictCRS", type: "Point", coordinates: [-97.9, 0], crs: strictCRS},
{
- name: "point with strictCRS",
- type: "Point",
- coordinates: [ -97.9 , 0 ],
- crs: strictCRS
- },
- {
- name: "multipoint with strictCRS",
- type: "MultiPoint",
- coordinates: [
- [ -97.9 , 0 ],
- [ -10.9 , 0 ]
- ],
- crs: strictCRS
+ name: "multipoint with strictCRS",
+ type: "MultiPoint",
+ coordinates: [[-97.9, 0], [-10.9, 0]],
+ crs: strictCRS
},
{
- name: "line with strictCRS",
- type: "LineString",
- coordinates: [
- [ -122.1611953, 37.4420407 ],
- [ -118.283638, 34.028517 ]
- ],
- crs: strictCRS
+ name: "line with strictCRS",
+ type: "LineString",
+ coordinates: [[-122.1611953, 37.4420407], [-118.283638, 34.028517]],
+ crs: strictCRS
}
];
-
objects.forEach(function(o) {
// within
assert.throws(function() {
- coll.count({geo: {$geoWithin: {$geometry: o}}});},
- null,
- "within " + o.name);
+ coll.count({geo: {$geoWithin: {$geometry: o}}});
+ }, null, "within " + o.name);
// intersection
assert.throws(function() {
- coll.count({geo: {$geoIntersects: {$geometry: o}}});},
- null,
- "intersection " + o.name);
+ coll.count({geo: {$geoIntersects: {$geometry: o}}});
+ }, null, "intersection " + o.name);
});
-
// Big Polygon query for $nearSphere & geoNear should fail
var bigPoly = {
name: "3 sided closed polygon",
type: "Polygon", // triangle
- coordinates: [ [
- [ 10.0, 10.0 ],
- [ 20.0, 10.0 ],
- [ 15.0, 17.0 ],
- [ 10.0, 10.0 ]
- ] ],
+ coordinates: [[[10.0, 10.0], [20.0, 10.0], [15.0, 17.0], [10.0, 10.0]]],
crs: strictCRS
};
@@ -96,39 +70,29 @@ assert.commandWorked(coll.ensureIndex({geo: "2dsphere"}), "2dsphere index");
// $nearSphere on big polygon should fail
assert.throws(function() {
- coll.count({geo: {$nearSphere: {$geometry: bigPoly}}});},
- null,
- "nearSphere " + bigPoly.name);
+ coll.count({geo: {$nearSphere: {$geometry: bigPoly}}});
+}, null, "nearSphere " + bigPoly.name);
// geoNear on big polygon should fail
-assert.commandFailed(
- db.runCommand({
- geoNear: coll.getName(),
- near: bigPoly,
- spherical: true
- }),
- "geoNear " + bigPoly.name);
+assert.commandFailed(db.runCommand({geoNear: coll.getName(), near: bigPoly, spherical: true}),
+ "geoNear " + bigPoly.name);
// aggregate $geoNear on big polygon should fail
-assert.commandFailed(
- db.runCommand({
- aggregate: coll.getName(),
- pipeline: [
- {$geoNear:
- {near: bigPoly, distanceField: "geo.calculated", spherical: true}}]
- }),
- "aggregate $geoNear " + bigPoly.name);
+assert.commandFailed(db.runCommand({
+ aggregate: coll.getName(),
+ pipeline: [{$geoNear: {near: bigPoly, distanceField: "geo.calculated", spherical: true}}]
+}),
+ "aggregate $geoNear " + bigPoly.name);
// mapReduce on big polygon should work
-assert.commandWorked(
- db.runCommand({
- mapReduce: coll.getName(),
- map: function() {},
- reduce: function() {},
- query: {geo: {$geoIntersects: {$geometry: bigPoly}}},
- out: {inline:1 },
- }),
- "mapReduce " + bigPoly.name);
+assert.commandWorked(db.runCommand({
+ mapReduce: coll.getName(),
+ map: function() {},
+ reduce: function() {},
+ query: {geo: {$geoIntersects: {$geometry: bigPoly}}},
+ out: {inline: 1},
+}),
+ "mapReduce " + bigPoly.name);
// Tests that stored objects with strictCRS will be ignored by query
// If strictCRS is removed from the document then they will be found
@@ -138,48 +102,37 @@ assert.commandWorked(coll.dropIndex({geo: "2dsphere"}), "drop 2dsphere index");
objects = [
{
- name: "NYC Times Square - point",
- geo: {
- type: "Point",
- coordinates: [ -73.9857 , 40.7577 ],
- crs: strictCRS
- }
+ name: "NYC Times Square - point",
+ geo: {type: "Point", coordinates: [-73.9857, 40.7577], crs: strictCRS}
},
{
- name: "NYC CitiField & JFK - multipoint",
- geo: {
- type: "MultiPoint",
- coordinates: [
- [ -73.8458 , 40.7569 ],
- [ -73.7789 , 40.6397 ]
- ],
- crs: strictCRS
- }
+ name: "NYC CitiField & JFK - multipoint",
+ geo: {
+ type: "MultiPoint",
+ coordinates: [[-73.8458, 40.7569], [-73.7789, 40.6397]],
+ crs: strictCRS
+ }
},
{
- name: "NYC - Times Square to CitiField to JFK - line/string",
- geo: {
- type: "LineString",
- coordinates: [
- [ -73.9857 , 40.7577 ],
- [ -73.8458 , 40.7569 ],
- [ -73.7789 , 40.6397 ]
- ],
- crs: strictCRS
- }
+ name: "NYC - Times Square to CitiField to JFK - line/string",
+ geo: {
+ type: "LineString",
+ coordinates: [[-73.9857, 40.7577], [-73.8458, 40.7569], [-73.7789, 40.6397]],
+ crs: strictCRS
+ }
},
{
- name: "NYC - Times Square to CitiField to JFK to Times Square - polygon",
- geo: {
- type: "Polygon",
- coordinates: [
- [ [ -73.9857 , 40.7577 ],
- [ -73.7789 , 40.6397 ],
- [ -73.8458 , 40.7569 ],
- [ -73.9857 , 40.7577 ] ]
- ],
- crs: strictCRS
- }
+ name: "NYC - Times Square to CitiField to JFK to Times Square - polygon",
+ geo: {
+ type: "Polygon",
+ coordinates: [[
+ [-73.9857, 40.7577],
+ [-73.7789, 40.6397],
+ [-73.8458, 40.7569],
+ [-73.9857, 40.7577]
+ ]],
+ crs: strictCRS
+ }
}
];
@@ -193,33 +146,25 @@ objects.forEach(function(o) {
var poly = {
name: "4 sided polygon around NYC",
type: "Polygon", // triangle
- coordinates: [ [
- [ -74.5, 40.5 ],
- [ -72.0, 40.5 ],
- [ -72.00, 41.0 ],
- [ -74.5, 41.0 ],
- [ -74.5, 40.5 ]
- ] ],
+ coordinates: [[[-74.5, 40.5], [-72.0, 40.5], [-72.00, 41.0], [-74.5, 41.0], [-74.5, 40.5]]],
crs: strictCRS
};
assert.eq(0,
- coll.count({geo: {$geoWithin: {$geometry: poly}}}),
- "ignore objects with strictCRS within");
+ coll.count({geo: {$geoWithin: {$geometry: poly}}}),
+ "ignore objects with strictCRS within");
assert.eq(0,
- coll.count({geo: {$geoIntersects: {$geometry: poly}}}),
- "ignore objects with strictCRS intersects");
+ coll.count({geo: {$geoIntersects: {$geometry: poly}}}),
+ "ignore objects with strictCRS intersects");
// Now remove the strictCRS and find all the objects
-coll.update({},{$unset: {"geo.crs": ""}}, {multi: true});
+coll.update({}, {$unset: {"geo.crs": ""}}, {multi: true});
var totalDocs = coll.count();
+assert.eq(totalDocs, coll.count({geo: {$geoWithin: {$geometry: poly}}}), "no strictCRS within");
assert.eq(totalDocs,
- coll.count({geo: {$geoWithin: {$geometry: poly}}}),
- "no strictCRS within");
-assert.eq(totalDocs,
- coll.count({geo: {$geoIntersects: {$geometry: poly}}}),
- "no strictCRS intersects");
+ coll.count({geo: {$geoIntersects: {$geometry: poly}}}),
+ "no strictCRS intersects");
// Clear collection
coll.remove({});
@@ -228,66 +173,44 @@ coll.remove({});
// Objects should be found from query
objects = [
{
- name: "NYC Times Square - point crs84CRS",
- geo: {
- type: "Point",
- coordinates: [ -73.9857 , 40.7577 ],
- crs: crs84CRS
- }
+ name: "NYC Times Square - point crs84CRS",
+ geo: {type: "Point", coordinates: [-73.9857, 40.7577], crs: crs84CRS}
},
{
- name: "NYC Times Square - point epsg4326CRS",
- geo: {
- type: "Point",
- coordinates: [ -73.9857 , 40.7577 ],
- crs: epsg4326CRS
- }
+ name: "NYC Times Square - point epsg4326CRS",
+ geo: {type: "Point", coordinates: [-73.9857, 40.7577], crs: epsg4326CRS}
},
{
- name: "NYC CitiField & JFK - multipoint crs84CRS",
- geo: {
- type: "MultiPoint",
- coordinates: [
- [ -73.8458 , 40.7569 ],
- [ -73.7789 , 40.6397 ]
- ],
- crs: crs84CRS
- }
+ name: "NYC CitiField & JFK - multipoint crs84CRS",
+ geo: {
+ type: "MultiPoint",
+ coordinates: [[-73.8458, 40.7569], [-73.7789, 40.6397]],
+ crs: crs84CRS
+ }
},
{
- name: "NYC CitiField & JFK - multipoint epsg4326CRS",
- geo: {
- type: "MultiPoint",
- coordinates: [
- [ -73.8458 , 40.7569 ],
- [ -73.7789 , 40.6397 ]
- ],
- crs: epsg4326CRS
- }
+ name: "NYC CitiField & JFK - multipoint epsg4326CRS",
+ geo: {
+ type: "MultiPoint",
+ coordinates: [[-73.8458, 40.7569], [-73.7789, 40.6397]],
+ crs: epsg4326CRS
+ }
},
{
- name: "NYC - Times Square to CitiField to JFK - line/string crs84CRS",
- geo: {
- type: "LineString",
- coordinates: [
- [ -73.9857 , 40.7577 ],
- [ -73.8458 , 40.7569 ],
- [ -73.7789 , 40.6397 ]
- ],
- crs: crs84CRS
- }
+ name: "NYC - Times Square to CitiField to JFK - line/string crs84CRS",
+ geo: {
+ type: "LineString",
+ coordinates: [[-73.9857, 40.7577], [-73.8458, 40.7569], [-73.7789, 40.6397]],
+ crs: crs84CRS
+ }
},
{
- name: "NYC - Times Square to CitiField to JFK - line/string epsg4326CRS",
- geo: {
- type: "LineString",
- coordinates: [
- [ -73.9857 , 40.7577 ],
- [ -73.8458 , 40.7569 ],
- [ -73.7789 , 40.6397 ]
- ],
- crs: epsg4326CRS
- }
+ name: "NYC - Times Square to CitiField to JFK - line/string epsg4326CRS",
+ geo: {
+ type: "LineString",
+ coordinates: [[-73.9857, 40.7577], [-73.8458, 40.7569], [-73.7789, 40.6397]],
+ crs: epsg4326CRS
+ }
}
];
@@ -300,19 +223,18 @@ objects.forEach(function(o) {
totalDocs = coll.count();
assert.eq(totalDocs,
- coll.count({geo: {$geoWithin: {$geometry: poly}}}),
- "crs84CRS or epsg4326CRS within");
+ coll.count({geo: {$geoWithin: {$geometry: poly}}}),
+ "crs84CRS or epsg4326CRS within");
assert.eq(totalDocs,
- coll.count({geo: {$geoIntersects: {$geometry: poly}}}),
- "crs84CRS or epsg4326CRS intersects");
+ coll.count({geo: {$geoIntersects: {$geometry: poly}}}),
+ "crs84CRS or epsg4326CRS intersects");
// Add index and look again for stored point & spherical CRS documents
assert.commandWorked(coll.ensureIndex({geo: "2dsphere"}), "2dsphere index");
assert.eq(totalDocs,
- coll.count({geo: {$geoWithin: {$geometry: poly}}}),
- "2dsphere index - crs84CRS or epsg4326CRS within");
+ coll.count({geo: {$geoWithin: {$geometry: poly}}}),
+ "2dsphere index - crs84CRS or epsg4326CRS within");
assert.eq(totalDocs,
- coll.count({geo: {$geoIntersects: {$geometry: poly}}}),
- "2dsphere index - crs84CRS or epsg4326CRS intersects");
-
+ coll.count({geo: {$geoIntersects: {$geometry: poly}}}),
+ "2dsphere index - crs84CRS or epsg4326CRS intersects");