<html><body><div><div><span>Hi Sandro,</span></div><br><div><span>Many thanks for your answer, I think that running the clearTopoGeom in the trigger function may work, as the idea is do all this inside a before update trigger function row by row, whenever the original geometry is changed.</span></div><br><div><span>Thanks,</span></div><br><div><span>Alexandre Neto</span></div></div><br><div><div>On Tue Nov 7, 2023, 11:33 AM GMT, <a href="mailto:strk@kbt.io">Sandro Santilli</a> wrote:<br></div><blockquote style="margin:0 0 0 4pt;padding-left:4pt;border-left:1px solid #CCC"><div style="color:#212121;font-size:14px;font-weight:normal;line-height:20px">On Thu, Nov 02, 2023 at 03:26:22PM +0000, Alexandre Neto via postgis-users wrote:<br><blockquote>UPDATE temp.troco SET<br>topo = totopogeom(geom, 'master_topology',1)</blockquote><br>[..]<br><blockquote>Now I decided to remove one of the linestrings that splited two polygons.<br><br>And I rerun the updated on the topo columns:<br><br>UPDATE temp.troco SET<br>topo = totopogeom(geom, 'master_topology',1)</blockquote><br>This call does NOT remove the old TopoGeometries, which are left<br>orphaned (defined but not appearing in any TopoLogy Layer).<br><br>The returned text from this query should mention this problem:<br><br> SELECT TopologySummary('master_topology')<br><br>The clearTopoGeom function can be used to destroy a TopoGeometry,<br>but at this point it would probably be faster for you to do the<br>cleanup with direct DELETE on master_topology.relation WHERE the<br>layer_id/topogeo_id pair are not found in their respective layers<br>(dangerous operation). Suggestion/patches are welcome to improve<br>this situation. I've also noted the example for clearTopoGeom on<br>the manual is misleading:<br><br> https://postgis.net/docs/clearTopoGeom.html<br><blockquote>SELECT RemoveUnusedPrimitives('master_topology');<br>It returned saying that no edges were removed.</blockquote><br>It should tell you more if you:<br><br> set client_min_messages to debug;<br><blockquote>My idea was to keep the topology in sync with the lines geometries by running this steps in trigger functions</blockquote><br>Maybe you can consider running the clearTopoGeom in a trigger function<br>too (on UPDATE...)<br><br>--strk;<br></div></blockquote></div></body></html>