<html><body><div><div><span>Hi,</span></div><br><div><span>I am trying to use the </span><code style="padding:0 4px;background-color:#F5F5F5;border-radius:4px;font-weight:500"><span>RemoveUnusedPrimitives</span></code><span> function to clean up my topology and clean unnecessary primitives in the following (not working) way.</span></div><br><div><span>I have created a topology using </span></div><br><div><b><span>SELECT</span></b><span> createtopology('master_topology', 3763);</span></div><br><div><span>To an existing linestring table I have added a topogeometry column using the following:</span></div><br><div><b><span>SELECT</span></b><span> addtopogeometrycolumn(</span></div><div><span> 'master_topology',</span></div><div><span> 'temp',</span></div><div><span> 'lines',</span></div><div><span> 'topo',</span></div><div><span> 'LINESTRING'</span></div><div><span>);</span></div><br><div><span>I have added a bunch of connecting lines to the temp.lines, them I populated the topo column:</span></div><br><div><b><span>UPDATE</span></b><span> </span><b><span>temp</span></b><span>.troco </span><b><span>SET</span></b></div><div><span>topo = totopogeom(geom, 'master_topology',1)</span></div><br><div><span>So far so good, I was able to load my faces in QGIS using this:</span></div><br><div><b><span>SELECT</span></b><span> face_id, st_getfacegeometry('master_topology', face_id) </span><b><span>AS</span></b><span> geom</span></div><div><b><span>FROM</span></b><span> master_topology.face</span></div><div><b><span>WHERE</span></b><span> face_id > 0;</span></div><br><div><span>Now I decided to remove one of the linestrings that splited two polygons.</span></div><br><div><span>And I rerun the updated on the topo columns:</span></div><br><div><b><span>UPDATE</span></b><span> </span><b><span>temp</span></b><span>.troco </span><b><span>SET</span></b></div><div><span>topo = totopogeom(geom, 'master_topology',1)</span></div><br><div><span>Now, I expected to have edges, and eventually nodes on my topology that are not used in any topogeometry, so I tried to clean up the topology using RemoveUnusedPrimitives</span></div><br><div><b><span>SELECT</span></b><span> RemoveUnusedPrimitives('master_topology');</span></div><br><div><span>It returned saying that no edges were removed. Because the function documentation asked for a extent I have also tried adding one:</span></div><br><div><b><span>WITH</span></b><span> all_geom </span><b><span>AS</span></b><span> (</span></div><div><b><span>SELECT</span></b><span> st_collect(geom) </span><b><span>AS</span></b><span> geom </span><b><span>FROM</span></b><span> temp.lines</span></div><div><span>)</span></div><div><b><span>SELECT</span></b><span> RemoveUnusedPrimitives('master_topology', </span><b><span>st_setsrid</span></b><span>(st_extent(geom),3763))</span></div><div><b><span>FROM</span></b><span> all_geom;</span></div><br><div><span>But I got the exact same result.</span></div><div><span>My idea was to keep the topology in sync with the lines geometries by running this steps in trigger functions and be able to get the updated faces as well whenever needed. Since this steps did not work, I am wondering if the function does what I was expecting to do, or if my workflow makes no sense at all.</span></div><br><div><span>Thanks,</span></div><br><div><span>Alexandre Neto</span></div></div></body></html>