-
Notifications
You must be signed in to change notification settings - Fork 200
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
is_valid
for all geometry types.
#1130
Comments
For |
Some time ago I tried to implement various validity checks for I think it implements most of the validity checks of GEOS as well as some other checks. The non-validity diagnostic messages could greatly be improved, and there is no functionality to attempt to repair the geometries. |
Somewhat related to #1120 |
I'm currently studying the JTS It's quite a bit of code, but includes some machinery which would also be useful for buffering (maybe some day)! We already have monotone sweep functionality - but I'm having a hard time squaring it's API with the functionality needed by JTS's |
I haven't looked over the implementation very closely, but I wired it up to the JTS test suite for their IsValid method. They're mostly passing! The failures are:
Interestingly, it seems like all the failures have to do with considering empty geometries (and empty rings) as invalid, while JTS considers them valid, which might be a relatively simple to fix. |
Starting from @mthh's code, I was able to easily work through the few failing JTS tests. I'm still making some changes before opening a PR, but it's looking pretty promising. I'm not sure performance wise how it will compare with the more battle hardened JTS implementation, but so long as it's correct, I'm happy to use it as a start. |
Here's my WIP: https://github.com/georust/geo/compare/mkirk/mthh_is_valid_2?expand=1 Note it's not currently compiling - I broke it recently while DRY'ing up the implementation, but I think I'll be able to work through it in the next day or so. To see an older version, where the build is working and the tests are passing you can check out ea171e8 |
As stated in the description of the geometry types (e.g.,
Polygon
,LineString
), validity is not enforced, but it is expected. While the validity requirements are clearly documented, there is no "canonical" way to check if your geometry adheres to the validity requirements.An example of when this would be desirable is loading polygons from a file. There is no guarantee that the file contained valid geometry, but once we check this, the algorithms should produce valid polygons.
Therefore, if checking validity is expensive, that is ok, since this should be a one-time cost.
Ideally this is supported by each geometry type separately, and also on
Geometry
.related: #123
The text was updated successfully, but these errors were encountered: