toTopoGeom — 将简单几何图形转换为拓扑几何图形。
topogeometry toTopoGeom(
geometry geom, varchar toponame, integer layer_id, float8 tolerance)
;
topogeometry toTopoGeom(
geometry geom, topogeometry topogeom, float8 tolerance)
;
将简单的几何图形转换为拓扑几何图形TopoGeometry。
表示输入几何所需的拓扑基元将被添加到底层拓扑中,可能会拆分现有拓扑,并且它们将与关系
表中的输出 TopoGeometry 相关联。
现有的 TopoGeometry 对象(拓扑几何
可能除外,如果给定的话)将保留其形状。
当给出公差
时,它将用于将输入几何体捕捉到现有图元。
在第一种形式中,将为给定拓扑 (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 = 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 );