-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Fix bug #9777: Simplification of polygons may return invalid polygons -> ST_MakeValid #1241
Conversation
|
@ahuarte47 Nice work on this! I have not tested it, but it seems to me the wording for the option might be better if it was something like: Enable automatic repair of invalid geometries for newly added layers because 'validation' refers to just checking the validity of the geometry, whereas your routine is attempting to repair geometries found to be invalid. |
Done, thank you very much @dakcarto ! |
@ahuarte47 It seems nice ! |
liblwgeom is well packaged now, and included in the standalone installer for win; in fact, I suggest to make more use of it, e.g. adding the relevant plugin to the standard qgis installation. |
Hi, I am adding this code to GEOS lib in its github repo, but while it is not published and QGIS not use the new version, we already have that functionality. Do you agree ? |
Not sure to understand. You plan to add this to GEOS ? Isn't it already extracted from liblwgeom ? |
Sorry, I did not express myself well, I want append this "ST_makeValid" method in the class GEOSGeometry to be directly used in QGIS in class QgsGeometry when possible. |
Ok. So yes if you managed to get this directly into GEOS, that would be perfect. With a test for GEOS version in the QGIS source I guess. |
@ahuarte47 don't forget to add a C API for the GEOSGeometry method. |
ok, I had thought to add the code to GEOS when it is found in QGIS that this is correct. |
Hi @mhugo, about ... '... You plan to add this to GEOS ? Isn't it already extracted from liblwgeom ? ' The functionality is in PostGIS. It just uses GEOS calls, but the actual fixing is done in PostGIS: https://github.com/postgis/postgis/blob/svn-trunk/liblwgeom/lwgeom_geos_clean.c I have done a simple refactoring for inclusion in QgsGeometry. this code I want to include in GEOS (and C API). Best Regards |
assigned to @jef-n |
46ba8d5
to
6cebda7
Compare
fbcd47a
to
ad937f9
Compare
@jef-n @ahuarte47 could we please commit this before 2.6 is released? I regularly get contacted by students who wonder why polygons aren't being labelled. I just ran into this issue myself today: |
agree, this would be very important to merge now so we can test before the release. |
d277b76
to
d251857
Compare
d251857
to
cc46969
Compare
cc46969
to
6b10230
Compare
0c3a11d
to
8091494
Compare
Implements ST_MakeValid and AutomaticGeosValidation for QgsGeometry class
It does not fix the possible invalid polygons by default. The new generic automatic validation will do it.
What's left to do here @ahuarte47 ? Can you rebase to master and ensure travis passes ? |
Hi sandro, this pull request is obsolete from the changes in the QgsGeometry class using now the QgsGeometryPrivate struct. The automatic validation and repair of the geometry can not be needed now. But it would possible append the method QgsGeometry::makeValid for QGIS developers (cloned from method ST_MakeValid in postgis source code) if you think it as interesting. Otherwise, you can close this PR freely. Alvaro |
I'll close. Beside I think there was some interest in linking liblwgeom directly, that'd make the "makeValid" algorithm available to QGIS too. |
ok, thanks @strk |
@strk @ahuarte47 do you know what the current status regarding liblwgeom is? I gather that it's now its own library, independent from PostGIS. Should we revisit now making a makevalid function available in QGIS? |
liblwgeom implements it in: The code uses GEOS library. |
Actually, there are opposite forces pushing for liblwgeom.
While build scripts exist to install it separately and some packagers
do package it separately, there's no separate development branch
and release cycle for it.
My suggestion is to make the code conditional on availability of liblwgeom.
Chances are a liblwgeom replacement library, funded by Regione Toscana,
will be released by the first half of 2016:
https://lists.osgeo.org/pipermail/postgis-devel/2015-October/025376.html
|
Hi, related to this issue (many times caused by on-the-fly-simplification), I would like propose a change to avoid them! http://hub.qgis.org/issues/3517#note-17 Best regards |
This pull fixes the bug 9777 (http://hub.qgis.org/issues/9777) or others errors when GEOS uses an invalid geometry (labeling, centroid calculations, spatial operations, ...):
It implements the -ST_MakeValid- function for QgsGeometry class. The code is a fork from the original code in postgis implementation with slight changes:
https://github.com/postgis/postgis/blob/svn-trunk/liblwgeom/lwgeom_geos_clean.c
Also, the user can configure automatic validation of the fetched geometries of a layer and convert them to valid when needed.
The validation code is only executed when needed, drawing labels of a simplified geometry, or any code requires the GEOS geometry and this flag is enabled. If a simplified geometry is drawed without internally call to 'exportWkbToGeos()', as usual, then the validation is not executed and there is no penalty in the performance.