diff options
author | Dan Pasette <dan@10gen.com> | 2013-10-02 19:45:14 -0400 |
---|---|---|
committer | Dan Pasette <dan@mongodb.com> | 2013-10-02 19:45:14 -0400 |
commit | 33865cba588b666b32b75c42f309b26d21652762 (patch) | |
tree | ffc1b4f79905b8b7472fdc93509ca8a68f110688 | |
parent | bd96977507f3b45f2fafb3f8b8c3299948e5899c (diff) | |
download | mongo-33865cba588b666b32b75c42f309b26d21652762.tar.gz |
SERVER-10285 uassert that s2latlng is valid, print out if it's not
Backport original commit: ce6607fd28df1cc7c57a6ea03dcb0676e7a009ce
-rw-r--r-- | src/mongo/db/geo/geoparser.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/mongo/db/geo/geoparser.cpp b/src/mongo/db/geo/geoparser.cpp index 3de520be0be..ed86a2c3fa9 100644 --- a/src/mongo/db/geo/geoparser.cpp +++ b/src/mongo/db/geo/geoparser.cpp @@ -39,8 +39,15 @@ namespace mongo { static const string GEOJSON_COORDINATES = "coordinates"; //// Utility functions used by GeoParser functions below. - static S2Point coordToPoint(double p0, double p1) { - return S2LatLng::FromDegrees(p1, p0).Normalized().ToPoint(); + static S2Point coordToPoint(double lng, double lat) { + // Note that it's (lat, lng) for S2 but (lng, lat) for MongoDB. + S2LatLng ll = S2LatLng::FromDegrees(lat, lng).Normalized(); + if (!ll.is_valid()) { + stringstream ss; + ss << "coords invalid after normalization, lng = " << lng << " lat = " << lat << endl; + uasserted(17125, ss.str()); + } + return ll.ToPoint(); } static S2Point coordsToPoint(const vector<BSONElement>& coordElt) { |