20 #include "mongo/base/string_data.h"
28 #include "mongo/geo/point.h"
31 #include "mongo/util/assert_util.h"
36 template <
typename TCoordinates>
41 "bson argument must have field \"type\" that has value of type string.",
44 switch (stringToType(typeField.
String())) {
45 case GeoObjType_Point:
47 case GeoObjType_MultiPoint:
49 case GeoObjType_LineString:
51 case GeoObjType_MultiLineString:
53 case GeoObjType_Polygon:
55 case GeoObjType_MultiPolygon:
57 case GeoObjType_GeometryCollection:
60 uassert(0,
"bson must contain a type supported by MongoDB.",
false);
64 template <
typename TCoordinates>
66 if (typeStr == kPointTypeStr)
67 return GeoObjType_Point;
68 if (typeStr == kLineStringTypeStr)
69 return GeoObjType_LineString;
70 if (typeStr == kPolygonTypeStr)
71 return GeoObjType_Polygon;
72 if (typeStr == kMultiPointTypeStr)
73 return GeoObjType_MultiPoint;
74 if (typeStr == kMultiLineStringTypeStr)
75 return GeoObjType_MultiLineString;
76 if (typeStr == kMultiPolygonTypeStr)
77 return GeoObjType_MultiPolygon;
78 if (typeStr == kGeometryCollectionTypeStr)
79 return GeoObjType_GeometryCollection;
81 uassert(0,
"typeStr must contain a GeoJSON type supported by MongoDB",
false);
A StringData object wraps a 'const string&' or a 'const char*' without copying its contents...
Definition: string_data.h:43
Utility functions for parsing numbers from strings.
Definition: compare_numbers.h:20
Definition: geometrycollection.h:37
Definition: linestring.h:34
Definition: multipolygon.h:36
Definition: multilinestring.h:35
BSONType type() const
Returns the type of the element.
Definition: bsonelement.h:154
Definition: geometrycollection.h:40
BSONElement getField(const StringData &name) const
Get the field of the specified name.
std::string String() const
These functions, which start with a capital letter, throw a MsgAssertionException if the element is n...
Definition: bsonelement.h:62
Definition: multipoint.h:34
Represents a Point.
Definition: geometry.h:36
bool eoo() const
Indicates if it is the end-of-object element, which is present at the end of every BSON object...
Definition: bsonelement.h:172
BSONElement represents an "element" in a BSONObj.
Definition: bsonelement.h:55
static GeoObj< TCoordinates > * parse(const BSONObj &bson)
Parse the given BSON into a geometry type.
Definition: parser-impl.h:37
C++ representation of a "BSON" object – that is, an extended JSON-style object in a binary represent...
Definition: bsonobj.h:78
character string, stored in utf8
Definition: bsontypes.h:46