Topology topology_ 4: Topology constructor

Posted by Peredy on Fri, 10 Dec 2021 17:21:15 +0100

4. Topology constructor

4.1. CreateTopology

CreateTopology - create a new topology schema and register the new schema in the topology. Topology table.

4.1. 1. Summary

integer CreateTopology(varchar topology_schema_name);
integer CreateTopology(varchar topology_schema_name, integer srid);
integer CreateTopology(varchar topology_schema_name, integer srid, double precision prec);
integer CreateTopology(varchar topology_schema_name, integer srid, double precision prec, boolean hasz);

4.1. 2. Description

Create a named topology_ The new schema of name is composed of tables (edge_data, face, node and relationship), and the new topology is registered in the topology. Topology table. It returns the id of the topology in the topology table. srid is the spatial in the topology_ ref_ The spatial reference defined in the sys table. Topology must be uniquely named. Tolerances are measured in spatial reference systems. If no tolerance (prec) is specified, the default value is 0.

This is similar to SQL/MM ST_InitTopoGeo, but more powerful. Hasz defaults to false, if not specified.

4.1. 3. Example

This example creates a named ma_topo's new schema, which stores edges, faces, and relationships in the Massachusetts State Plane instrument. Since the spatial reference system is a meter based spatial reference system, the tolerance represents 1 / 2 meter

SELECT topology.CreateTopology('ma_topo',26986, 0.5);

Create Rhode Island topology in the state plane

SELECT topology.CreateTopology('ri_topo',3438) As topoid;
topoid
2

4.2 CopyTopology

CopyTopology - copy topology (nodes, edges, faces, layers, and topology geometry).

4.2. 1. Summary

integer CopyTopology(varchar existing_topology_name, varchar new_name);

4.2. 2. Description

Create a new topology named new_topology_name and SRID, precision from existing_topology_name, copy all nodes, edges and faces, and also copy layers and their TopoGeometries.

A new row in the topology. The layer will contain the schema_name,table_name and feature_ The composite value of column. This is because TopoGeometry will only exist as a definition, but it cannot be used in any user level table.

4.2. 3. Example

  • This example pair is named ma_topo's topology is backed up
SELECT topology.CopyTopology('ma_topo', 'ma_topo_bakup');

4.3 ST_InitTopoGeo

ST_InitTopoGeo - create a new topology schema and register the new schema in the topology. Topology table and detailed summary of the process.

4.3. 1. Summary

text ST_InitTopoGeo(varchar topology_schema_name);

4.3. 2. Description

This is an SQL-MM equivalent CreateTopology, but lacks the spatial reference and tolerance options of CreateTopology, and outputs the created text description instead of the topology id.

4.3. 3. Example

SELECT topology.ST_InitTopoGeo('topo_schema_to_create') AS topocreation;
astopocreation
Topology-Geometry 'topo_schema_to_create' (id:7) created.

4.4. ST_CreateTopoGeo

ST_CreateTopoGeo - adds a collection of geometry to a given empty topology and returns a message detailing success.

4.4. 1. Summary

text ST_CreateTopoGeo(varchar atopology, geometry acollection);

4.4. 2. Description

Adds a collection of geometry to the given empty topology and returns a message detailing the success.
Useful for populating empty topologies

4.4. 3. Example

  • Fill topology
SELECT topology.ST_CreateTopoGeo('ri_topo',
ST_GeomFromText('MULTILINESTRING((384744 236928,384750 236923,384769 236911,384799 236895,384811 236890,384833 236884,
            384844 236882,384866 236881,384879 236883,384954 236898,385087 236932,385117 236938,
            385167 236938,385203 236941,385224 236946,385233 236950,385241 236956,385254 236971,
            385260 236979,385268 236999,385273 237018,385273 237037,385271 237047,385267 237057,
            385225 237125,385210 237144,385192 237161,385167 237192,385162 237202,385159 237214,
            385159 237227,385162 237241,385166 237256,385196 237324,385209 237345,385234 237375,
            385237 237383,385238 237399,385236 237407,385227 237419,385213 237430,385193 237439,
            385174 237451,385170 237455,385169 237460,385171 237475,385181 237503,385190 237521,
            385200 237533,385206 237538,385213 237541,385221 237542,385235 237540,385242 237541,
            385249 237544,385260 237555,385270 237570,385289 237584,385292 237589,385291 237596,385284 237630))',3438)
);
st_createtopogeo
Topology ri_topo populated
  • Create tables and topology geometry
CREATE TABLE ri.roads(gid serial PRIMARY KEY, road_name text);

SELECT topology.AddTopoGeometryColumn('ri_topo', 'ri', 'roads', 'topo', 'LINE');

4.5. TopoGeo_AddPoint

TopoGeo_AddPoint - adds a point to an existing topology using tolerance (possibly splitting existing edges).

4.5. 1. Summary

integer TopoGeo_AddPoint(varchar toponame, geometry apoint, float8 tolerance);

4.5. 2. Description

Adds a point to an existing topology and returns its identifier. A given point will be connected to an existing node or edge within a given tolerance. Existing edges may be segmented by break points.

4.6. TopoGeo_AddLineString

TopoGeo_AddLineString - adds a line string to an existing topology using tolerances and possibly splitting existing edges / faces. Returns the edge identifier

4.6. 1. Summary

SETOF integer TopoGeo_AddLineString(varchar toponame, geometry aline, float8 tolerance);

4.6. 2. Description

Adds a linestring to an existing topology and returns a set of edge identifiers that make up the topology. A given line will merge with an existing node or edge within a given tolerance. Existing edges and faces may be separated by lines.

4.7. TopoGeo_AddLineString

TopoGeo_AddPolygon - adds polygons to an existing topology using tolerances and possibly splitting existing edges / faces.

4.7. 1. Summary

integer TopoGeo_AddPolygon(varchar atopology, geometry apoly, float8 atolerance);

4.7. 2. Description

Adds a polygon to an existing topology and returns the set of face identifiers that make up the topology. The boundaries of a given polygon align with existing nodes or edges within a given tolerance. Existing edges and faces may be split by the boundaries of the new polygon.

Topics: PostgreSQL