[postgis-users] Topology: error creating aggregated topogeom (at city level) from a neighborhoods topogeom

Sandro Santilli strk at keybit.net
Sat Jan 30 14:09:09 PST 2016


On Sat, Jan 30, 2016 at 01:39:49AM -0200, Lucas Ferreira Mation wrote:

> --2) Creating the more aggregated cities table and adding a topogeometry
> 
> CREATE TABLE cities AS
> SELECT     substring(cod_set,1,7) AS cod_mun
> FROM temp_geom_ac
> GROUP BY substring(cod_set,1,7)
> SELECT topology.addtopogeometrycolumn('topo_AC',
> 'public','cities','tg_cities','POLYGON');

You're not defining a hierarchical layer here, but a primitive one.
For a hierarchical one you'll want to pass an additional parameter
specifying the cchild layer identifier.

> -- at this pooint these are the contents of topology.layer table
> 
> -- 
> topology_id;layer_id;shcema_name;table_name;feature_column;feature_type;child_id
> -- 15;1;"public";"temp_geom_ac";"tg_geom_dump_utm";3;0;NULL
> -- 15;2;"public";"cities";"tg_cities";3;NULL

See the child_id=NULL field, means both are primitive layers.

> TopoElementArray_Agg(ARRAY[(tg_geom_dump_utm).id,(tg_geom_dump_utm).layer_id])

Here you're trying to pass a "layer_id" as the "type" of component
for a non-hierarchical layer, thus the error

> -- ERROR:  A TopoGeometry of type 3 cannot contain topology elements of
> type 1

It's telling you that an "areal" TopoGeometry (type 3) cannot
be defined by a "line component" (type 1).

> The error above is weird. I tell the function tg_type =3 (areal), but
> somehow it is considering it to be 1 (point).

Right, which is what you're passing as the second number in
the TopoGeometry. Read http://postgis.net/docs/topoelement.html

--strk;


More information about the postgis-users mailing list