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
IsValidOp.isValid(LineString) does not check for repeated points #486
Comments
That spec is behind a paywall. Do you have a copy? |
This has come up in the PostGIS project as well: https://trac.osgeo.org/postgis/ticket/3425 In that context I wrote in defence of the current behaviour, based on my interpretation of the OGC Simple Feature Access for SQL (SFS) spec: https://lists.osgeo.org/pipermail/postgis-users/2010-March/026265.html Is the ISO spec more clear on this issue? Anyway, this behaviour is intentional in JTS. And it's been there forever, so I am disinclined to change it for the default. Perhaps it could be provided as an option to Is this causing an actual problem for you? |
The ISO spec is a licensed product (unfortunately). I'll quote the relevant bit (under fair use) below; constructing the LineString will ultimately call the One thing the ISO spec is more clear on is that checking validity means checks on construction of geometries, and mostly are A second thing is that, viewed as a Curve, consecutive repeated points are not a validity issue. As your argument correctly points out, consecutive repeated points don't affect the embedded image of the curve, which is all Curve validity cares about. However, LineStrings have an explicit prohibition against repeated points in their construction. This is an issue for me because I'm exploring replacing Presto's use of Esri with JTS (partially motived by packed coordinates), and this would be a non-backwards-compatible change, and one that reduces our compliance with the spec. I don't know if any algorithms would be ill-behaved for these geometries. On the other hand, consistency with PostGIS is also a goal, so I'd like to keep as close to upstream as possible!
|
Thanks for the spec extract. It does seem clear that repeated points are invalid. I assume this applies to There's a few places where this comes into play:
Do you which of the above is required for your use cases? it should be straightforward to implement pre-or-post processors to check for repeated points, if that's desired. |
The issue of polygon topology semantics is a much bigger one, because it's harder (code and performance-wise) to check. I assume that the ISO spec is in line with the SFS here? And the ESRI library is not? Is that an issue as well? |
LinearRings are considered LinearStrings and have all the properties/prohibitions inherited from them. I really like JTS's approach of not erroring out when constructing invalid geometries, and leaving validity checks to "Cleaning up" on construction might be ok, but this prevents people from figuring out if the underlying WKT/WKB/etc is invalid. Ie, I'm happy to leave polygon semantics discussion for another time :). In particular, the ISO spec requires polygon validity to include simplicity in the constituent rings, which is very expensive. I view this as an unfortunate part of the spec. SFS does not really distinguish between |
Sorry, there was a typo in my comment, which made it unclear that point 3 actually refers to geometry constructed by JTS as a result of operations. Hopefully clearer now (see edit above), and not contentious.
it probably is a bit more expensive to handle simple rings than without this provision. Although the alternative ESRI-style semantic still does not require that valid rings are noded, and thus still requires a relatively expensive check for node points.
Correct, the SFS does not define |
I am not sure if this is off-topic or not, but I found this type of problematic geometry when I tried to understand why ArcMap and ArcGIS stopped rendering a large layer. If the jump in Z is not at the start/end point then the geometry gets rendered. OpenJUMP reports that there are consecutive points but they are consecutive only when it comes to X and Y. I believe that according to SFS this is not a polygon at all because it is not planar. However, I think that geometry validators usually do not care if XYZ polygons are planar or not. Just wondering about what JTS should say about it.
|
Currently JTS validation only checks X and Y. So this example is considered valid. It seems overlay finicky to not be able to render because of this situation! Aren't vertical lines supported? |
Only at that place of geometry (end/start point). In the middle of the ring the vertical segment does not prevent rendering. I tried to make a bug report through the local ESRI support but I do not know if it was filed or not. |
The isValid method for LineStrings does not check for repeated points. This is a condition for validity in the ISO spec (ISO/IEC 13249-3:2016 section 7.2.3), and is caught by ESRI.
IsValidOp
only checks if the coordinates are individually valid, and that there are enough points in the LineString (checkTooFewPoints
dedups consecutive points):You can check this with
"LINESTRING (0 0, 0 1, 0 1, 1 1, 1 0, 0 0)"
:Note that also
geom.isSimple() == true
(which is arguably correct).I'm happy to make a PR to fix this if desired. And if I'm misunderstanding something, let me know!
The text was updated successfully, but these errors were encountered: