AddTopoGeometryColumn — Adds a topogeometry column to an existing table, registers this new column as a layer in topology.layer and returns the new layer_id.
integer AddTopoGeometryColumn(
varchar
topology_name, varchar
schema_name, varchar
table_name, varchar
column_name, varchar
feature_type)
;
integer AddTopoGeometryColumn(
varchar
topology_name, varchar
schema_name, varchar
table_name, varchar
column_name, varchar
feature_type, integer
child_layer)
;
Each TopoGeometry object belongs to a specific Layer of a specific Topology. Before creating a TopoGeometry object you need to create its TopologyLayer. A Topology Layer is an association of a feature-table with the topology. It also contain type and hierarchy information. We create a layer using the AddTopoGeometryColumn() function:
This function will both add the requested column to the table and add a record to the topology.layer table with all the given info.
If you don't specify [child_layer] (or set it to NULL) this layer would contain Basic TopoGeometries (composed by primitive topology elements). Otherwise this layer will contain hierarchical TopoGeometries (composed by TopoGeometries from the child_layer).
Once the layer is created (its id is returned by the AddTopoGeometryColumn function) you're ready to construct TopoGeometry objects in it
Valid feature_type
s are: POINT, MULTIPOINT, LINE, MULTILINE, POLYGON, MULTIPOLYGON, COLLECTION
Availability: 1.1
-- Note for this example we created our new table in the ma_topo schema -- though we could have created it in a different schema -- in which case topology_name and schema_name would be different CREATE SCHEMA ma; CREATE TABLE ma.parcels(gid serial, parcel_id varchar(20) PRIMARY KEY, address text); SELECT topology.AddTopoGeometryColumn('ma_topo', 'ma', 'parcels', 'topo', 'POLYGON');
CREATE SCHEMA ri; CREATE TABLE ri.roads(gid serial PRIMARY KEY, road_name text); SELECT topology.AddTopoGeometryColumn('ri_topo', 'ri', 'roads', 'topo', 'LINE');