toTopoGeom — Converts a simple Geometry into a topo geometry.
topogeometry toTopoGeom(geometry geom, varchar toponame, integer layer_id, float8 tolerance=-1);
topogeometry toTopoGeom(geometry geom, topogeometry topogeom, float8 tolerance=-1);
Converte uma simples geometria em TopoGeometry.
Topológicos primitivos requeridos para representar a geometria de entrada será adicionada a topologia oculta, possivelmente dividindo as existentes, e elas serão associadas com a TopoGeometria de saída na table relation.
Objetos existentes de TopoGeometria (com a possível exceção de topogeom, se dada) manterão suas formas.
When tolerance is given it will be used to snap the input geometry to existing primitives. The special value -1 (default) means use the topology precision as tolerance.
Na primeira forma, uma nova TopoGeometria será criada para a dada camada (layer_id) da topologia (toponame)
Na segunda forma, as rpimitivs resultantes da conversão serão adicionadas a uma TopoGeometria pre existente (topogeom), adicionando, possivelmente, espaço à sua forma final. Para obter a nova forma completamente substituir a antiga, veja clearTopoGeom.
Disponibilidade: 2.0
Melhorias: 2.1.0 adiciona a versão pegando uma TopoGeometria existente.
Changed: 3.7.0 changes meaning of tolerance 0 to really mean 0 and -1 (new default) to request using the topology precision.
Este é um fluxo de trabalho auto contido completo
-- 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
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 = toTopoGeom(ST_Buffer(topo, -10), clearTopoGeom(topo), 0);
-- 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
);
CreateTopology, AddTopoGeometryColumn, CreateTopoGeom, TopologySummary, clearTopoGeom