名称

toTopoGeom — 将简单几何转换为拓扑几何。

概要

topogeometry toTopoGeom(geometry geom, varchar toponame, integer layer_id, float8 tolerance);

topogeometry toTopoGeom(geometry geom, topogeometry topogeom, float8 tolerance);

描述

将简单几何转换为 TopoGeometry

表示输入几何所需的拓扑基元将被添加到底层拓扑中,可能会将现有基元分割,并且它们将在 relation 表中与输出 TopoGeometry 关联。

现有的 TopoGeometry 对象(如果给出,则可能除 topogeom 外)将保留其形状。

当给出 tolerance 时,它将用于将输入几何捕捉到现有基元。

在第一种形式中,将为给定拓扑 (toponame) 的给定图层 (layer_id) 创建一个新的 TopoGeometry。

在第二种形式中,转换产生的基元将被添加到预先存在的 TopoGeometry (topogeom) 中,可能会为其最终形状添加空间。要使新形状完全替换旧形状,请参见 clearTopoGeom

可用性:2.0

增强:2.1.0 添加了采用现有 TopoGeometry 的版本。

示例

这是一个完整的自包含工作流程

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

另请参见

CreateTopologyAddTopoGeometryColumnCreateTopoGeomTopologySummaryclearTopoGeom