mirror of https://gitee.com/bigwinds/arangodb
Improve error messages for loop validation (#9838)
* Improve error messages for loop validation * added changelog * Update CHANGELOG
This commit is contained in:
parent
d9507f8134
commit
c2df414b24
|
@ -1,6 +1,8 @@
|
|||
v3.5.1 (XXXX-XX-XX)
|
||||
-------------------
|
||||
|
||||
* Geo functions will now have better error reporting on invalid input.
|
||||
|
||||
* The graph viewer of the web interface now tries to find a vertex document of
|
||||
all available vertex collections before it aborts.
|
||||
|
||||
|
|
|
@ -328,11 +328,14 @@ Result parsePolygon(VPackSlice const& vpack, ShapeContainer& region) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
loops.push_back(std::make_unique<S2Loop>(vtx, S2Debug::DISABLE));
|
||||
if (!loops.back()->IsValid()) { // will check first and last for us
|
||||
return Result(TRI_ERROR_BAD_PARAMETER, "Invalid loop in polygon");
|
||||
|
||||
S2Error error;
|
||||
if (loops.back()->FindValidationError(&error)) {
|
||||
return Result(TRI_ERROR_BAD_PARAMETER,
|
||||
std::string("Invalid loop in polygon: ").append(error.text()));
|
||||
}
|
||||
|
||||
S2Loop* loop = loops.back().get();
|
||||
// normalization ensures that point orientation does not matter for Polygon
|
||||
// type the RFC recommends this for better compatibility
|
||||
|
@ -425,8 +428,10 @@ Result parseMultiPolygon(velocypack::Slice const& vpack, ShapeContainer& region)
|
|||
}
|
||||
|
||||
loops.push_back(std::make_unique<S2Loop>(vtx, S2Debug::DISABLE));
|
||||
if (!loops.back()->IsValid()) { // will check first and last for us
|
||||
return Result(TRI_ERROR_BAD_PARAMETER, "Invalid loop in polygon");
|
||||
S2Error error;
|
||||
if (loops.back()->FindValidationError(&error)) {
|
||||
return Result(TRI_ERROR_BAD_PARAMETER,
|
||||
std::string("Invalid loop in polygon: ").append(error.text()));
|
||||
}
|
||||
S2Loop* loop = loops.back().get();
|
||||
// normalization ensures that CCW orientation does not matter for Polygon
|
||||
|
@ -562,8 +567,10 @@ Result parseLoop(velocypack::Slice const& coords, bool geoJson, S2Loop& loop) {
|
|||
vertices.resize(vertices.size() - 1); // remove redundant last vertex
|
||||
}
|
||||
loop.Init(vertices);
|
||||
if (!loop.IsValid()) { // will check first and last for us
|
||||
return Result(TRI_ERROR_BAD_PARAMETER, "Invalid GeoJSON loop");
|
||||
S2Error error;
|
||||
if (loop.FindValidationError(&error)) {
|
||||
return Result(TRI_ERROR_BAD_PARAMETER,
|
||||
std::string("Invalid loop: ").append(error.text()));
|
||||
}
|
||||
loop.Normalize();
|
||||
|
||||
|
|
Loading…
Reference in New Issue