diff options
author | Hari Khalsa <hkhalsa@10gen.com> | 2013-01-10 17:53:16 -0500 |
---|---|---|
committer | Hari Khalsa <hkhalsa@10gen.com> | 2013-01-11 10:33:36 -0500 |
commit | 2e7a1a24160a09c9de2df4caad0fc9c2a278b998 (patch) | |
tree | 0180087771f801e2ca1c5979762e71c0edb32e2a /src/mongo/db/geo/geoparser_test.cpp | |
parent | 4ba4aae6776c5832fcf613884eaca31382cde7a4 (diff) | |
download | mongo-2e7a1a24160a09c9de2df4caad0fc9c2a278b998.tar.gz |
verify latitude is [-90,90]
Diffstat (limited to 'src/mongo/db/geo/geoparser_test.cpp')
-rw-r--r-- | src/mongo/db/geo/geoparser_test.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/mongo/db/geo/geoparser_test.cpp b/src/mongo/db/geo/geoparser_test.cpp index 8194d208817..aa4a1af5db6 100644 --- a/src/mongo/db/geo/geoparser_test.cpp +++ b/src/mongo/db/geo/geoparser_test.cpp @@ -48,12 +48,24 @@ namespace { ASSERT_FALSE(GeoParser::isPoint(fromjson("{'type':'Point', 'coordinates': 40}"))); ASSERT_FALSE(GeoParser::isPoint( fromjson("{'type':'Point', 'coordinates': [40, -5, 7]}"))); + + // 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_FALSE(GeoParser::isPoint(fromjson("{'type':'Point', 'coordinates': [0, 90.1]}"))); + ASSERT_FALSE(GeoParser::isPoint(fromjson("{'type':'Point', 'coordinates': [0, -90.1]}"))); } TEST(GeoParser, isValidLineString) { ASSERT_TRUE(GeoParser::isLineString( fromjson("{'type':'LineString', 'coordinates':[[1,2], [3,4]]}"))); ASSERT_TRUE(GeoParser::isLineString( + fromjson("{'type':'LineString', 'coordinates':[[0,-90], [0,90]]}"))); + ASSERT_FALSE(GeoParser::isLineString( + fromjson("{'type':'LineString', 'coordinates':[[0,-91], [0,90]]}"))); + ASSERT_FALSE(GeoParser::isLineString( + fromjson("{'type':'LineString', 'coordinates':[[0,-90], [0,91]]}"))); + ASSERT_TRUE(GeoParser::isLineString( fromjson("{'type':'LineString', 'coordinates':[[1,2], [3,4], [5,6]]}"))); ASSERT_FALSE(GeoParser::isLineString( fromjson("{'type':'LineString', 'coordinates':[[1,2]]}"))); @@ -72,6 +84,10 @@ namespace { ASSERT_TRUE(GeoParser::isPolygon( fromjson("{'type':'Polygon', 'coordinates':[ [[0,0],[5,0],[5,5],[0,5],[0,0]]," " [[1,1],[4,1],[4,4],[1,4],[1,1]] ]}"))); + // Latitudes must be OK + ASSERT_FALSE(GeoParser::isPolygon( + fromjson("{'type':'Polygon', 'coordinates':[ [[0,0],[5,0],[5,91],[0,91],[0,0]]," + " [[1,1],[4,1],[4,4],[1,4],[1,1]] ]}"))); // First point must be the same as the last. ASSERT_FALSE(GeoParser::isPolygon( fromjson("{'type':'Polygon', 'coordinates':[ [[1,2],[3,4],[5,6]] ]}"))); |