toTopoGeom
Name
toTopoGeom — Converts a simple Geometry into a topo geometry.
Synopsis
topogeometry
toTopoGeom
(
geometry
geom
, varchar
toponame
, integer
layer_id
, float8
tolerance
)
;
topogeometry
toTopoGeom
(
geometry
geom
, topogeometry
topogeom
, float8
tolerance
)
;
Description
Converts a simple Geometry into a TopoGeometry .
Topological primitives required to represent the input geometry will be
added to the underlying topology, possibly splitting existing ones,
and they will be associated with the output TopoGeometry in the
relation
table.
Existing TopoGeometry objects (with the possible exception of
topogeom
, if given) will retain their shapes.
When
tolerance
is given it will be used to snap the
input geometry to existing primitives.
In the first form a new TopoGeometry will be created for the given
layer (
layer_id
) of the given topology (
toponame
).
In the second form the primitives resulting from the conversion will be
added to the pre-existing TopoGeometry (
topogeom
),
possibly adding space to its final shape. To have the new shape completely
replace the old one see
clearTopoGeom
.
Availability: 2.0
Enhanced: 2.1.0 adds the version taking an existing TopoGeometry.
Examples
This is a full self-contained workflow
-- do this if you don't have a topology setup already -- creates topology not allowing any tolerance SELECT topology.CreateTopology('topo_boston_test', 2249); -- create a new table CREATE TABLE nei_topo(gid serial primary key, nei varchar(30)); --add a topogeometry column to it SELECT topology.AddTopoGeometryColumn('topo_boston_test', 'public', 'nei_topo', 'topo', 'MULTIPOLYGON') As new_layer_id; new_layer_id ----------- 1 --use new layer id in populating the new topogeometry column -- we add the topogeoms to the new layer with 0 tolerance INSERT INTO nei_topo(nei, topo) SELECT nei, topology.toTopoGeom(geom, 'topo_boston_test', 1) FROM neighborhoods WHERE gid BETWEEN 1 and 15; --use to verify what has happened -- SELECT * FROM topology.TopologySummary('topo_boston_test'); -- summary-- Topology topo_boston_test (5), SRID 2249, precision 0 61 nodes, 87 edges, 35 faces, 15 topogeoms in 1 layers Layer 1, type Polygonal (3), 15 topogeoms Deploy: public.nei_topo.topo
-- Shrink all TopoGeometry polygons by 10 meters UPDATE nei_topo SET topo = ST_Buffer(clearTopoGeom(topo), -10); -- Get the no-one-lands left by the above operation -- I think GRASS calls this "polygon0 layer" SELECT ST_GetFaceGeometry('topo_boston_test', f.face_id) FROM topo_boston_test.face f WHERE f.face_id > 0 -- don't consider the universe face AND NOT EXISTS ( -- check that no TopoGeometry references the face SELECT * FROM topo_boston_test.relation WHERE layer_id = 1 AND element_id = f.face_id );