diff options
author | Eric Cox <eric.cox@mongodb.com> | 2021-09-14 15:05:18 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-09-14 15:50:06 +0000 |
commit | 85cf0f4bdb5763514df90653a677cf8fa0100305 (patch) | |
tree | 609e1a6334a7233c38eb70dc66dd73541a6229e5 /src/mongo/db/geo | |
parent | 9cbf52051d506a029546c1e7e28a5f77afd8bd46 (diff) | |
download | mongo-85cf0f4bdb5763514df90653a677cf8fa0100305.tar.gz |
SERVER-57938 Skip validation for stored geometry if a 2dsphere index exists
Diffstat (limited to 'src/mongo/db/geo')
-rw-r--r-- | src/mongo/db/geo/geometry_container.cpp | 3 | ||||
-rw-r--r-- | src/mongo/db/geo/geoparser.cpp | 5 |
2 files changed, 3 insertions, 5 deletions
diff --git a/src/mongo/db/geo/geometry_container.cpp b/src/mongo/db/geo/geometry_container.cpp index e4f18636b14..03a97ef86b0 100644 --- a/src/mongo/db/geo/geometry_container.cpp +++ b/src/mongo/db/geo/geometry_container.cpp @@ -1339,9 +1339,6 @@ StoredGeometry* StoredGeometry::parseFrom(const BSONElement& element, bool skipV return nullptr; std::unique_ptr<StoredGeometry> stored(new StoredGeometry); - - // GeoNear stage can only be run with an existing index - // Therefore, it is always safe to skip geometry validation if (!stored->geometry.parseFromStorage(element, skipValidation).isOK()) return nullptr; stored->element = element; diff --git a/src/mongo/db/geo/geoparser.cpp b/src/mongo/db/geo/geoparser.cpp index bf4888bbf5b..ea97c706851 100644 --- a/src/mongo/db/geo/geoparser.cpp +++ b/src/mongo/db/geo/geoparser.cpp @@ -189,7 +189,8 @@ static Status parseGeoJSONPolygonCoordinates(const BSONElement& elem, loops.push_back(std::make_unique<S2Loop>(points)); S2Loop* loop = loops.back().get(); - // Check whether this loop is valid. + // Check whether this loop is valid if vaildation hasn't been already done on 2dSphere index + // insertion which is controlled by the 'skipValidation' flag. // 1. At least 3 vertices. // 2. All vertices must be unit length. Guaranteed by parsePoints(). // 3. Loops are not allowed to have any duplicate vertices. @@ -202,7 +203,7 @@ static Status parseGeoJSONPolygonCoordinates(const BSONElement& elem, // Check the first loop must be the exterior ring and any others must be // interior rings or holes. - if (loops.size() > 1 && !loops[0]->Contains(loop)) { + if (!skipValidation && loops.size() > 1 && !loops[0]->Contains(loop)) { return BAD_VALUE( "Secondary loops not contained by first exterior loop - " "secondary loops must be holes: " |