Add ST_MakeValid functionality to QgsGeometry?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Add ST_MakeValid functionality to QgsGeometry?

Larry_S
Hi,

Recently there have been several labeling-related issues where the
conclusion is that a label is not shown because the geometry is
invalid (generally polygons). I noticed Sandro Santilli's work for
PostGIS 2.0 with the new ST_MakeValid function [0]. I'm no geometry
whiz, but it appears to be based solely off of GEOS (and some other
PostGIS internals).

What's the likelihood that the ST_MakeValid function could be ported
to QGIS?... ending up with something like:

bool QgsGeometry::makeValid()
Converts an invalid geometry to a list of valid representative geometries
Returns:  true on success and false otherwise

For labeling, this might allow for some invalid geometries to be
labeled, since labeling engine already creates duplicate temporary
feature geometries to send to PAL. I see it in the GUI as a checkbox
PAL layer option, like 'Attempt to fix invalid geometries,' that would
be off by default, since the fixing operation might slow labeling
down. This may also help to label some clipped (but invalid) polygons
around the perimeter of the visible extent, when clipping is used.

While my focus is labeling, I'm pretty sure there would be other
reasons to have a geometry fixing solution in QgsGeometry as well.
Sorry if this has already been discussed, or even implemented
somewhere in the source (if so where?).

I researched some other quick, on-the-fly geometry-fixing solutions,
but the only other option appeared to be 'prepair' [1]. The prepair
results look good [2], but it has an additional dependency on a much
larger library, CGAL [3] (12 MB).

[0] http://svn.osgeo.org/postgis/trunk/postgis/lwgeom_geos_clean.c
[1] https://github.com/tudelft-gist/prepair
[2] http://www.gdmc.nl/ledoux/pdfs/_12agile.pdf
[3] http://www.cgal.org

Regards,

Larry
_______________________________________________
Qgis-developer mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/qgis-developer
Reply | Threaded
Open this post in threaded view
|

Re: Add ST_MakeValid functionality to QgsGeometry?

Giovanni Manghi-2
Hi Larry,

>
> What's the likelihood that the ST_MakeValid function could be ported
> to QGIS?... ending up with something like:


glad you raised this question. The common users really misses a tool to
allow easily fix geometries in QGIS, and the feedback is that when is
needed they usually use other GIS software (for example many of the
tools in the "vector" menu do not return the expected results if the
geometries are not valid).

Any improvement in this field would be very welcome.

cheers

-- Giovanni --

_______________________________________________
Qgis-developer mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/qgis-developer
Reply | Threaded
Open this post in threaded view
|

Re: Add ST_MakeValid functionality to QgsGeometry?

macho
hi
Yes a validity check would be great - although it sounds like a lot of work .
As I already had such problems with data from a friend of mine
(invalid geometry with wrong results in ftools) I also would love to
see such a check in QGIS.

kind regards
Werner


On Tue, Sep 18, 2012 at 2:06 PM, Giovanni Manghi
<[hidden email]> wrote:

> Hi Larry,
>
>>
>> What's the likelihood that the ST_MakeValid function could be ported
>> to QGIS?... ending up with something like:
>
>
> glad you raised this question. The common users really misses a tool to
> allow easily fix geometries in QGIS, and the feedback is that when is
> needed they usually use other GIS software (for example many of the
> tools in the "vector" menu do not return the expected results if the
> geometries are not valid).
>
> Any improvement in this field would be very welcome.
>
> cheers
>
> -- Giovanni --
>
> _______________________________________________
> Qgis-developer mailing list
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
_______________________________________________
Qgis-developer mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/qgis-developer
Reply | Threaded
Open this post in threaded view
|

Re: Add ST_MakeValid functionality to QgsGeometry?

Jürgen E. Fischer
In reply to this post by Larry_S
Hi Larry,

On Mon, 17. Sep 2012 at 14:15:42 -0600, Larry Shaffer wrote:
> Recently there have been several labeling-related issues where the
> conclusion is that a label is not shown because the geometry is
> invalid (generally polygons). I noticed Sandro Santilli's work for
> PostGIS 2.0 with the new ST_MakeValid function [0]. I'm no geometry
> whiz, but it appears to be based solely off of GEOS (and some other
> PostGIS internals).

The functionality is in PostGIS.  It just uses GEOS calls, but the
actual fixing is done in PostGIS (in lwgeom_geos_clean.c).

But we could adapt the code there for inclusion in QgsGeometry.


Jürgen

--
Jürgen E. Fischer         norBIT GmbH               Tel. +49-4931-918175-31
Dipl.-Inf. (FH)           Rheinstraße 13            Fax. +49-4931-918175-50
Software Engineer         D-26506 Norden               http://www.norbit.de
committ(ed|ing) to Quantum GIS                         IRC: jef on FreeNode                        

--
norBIT Gesellschaft fuer Unternehmensberatung und Informationssysteme mbH
Rheinstrasse 13, 26506 Norden
GF: Jelto Buurman, HR: Amtsgericht Emden, HRB 5502

_______________________________________________
Qgis-developer mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/qgis-developer