#5336 closed defect (fixed)
topogeometry cast to topoelement
Reported by: | robe | Owned by: | robe |
---|---|---|---|
Priority: | medium | Milestone: | PostGIS 3.4.0 |
Component: | topology | Version: | master |
Keywords: | Cc: |
Description (last modified by )
When you want to pass in a topogeom as a topoelement for building, the syntax is pretty ugly and hard to explain.
As discussed in this thread https://lists.osgeo.org/pipermail/postgis-users/2023-February/045845.html
In order to build hierarchical topoelement using topogeom, you need to do this ugly thing of
TopoElementArray_Agg( ARRAY[(topo).id,(topo).layer_id]::topology.topoelement )
It would be cleaner if we have a topoelementArray_agg that takes a topogeometry or have topogeometry be able to autocast to a topoelement.
Then the above would reduce to
TopoElementArray_Agg( topo )
Change History (8)
comment:1 by , 22 months ago
Component: | postgis → topology |
---|---|
Owner: | changed from | to
comment:2 by , 22 months ago
Description: | modified (diff) |
---|
comment:3 by , 22 months ago
Summary: | topoelementarray_agg that takes topogeom → topoelementarray_agg that takes topogeometry |
---|
comment:4 by , 22 months ago
comment:5 by , 22 months ago
I'm going to test the performance of this out, but here is what my plan is.
CREATE OR REPLACE FUNCTION topology.topoelement(topo topology.topogeometry) RETURNS topology.topoelement LANGUAGE sql COST 1 IMMUTABLE PARALLEL SAFE AS $$SELECT ARRAY[topo.id,topo.layer_id]::topology.topoelement;$$; -- note you can't create a cast against a domain, but you can create a cast against the underlying type of domain CREATE CAST (topogeometry AS int[]) WITH FUNCTION topoelement(topogeometry) AS IMPLICIT;
Once you do the above:
This works:
SELECT TopoElementArray_Agg(NULL::topogeometry)
without the cast in place, you get error:
function topoelementarray_agg(topogeometry) does not exist
comment:7 by , 21 months ago
Summary: | topoelementarray_agg that takes topogeometry → topogeometry cast to topoelement |
---|
If you do this consider making sure all topogeometries are from the same topology and layer_id, as can only imagine trouble if you try to create a TopoGeometry composed by elements coming from different topologies (we don't have referential integrity there)