summaryrefslogtreecommitdiff
path: root/src/mongo/db/geo
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/geo')
-rw-r--r--src/mongo/db/geo/geometry_container.cpp4
-rw-r--r--src/mongo/db/geo/geoparser.cpp45
-rw-r--r--src/mongo/db/geo/geoparser.h5
3 files changed, 14 insertions, 40 deletions
diff --git a/src/mongo/db/geo/geometry_container.cpp b/src/mongo/db/geo/geometry_container.cpp
index be09ea54dc7..c3c3adaa1b2 100644
--- a/src/mongo/db/geo/geometry_container.cpp
+++ b/src/mongo/db/geo/geometry_container.cpp
@@ -317,9 +317,7 @@ bool GeometryContainer::contains(const GeometryContainer& otherContainer) const
}
if (nullptr != otherContainer._polygon) {
- tassert(7323500,
- "Checking if geometry contains big polygon is not supported",
- nullptr != otherContainer._polygon->s2Polygon);
+ invariant(nullptr != otherContainer._polygon->s2Polygon);
return contains(*otherContainer._polygon->s2Polygon);
}
diff --git a/src/mongo/db/geo/geoparser.cpp b/src/mongo/db/geo/geoparser.cpp
index d7a353fe6e4..005f6defef2 100644
--- a/src/mongo/db/geo/geoparser.cpp
+++ b/src/mongo/db/geo/geoparser.cpp
@@ -49,37 +49,21 @@ namespace mongo {
namespace dps = ::mongo::dotted_path_support;
-Status GeoParser::parseFlatPointCoordinates(const BSONElement& elem,
- BSONElement& x,
- BSONElement& y,
- bool allowAddlFields /* = false */) {
- if (!elem.isABSONObj()) {
- return BAD_VALUE("Point must be an array or object, instead got type "
- << typeName(elem.type()));
- }
-
+static Status parseFlatPoint(const BSONElement& elem, Point* out, bool allowAddlFields = false) {
+ if (!elem.isABSONObj())
+ return BAD_VALUE("Point must be an array or object");
BSONObjIterator it(elem.Obj());
- x = it.next();
+ BSONElement x = it.next();
if (!x.isNumber()) {
return BAD_VALUE("Point must only contain numeric elements");
}
- y = it.next();
+ BSONElement y = it.next();
if (!y.isNumber()) {
return BAD_VALUE("Point must only contain numeric elements");
}
if (!allowAddlFields && it.more()) {
return BAD_VALUE("Point must only contain two numeric elements");
}
- return Status::OK();
-}
-
-static Status parseFlatPoint(const BSONElement& elem, Point* out, bool allowAddlFields = false) {
- BSONElement x, y;
- auto status = GeoParser::parseFlatPointCoordinates(elem, x, y, allowAddlFields);
- if (!status.isOK()) {
- return status;
- }
-
out->x = x.number();
out->y = y.number();
// Point coordinates must be finite numbers, neither NaN or infinite.
@@ -784,23 +768,20 @@ GeoParser::GeoJSONType GeoParser::parseGeoJSONType(const BSONObj& obj) {
if (String != type.type()) {
return GeoParser::GEOJSON_UNKNOWN;
}
- return geoJSONTypeStringToEnum(type.checkAndGetStringData());
-}
-
-GeoParser::GeoJSONType GeoParser::geoJSONTypeStringToEnum(StringData type) {
- if (GEOJSON_TYPE_POINT == type) {
+ const string& typeString = type.String();
+ if (GEOJSON_TYPE_POINT == typeString) {
return GeoParser::GEOJSON_POINT;
- } else if (GEOJSON_TYPE_LINESTRING == type) {
+ } else if (GEOJSON_TYPE_LINESTRING == typeString) {
return GeoParser::GEOJSON_LINESTRING;
- } else if (GEOJSON_TYPE_POLYGON == type) {
+ } else if (GEOJSON_TYPE_POLYGON == typeString) {
return GeoParser::GEOJSON_POLYGON;
- } else if (GEOJSON_TYPE_MULTI_POINT == type) {
+ } else if (GEOJSON_TYPE_MULTI_POINT == typeString) {
return GeoParser::GEOJSON_MULTI_POINT;
- } else if (GEOJSON_TYPE_MULTI_LINESTRING == type) {
+ } else if (GEOJSON_TYPE_MULTI_LINESTRING == typeString) {
return GeoParser::GEOJSON_MULTI_LINESTRING;
- } else if (GEOJSON_TYPE_MULTI_POLYGON == type) {
+ } else if (GEOJSON_TYPE_MULTI_POLYGON == typeString) {
return GeoParser::GEOJSON_MULTI_POLYGON;
- } else if (GEOJSON_TYPE_GEOMETRY_COLLECTION == type) {
+ } else if (GEOJSON_TYPE_GEOMETRY_COLLECTION == typeString) {
return GeoParser::GEOJSON_GEOMETRY_COLLECTION;
}
return GeoParser::GEOJSON_UNKNOWN;
diff --git a/src/mongo/db/geo/geoparser.h b/src/mongo/db/geo/geoparser.h
index cba5893cf37..4d4d1185235 100644
--- a/src/mongo/db/geo/geoparser.h
+++ b/src/mongo/db/geo/geoparser.h
@@ -92,17 +92,12 @@ public:
static GeoSpecifier parseGeoSpecifier(const BSONElement& elem);
static GeoJSONType parseGeoJSONType(const BSONObj& obj);
- static GeoJSONType geoJSONTypeStringToEnum(StringData type);
// Legacy points can contain extra data as extra fields - these are valid to index
// e.g. { x: 1, y: 1, z: 1 }
static Status parseLegacyPoint(const BSONElement& elem,
PointWithCRS* out,
bool allowAddlFields = false);
- static Status parseFlatPointCoordinates(const BSONElement& elem,
- BSONElement& x,
- BSONElement& y,
- bool allowAddlFields = false);
// Parse the BSON object after $box, $center, etc.
static Status parseLegacyBox(const BSONObj& obj, BoxWithCRS* out);
static Status parseLegacyCenter(const BSONObj& obj, CapWithCRS* out);