summaryrefslogtreecommitdiff
path: root/src/mongo/db/geo/geojsonparser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/geo/geojsonparser.cpp')
-rw-r--r--src/mongo/db/geo/geojsonparser.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/mongo/db/geo/geojsonparser.cpp b/src/mongo/db/geo/geojsonparser.cpp
index 138583fec9a..c5ceae69b88 100644
--- a/src/mongo/db/geo/geojsonparser.cpp
+++ b/src/mongo/db/geo/geojsonparser.cpp
@@ -19,6 +19,7 @@
#include "mongo/db/jsobj.h"
#include "mongo/db/geo/geojsonparser.h"
#include "third_party/s2/s2.h"
+#include "third_party/s2/s2cell.h"
#include "third_party/s2/s2latlng.h"
#include "third_party/s2/s2loop.h"
#include "third_party/s2/s2polygon.h"
@@ -91,6 +92,13 @@ namespace mongo {
return coordinates[0].isNumber() && coordinates[1].isNumber();
}
+ void GeoJSONParser::parsePoint(const BSONObj& obj, S2Cell* out) {
+ const vector<BSONElement>& coords = obj.getFieldDotted(GEOJSON_COORDINATES).Array();
+ S2LatLng ll = S2LatLng::FromDegrees(coords[1].Number(),
+ coords[0].Number()).Normalized();
+ *out = S2Cell(ll);
+ }
+
void GeoJSONParser::parsePoint(const BSONObj& obj, S2Point* out) {
const vector<BSONElement>& coords = obj.getFieldDotted(GEOJSON_COORDINATES).Array();
*out = latLngToPoint(coords);