[postgis-users] Topology - RemoveUnusedPrimitives workflow

Sandro Santilli strk at kbt.io
Tue Nov 7 05:57:30 PST 2023


On November 7, 2023 12:40:47 PM GMT+01:00, Alexandre Neto <senhor.neto at gmail.com> wrote:
>Hi Sandro,
>
>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.
>
>Thanks,
>
>Alexandre Neto
>
>On Tue Nov 7, 2023, 11:33 AM GMT, Sandro Santilli <mailto:strk at kbt.io> wrote:
>> On Thu, Nov 02, 2023 at 03:26:22PM +0000, Alexandre Neto via postgis-users wrote:
>>> UPDATE temp.troco SET
>>> topo = totopogeom(geom, 'master_topology',1)
>>
>> [..]
>>> Now I decided to remove one of the linestrings that splited two polygons.
>>>
>>> And I rerun the updated on the topo columns:
>>>
>>> UPDATE temp.troco SET
>>> topo = totopogeom(geom, 'master_topology',1)
>>
>> This call does NOT remove the old TopoGeometries, which are left
>> orphaned (defined but not appearing in any TopoLogy Layer).
>>
>> The returned text from this query should mention this problem:
>>
>> SELECT TopologySummary('master_topology')
>>
>> The clearTopoGeom function can be used to destroy a TopoGeometry,
>> but at this point it would probably be faster for you to do the
>> cleanup with direct DELETE on master_topology.relation WHERE the
>> layer_id/topogeo_id pair are not found in their respective layers
>> (dangerous operation). Suggestion/patches are welcome to improve
>> this situation. I've also noted the example for clearTopoGeom on
>> the manual is misleading:
>>
>> https://postgis.net/docs/clearTopoGeom.html
>>> SELECT RemoveUnusedPrimitives('master_topology');
>>> It returned saying that no edges were removed.
>>
>> It should tell you more if you:
>>
>> set client_min_messages to debug;
>>> My idea was to keep the topology in sync with the lines geometries by running this steps in trigger functions
>>
>> Maybe you can consider running the clearTopoGeom in a trigger function
>> too (on UPDATE...)
>>
>> --strk;
Feel free to file an enhancement ticket for a RemoveOrphamedTopogeometries function to clean up the state you found yourself in 

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.


More information about the postgis-users mailing list