Topology topology_ 3: Topology and topology geometry management

Posted by funkyres on Thu, 09 Dec 2021 18:42:32 +0100

3. Topology and topology geometry management

3.1. AddTopoGeometryColumn

AddTopoGeometryColumn - adds a topology geometry column to the existing table and registers the new column as a layer in the topology. And return to the new layer_id.

3.1. 1. Summary

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);

3.1. 2. Description

Each TopoGeometry object belongs to a specific layer of a specific topology. Before creating a TopoGeometry object, you need to create its TopologyLayer. Topology layer is the association between feature table and topology. It also contains type and hierarchy information. We use the AddTopoGeometryColumn() function to create a layer:

This function adds the requested column to the table and adds a record to the topology. Layer table with all given information.

If not specified child_layer , this layer will contain the basic topology geometry (composed of basic topology elements). Otherwise, the layer will contain hierarchical topology geometry (composed of topology geometry from child_layer).

Once the layer is created (its id is returned by the addtopogeometry column function), the TopoGeometry object can be constructed in it

Valid features_ Type: POINT, LINE, POLYGON, COLLECTION

3.1. 3. Example

-- Note that in this case, we are ma_topo A new table was created in the schema  
-- Although we can create it in different patterns -- in this case, topology_name and schema_name Will 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');

3.2. DropTopology

DropTopology - use with caution: delete the topology schema and remove its references from the topology. Topology table and from geometry_ The columns table references the tables in the schema.

3.2. 1. Summary

integer DropTopology(varchar topology_schema_name);

3.2. 2. Description

Delete the topology schema and remove its references from the topology. Topology tables and pairs from geometry in this schema_ References to the columns table. Be careful when using this function, because it may destroy the data you care about. If the schema does not exist, it simply deletes the reference entries in the named schema.

3.2. 3. Example

  • Cascade delete ma_topo mode and delete all references to it in the topology. Topology and geometry_columns.
SELECT topology.DropTopology('ma_topo');

3.3. DropTopoGeometryColumn

DropTopoGeometryColumn - in schema_ From the name mode, the name is table_ Delete the topology geometry column from the table of name and delete it from topology These columns are unregistered from the layer table.

3.3. 1. Summary

text DropTopoGeometryColumn(varchar schema_name, varchar table_name, varchar column_name);

3.3. 2. Description

From schema_ Table in name_ Name deletes the topology geometry columns from the topology table and unregisters them from the topology table. Returns a summary of the drop status. Note: it first sets all values to NULL and then deletes them to bypass the reference integrity check.

3.3. 3. Example

SELECT topology.DropTopoGeometryColumn('ma_topo', 'parcel_topo', 'topo');

3.4. Populate_Topology_Layer

Populate_Topology_Layer - adds missing entries to the topology. Read metadata from topology table.

3.4. 1. Summary

setof record Populate_Topology_Layer();

3.4. 2. Description

Add missing entries to the topology. Hierarchical tables by examining topology constraints on the tables. This function is used to repair entries in the topology catalog after using the topology data recovery mode.

It returns a list of items created. The returned column is schema_name, table_name, feature_column.

3.4. 3. Example

SELECT CreateTopology('strk_topo');
CREATE SCHEMA strk;
CREATE TABLE strk.parcels(gid serial, parcel_id varchar(20) PRIMARY KEY, address text);
SELECT topology.AddTopoGeometryColumn('strk_topo', 'strk', 'parcels', 'topo', 'POLYGON');

-- This will not return any records because the feature is already registered  
SELECT * FROM topology.Populate_Topology_Layer();

-- reconstruction
TRUNCATE TABLE topology.layer;

SELECT * FROM topology.Populate_Topology_Layer();
SELECT topology_id,layer_id, schema_name As sn, table_name As tn, feature_column As fc FROM topology.layer;
schema_nametable_namefeature_column
strkparcelstopo
topology_idlayer_idsntnfc
22strkparcelstopo

3.5 TopologySummary

TopologySummary - accepts the topology name and provides a summary of the object types in the topology

3.5. 1. Summary

text TopologySummary(varchar topology_schema_name);

3.5. 2. Description

Accept the topology name and provide a summary of the object types in the topology

3.5. 3. Example

SELECT topology.topologysummary('city_data');
topologysummary
Topology city_data (329), SRID 4326, precision: 0 22 nodes, 24 edges, 10 faces, 29 topogeoms in 5 layers

Layer 1, type Polygonal (3), 9 topogeoms Deploy: features.land_parcels.feature
Layer 2, type Puntal (1), 8 topogeoms Deploy: features.traffic_signs.feature
Layer 3, type Lineal (2), 8 topogeoms Deploy: features.city_streets.feature
Layer 4, type Polygonal (3), 3 topogeoms Hierarchy level 1, child layer 1 Deploy: features.big_parcels.feature
Layer 5, type Puntal (1), 1 topogeoms Hierarchy level 1, child layer 2 Deploy: features.big_signs.feature|

3.6. ValidateTopology

ValidateTopology - returns a set of validatetopologies_ ReturnType objects that describe the topology problem in detail

3.6. 1. Summary

setof validatetopology_returntype ValidateTopology(varchar topology_schema_name);

3.6. 2. Description

Returns a set of validatetopologies_ ReturnType object, which describes the topology problem in detail. The list of possible errors and the returned id are as follows:

Errorid1id2
Edge crosses nodeedge_idnode_id
Invalid edgeedge_idnull
Edge not simpleedge_idnull
Edge crosses edgeedge_idedge_id
Edge start node geometry MIS matchedge_idnode_id
Edge end node geometry MIS matchedge_idnode_id
Face without edgesface_idnull
Face has no ringsface_idnull
Face overlaps faceface_idface_id
Face within face innerface_idouter face_id

3.6. 3. Example

SELECT * FROM topology.ValidateTopology('ma_topo');
errorid1id2
face without edges0

Topics: PostgreSQL