[postgis-users] Repair topology: Replicate pprepair in Postgis

Lucas Ferreira Mation lucasmation at gmail.com
Wed Dec 16 03:05:08 PST 2015


Would it be possible to replicate what prepair
<https://github.com/tudelft3d/prepair>+pprepair
<https://github.com/tudelft3d/pprepair> do in Postgis?

Both algorithms use constrained triangulations. prepair takes polygons
individually and makes them valid. pprepair fixes holes and overlaps
between  polygons, thus correcting topological problems. The programs are
stand alone and run from the Terminal (linux or MAC). These have been
mentioned a few times in previous post on this list, as the magic solution
when people are trying to fix topological problems in polygons and people
seemed happy with the output.

In my experience, they are great, solving most of the topology problems.
However, upon loading the shapefile outputed by   prepair
<https://github.com/tudelft3d/prepair>>pprepair
<https://github.com/tudelft3d/pprepair> in Postgis, we still found some
problems: invalid polygons (some of which are composed of only lines and
points), a small number of remanescent overlaps, many polygons with spikes,
and sometimes non noded intersections (or at least that is the error
ST_Union gives).

Could the importing the prepair <https://github.com/tudelft3d/prepair>>
pprepair <https://github.com/tudelft3d/pprepair> output in Postgis be
introducing problems? Maybe vertex precision is degraded or something?

Would trying to recreate prepair and pprepair as a Postgis function make
sense?

I think the list bellow could be a feasible algorithm, but donĀ“t really
know how to implement each part:

prepair:

this is simpler because the fix takes in consideration the polygon itself

1) constrained triangulation of each polygon individually.

2) reconstruction of the polygons according to the rules described in the
documentation of prepair

pprepair:

this is more complicated because the fix must take into account how
polygons interact with their neighbors.

1) Node all intersections between polygons boundaries

2) Create a constrained triangulation of all (properly noded) boundaries of
all polygons in the table

3) For each "triangle", know:

- which original sectors they are contained in (will be more than one for
overlap areas, and none for gaps)

4) Reconstruct the original polygons according to the rules described in
pprepair documentation.


I would appreciate any help to find the appropriate functions in Postgis to
do this. Do the more recent versions of Postgis support noding of all
intersections and constrained triangulation?


regards

Lucas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20151216/1ed06a07/attachment.html>


More information about the postgis-users mailing list