<div dir="ltr"><p dir="ltr">Would it be possible to replicate what <a href="https://github.com/tudelft3d/prepair">prepair</a>+<a href="https://github.com/tudelft3d/pprepair">pprepair</a> do in Postgis? </p>
<p dir="ltr">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. </p><p dir="ltr">In my experience, they are great, solving most of the topology problems. However, upon loading the shapefile outputed by   <a href="https://github.com/tudelft3d/prepair">prepair</a>><a href="https://github.com/tudelft3d/pprepair">pprepair</a> 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). <br></p><p>Could the importing the <a href="https://github.com/tudelft3d/prepair">prepair</a>><a href="https://github.com/tudelft3d/pprepair">pprepair</a> output in Postgis be introducing problems? Maybe vertex precision is degraded or something?</p><p>Would trying to recreate prepair and pprepair as a Postgis function make sense?</p><p>I think the list bellow could be a feasible algorithm, but don´t really know how to implement each part:</p><p>prepair:</p><p>this is simpler because the fix takes in consideration the polygon itself</p><p>1) constrained triangulation of each polygon individually. </p><p>2) reconstruction of the polygons according to the rules described in the documentation of prepair</p><p>pprepair:</p><p>this is more complicated because the fix must take into account how polygons interact with their neighbors. </p><p>1) Node all intersections between polygons boundaries</p><p>2) Create a constrained triangulation of all (properly noded) boundaries of all polygons in the table</p><p>3) For each "triangle", know:</p><p>- which original sectors they are contained in (will be more than one for overlap areas, and none for gaps)</p><p>4) Reconstruct the original polygons according to the rules described in pprepair documentation. </p><p><br>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? </p><p><br></p><p>regards</p><p>Lucas</p><p><br></p><p> </p><p><br></p><p><br></p><p><br></p>
<p dir="ltr"> </p>
</div>