-
Notifications
You must be signed in to change notification settings - Fork 165
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
Add validity check per method and validity API #276
Conversation
01de693
to
a4324a3
Compare
@BuonOmo I was able to fix the tests locally by adding a few more methods to |
@keithdoggett thanks! Yeah the FFI issue is still here. I'll try and find some time in the next two weeks to fix this. FYI I just tried something given there, yet it did not work... Some other leads: |
a9229fe
to
4c914aa
Compare
@BuonOmo the macos errors are due to homebrew releasing GEOS 3.10. There were some updates to the validity handling (https://libgeos.org/posts/2021-10-01-geos-3-10-released/) and this caused some of the error messages to change. We might have to handle those tests inside the Geos/FFI specific test files and base the error on GEOS version. I can take a look at that in the #275 branch since it is more related to that. Assuming that is handled in #275, what else needs to be done for this PR? Documentation? |
Yes mostly documentation, as stated in private, I think we can merge that and open new issues / PRs to have short commits and allow external contribution for the few bits that are needed |
f22b520
to
ff39bec
Compare
@@ -19,7 +19,7 @@ def projection | |||
end | |||
|
|||
def envelope | |||
factory.unproject(projection.envelope) | |||
factory.unproject(projection.unsafe_envelope) |
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.
What's the reasoning for us having to use the unsafe versions of methods in the projected features?
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.
If we call the safe versions, we have some issues:
- first we end up running
check_validity
multiple times, - second if one wants to call for instance
proj_factory.unsafe_area
, it will itself callprojection.area
, which checks for validity.
@BuonOmo looks like we have to define the |
This is orders of magnitude faster, but one must include it in its implementation. (is it an issue though?)
- ensure projection uses `unsafe_` methods, the validity check is already done in the main method - only use utf8 strings to avoid confusion for users (there may be more to track) - make validity_tests a bit more generic
1b76c2c
to
e1374fd
Compare
@keithdoggett actually, the issue is that it is called on MultiPoint, and per spec, it has no EDIT: this is another harsh one, in fact postgis accepts it everywhere (#205) since we're in ruby and in ruby everything should just work i'd say we make it feature standard, explaining that choice bcause of postgis. Ok for you? |
Ahh yes, good catch. I agree that we should add it to GeometryCollection. PostGIS/GEOS compatibility is probably more important than strict OGC alignment. |
Co-authored-by: Keith Doggett <keith.doggett887@gmail.com>
Summary
Now that we can handle validity with much more finesse, we can leverage that to have a per method validity check.
Details
This PR adds the
ValidityCheck
implementation helper which gives the API below:make_valid
is a best effort to return a valid version of the given polygoninvalid_reason
gives nil if valid, or a string indicating invalid reasoncheck_validity!
raises theinvalid_reason
string if invalidThis module also has a
CHECKED_METHODS
constant which gives every methods that will be overriden after implementation to make sure they check validity before being applied.TODO
CHECKED_METHODS
listImplHelper::ValidityCheck.override_classes
is not too complicated (@keithdoggett I'd love your opinion on that one!)ValidityCheck
module to more implementations: