-
Notifications
You must be signed in to change notification settings - Fork 369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CompoundCurve: Add validateConstruction method #1164
Conversation
1add0d1
to
175b272
Compare
Would this make sense to add to |
const CoordinateXY& end = curves[i-1]->getCoordinatesRO()->back<CoordinateXY>(); | ||
const CoordinateXY& start = curves[i]->getCoordinatesRO()->front<CoordinateXY>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may miss something, but it is not obvious to me that you can't insert an empty curve in a CompoundCurve, in which case back() and front() are returning something invalid. At least if using directly the CompoundCurve::CompoundCurve(std::vector<std::unique_ptr>&& p_curves, const GeometryFactory& gf) constructor. That might be hard/impossible to trigger through WKT. But maybe through WKB ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, this is possible and would crash. Of course it couldn't be so easy.
I was aiming to handle it consistently with how we handle linear rings, where we simply disallow the construction of a ring with a single point, or a ring that doesn't close. Lines 47 to 68 in bf2257a
|
So would this mean that a WKT or WKB serialization of an invalid compound curve could not be read? Sometimes users like to be able to read a structurally invalid geometry, so the library can be used to test validity and possible allow repair. I wonder how PostGIS handles this? |
Probably the same as LinearRing, which is (wait for it) to disallow non-closed WKT but allow non-closed WKB.
The point of being liberal in the binary is to allow dump/restore to work, even when highly invalid geometries have found their way into a table. |
I was wondering about that too. I've checked that GDAL allows for an extremely tiny gap of 1e-14, which probably is never met in practice.
What happens in practice though is when ingesting GML curves, and in particular when the compound curve chaining straight lines with circular portions where the circular portions are not defined as a CircularString, but as a ArcByCenterPoint, where you need to recompute the start and ending points from the center point and the start and end angles, which easily leads to precision issues. But I've ended up compensating for that in the GML import logic itself, because the gap is generally much larger than 1e-14. |
Correct, GEOS does not allow the construction of linear rings that are not closed, linear rings that have fewer than 3 points, or linestrings with a single point. |
Resolves #1103