Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/mongo/db/geo/geoquery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ namespace mongo {
if (!obj["maxDistance"].eoo()) {
uassert(17036, "maxDistance must be a number", obj["maxDistance"].isNumber());
double distArg = obj["maxDistance"].number();
log() << "parseFromGeoNear got maxDistance " << distArg;
uassert(16902, "maxDistance must be non-negative", distArg >= 0.0);
if (fromRadians) {
maxDistance = distArg * radius;
} else {
maxDistance = distArg;
}

uassert(17037, "maxDistance too large", maxDistance <= M_PI * radius);
uassert(17037, "maxDistance too large",
maxDistance <= nextafter(M_PI * radius, DBL_MAX));
}
return true;
}
Expand Down Expand Up @@ -98,7 +98,11 @@ namespace mongo {
}
}

double maxValidDistance = fromRadians ? M_PI : kRadiusOfEarthInMeters * M_PI;
// Add fudge to maxValidDistance so we don't throw when the provided maxDistance
// is on the edge.
double maxValidDistance = nextafter(fromRadians ?
M_PI :
kRadiusOfEarthInMeters * M_PI, DBL_MAX);

uassert(17038, "$minDistance too large", minDistance < maxValidDistance);
uassert(17039, "$maxDistance too large",
Expand Down
3 changes: 2 additions & 1 deletion src/mongo/db/index/2d_index_cursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1910,7 +1910,8 @@ namespace mongo {
maxDistance = e.numberDouble();
uassert(16989, "$maxDistance must be non-negative", maxDistance >= 0);
if (twod_internal::GEO_SPHERE == type) {
uassert(17088, "$maxDistance too large", maxDistance <= M_PI);
uassert(17088, "$maxDistance too large",
maxDistance <= nextafter(M_PI, DBL_MAX));
}
}
}
Expand Down