示例#1
0
文件: geoparser.cpp 项目: cpuga/mongo
 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();
 }
示例#2
0
 static S2Point coordToPoint(double lng, double lat) {
     // We don't rely on drem to clean up non-sane points.  We just don't let them become
     // spherical.
     verify(isValidLngLat(lng, lat));
     // Note that it's (lat, lng) for S2 but (lng, lat) for MongoDB.
     S2LatLng ll = S2LatLng::FromDegrees(lat, lng).Normalized();
     // This shouldn't happen since we should only have valid lng/lats.
     if (!ll.is_valid()) {
         stringstream ss;
         ss << "coords invalid after normalization, lng = " << lng << " lat = " << lat << endl;
         uasserted(17125, ss.str());
     }
     return ll.ToPoint();
 }
示例#3
0
 static Status coordToPoint(double lng, double lat, S2Point* out) {
     // We don't rely on drem to clean up non-sane points.  We just don't let them become
     // spherical.
     if (!isValidLngLat(lng, lat))
         return BAD_VALUE("longitude/latitude is out of bounds, lng: " << lng << " lat: " << lat);
     // Note that it's (lat, lng) for S2 but (lng, lat) for MongoDB.
     S2LatLng ll = S2LatLng::FromDegrees(lat, lng).Normalized();
     // This shouldn't happen since we should only have valid lng/lats.
     if (!ll.is_valid()) {
         stringstream ss;
         ss << "coords invalid after normalization, lng = " << lng << " lat = " << lat << endl;
         uasserted(17125, ss.str());
     }
     *out = ll.ToPoint();
     return Status::OK();
 }