-
Notifications
You must be signed in to change notification settings - Fork 442
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
RFC: Tests for ISO compliance #499
base: master
Are you sure you want to change the base?
Conversation
This PR is meant to start a discussion about where JTS is and isn't confirming to the ISO spec. These test cases are meant to explore the "basic" scenarios thoroughly. They aren't meant to test numerical stability or cpmplex cases, but are meant to test conditions like nulls and NaNs. The tests were designed to pass in JTS. Where I've noticed a departure from the ISO spec, or unexpected behavior, I've put an "XXX" comment.
Can you summarize the discrepancies with ISO in a list? Either here or in the unit test, or both. |
Summarizing some thoughts and incompatibilities:
More specific comments:
|
Really? So there is no semantic meaning for an ISO MultiPolygon over a GeometryCollection of Polygons? MultiPolygons whose polygons touch only on the boundaries are valid (and simple). JTS has them invalid but simple. In OGC elements of a MultiPolygon can touch at points but not in lines or areas. JTS implements this semantics |
A general comment: The key point is that JTS implements the OGC semantics. So it would be more appropriate to contrast the OGC semantics with ISO semantics. Then if necessary identify anywhere that JTS does not implement OGC semantics. I suggest splitting the tests into two files, one for JTS-only things and one for discrepancies between OGC and ISO. It doesn't look possible to meet all of the ISO semantics while keeping OGC compatibility. And a few of the ISO semantics (the ones involving MultiPolygons) look very questionable, since they seem to imply that MultiPolygons have none or very few topological constraints. The issues around whether geometries containing nulls/NaNs etc are probably addressable. I guess those are not OGC semantics per se, but purely JTS. |
I re-checked the ISO standard, and you're right about MultiPolygon intersections. Here is a more careful reading:
One challenge with the conforming to OGC is that OGC doesn't define One advantage of ISO is the SQL spec in general is in ISO standard, so the ISO simple geometry sql spec is natural to implement for databases. However, the requirement to pay is an unfortunate hurdle. ISO leaves some interpretation for those conditions that fail on construction, and those conditions for validity. It seems unreasonable to require containment/intersection checks on a MultiGeometry on construction -- those are very expensive operations, and I like JTS's philosophy of allowing serialization/deserialization of problematic geometries, since we don't know what the user is doing with them or how much they care. |
Sounds very similar to OGC.
The semantics of IsValid are presumably defined by the definition of geometry validity. This is reasonably well specified in the OGC SFS.
By all means. Although I suspect a textual/mathematical definition of the additional semantics will be required as well (and will be more concise and clear than the tests). |
So sounds like the current JTS construction semantics are fine. So just need to tighten up the validity checks perhaps? And that only in the area of checking for empty/null components? Also perhaps extend the definition of IsSimple, which should be fine. The concept of simplicity is actually a good way to expose some powerful topology checks, especially when combined with the JTS idea of generalizing the notion of "boundary node rule". For instance, this allows |
Out of curiosity, does the ISO spec address undefined/no data ordinate values? e.g. JTS uses |
ISO considers ordinates as real numbers. Not integers or floats. So it does not specify anything about infinities, NaNs, or subnormals (or integer effects like overflow). It's pretty specific for the general class of null pointers, so it describes the behavior when you try to pass a null array of Points to the MultiPoint constructor, or if one of the Points is null (in general, this would raise an error on construction). |
I went over the OGC specs more carefully, and I agree that the JTS semantics are generally fine. I'd say the issues remaining are in three categories:
|
Maybe... although I wonder if there is a use case for null ordinates? This is easy to enforce a priori by client code, so does not seem essential.
As far as I know this is the current JTS semantic. Is there an example where this is not the case?
Similar comment to #1. Has appeal, but this would be a breaking change. Relatively easy to check a priori. For #1 & 3, one approach would be to add these as checks, but allow them to be disabled via a global flag, for backwards compatibility. |
This PR is meant to start a discussion about where JTS is and isn't
confirming to the ISO spec. These test cases are meant to explore the
"basic" scenarios thoroughly. They aren't meant to test numerical
stability or complex cases, but are meant to test conditions like
nulls and NaNs.
The tests were designed to pass in JTS. Where I've noticed a
departure from the ISO spec, or unexpected behavior, I've put an
"XXX" comment.