summaryrefslogtreecommitdiff
path: root/src/mongo/db/geo/geoparser_test.cpp
diff options
context:
space:
mode:
authorHari Khalsa <hkhalsa@10gen.com>2013-03-25 11:01:40 -0400
committerHari Khalsa <hkhalsa@10gen.com>2013-03-27 09:37:49 -0400
commit2ef273f283c7d45b9dfa55f5adf14f2b63069dc7 (patch)
tree41a89b6db7c59f59b4ef40ccb38a0c4d1f4af47a /src/mongo/db/geo/geoparser_test.cpp
parent7b84af64e01ae93f0315dcd3c492f44e044adb24 (diff)
downloadmongo-2ef273f283c7d45b9dfa55f5adf14f2b63069dc7.tar.gz
SERVER-9062 don't rely on drem to normalize longitude -- explicitly reject OOB values
Diffstat (limited to 'src/mongo/db/geo/geoparser_test.cpp')
-rw-r--r--src/mongo/db/geo/geoparser_test.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/mongo/db/geo/geoparser_test.cpp b/src/mongo/db/geo/geoparser_test.cpp
index 2e7fffb515f..cb3af1a119e 100644
--- a/src/mongo/db/geo/geoparser_test.cpp
+++ b/src/mongo/db/geo/geoparser_test.cpp
@@ -54,6 +54,10 @@ namespace {
// Make sure lat is in range
ASSERT_TRUE(GeoParser::isPoint(fromjson("{'type':'Point', 'coordinates': [0, 90.0]}")));
ASSERT_TRUE(GeoParser::isPoint(fromjson("{'type':'Point', 'coordinates': [0, -90.0]}")));
+ ASSERT_TRUE(GeoParser::isPoint(fromjson("{'type':'Point', 'coordinates': [180, 90.0]}")));
+ ASSERT_TRUE(GeoParser::isPoint(fromjson("{'type':'Point', 'coordinates': [-180, -90.0]}")));
+ ASSERT_FALSE(GeoParser::isPoint(fromjson("{'type':'Point', 'coordinates': [180.01, 90.0]}")));
+ ASSERT_FALSE(GeoParser::isPoint(fromjson("{'type':'Point', 'coordinates': [-180.01, -90.0]}")));
ASSERT_FALSE(GeoParser::isPoint(fromjson("{'type':'Point', 'coordinates': [0, 90.1]}")));
ASSERT_FALSE(GeoParser::isPoint(fromjson("{'type':'Point', 'coordinates': [0, -90.1]}")));
}
@@ -63,6 +67,10 @@ namespace {
fromjson("{'type':'LineString', 'coordinates':[[1,2], [3,4]]}")));
ASSERT_TRUE(GeoParser::isLineString(
fromjson("{'type':'LineString', 'coordinates':[[0,-90], [0,90]]}")));
+ ASSERT_TRUE(GeoParser::isLineString(
+ fromjson("{'type':'LineString', 'coordinates':[[180,-90], [-180,90]]}")));
+ ASSERT_FALSE(GeoParser::isLineString(
+ fromjson("{'type':'LineString', 'coordinates':[[180.1,-90], [-180.1,90]]}")));
ASSERT_FALSE(GeoParser::isLineString(
fromjson("{'type':'LineString', 'coordinates':[[0,-91], [0,90]]}")));
ASSERT_FALSE(GeoParser::isLineString(
@@ -82,6 +90,13 @@ namespace {
TEST(GeoParser, isValidPolygon) {
ASSERT_TRUE(GeoParser::isPolygon(
fromjson("{'type':'Polygon', 'coordinates':[ [[0,0],[5,0],[5,5],[0,5],[0,0]] ]}")));
+ // No out of bounds points
+ ASSERT_FALSE(GeoParser::isPolygon(
+ fromjson("{'type':'Polygon', 'coordinates':[ [[0,0],[5,0],[5,91],[0,5],[0,0]] ]}")));
+ ASSERT_TRUE(GeoParser::isPolygon(
+ fromjson("{'type':'Polygon', 'coordinates':[ [[0,0],[180,0],[5,5],[0,5],[0,0]] ]}")));
+ ASSERT_FALSE(GeoParser::isPolygon(
+ fromjson("{'type':'Polygon', 'coordinates':[ [[0,0],[181,0],[5,5],[0,5],[0,0]] ]}")));
// And one with a hole.
ASSERT_TRUE(GeoParser::isPolygon(
fromjson("{'type':'Polygon', 'coordinates':[ [[0,0],[5,0],[5,5],[0,5],[0,0]],"