CreateTopoGeom — 지형 요소 배열로부터 새 지형 도형 객체를 생성합니다. tg_type은 1: [멀티]포인트, 2: [멀티]라인, 3: [멀티]폴리곤, 4: 도형 집합입니다.
topogeometry CreateTopoGeom(varchar toponame, integer tg_type, integer layer_id, topoelementarray tg_objs, bigint tg_id);
topogeometry CreateTopoGeom(varchar toponame, integer tg_type, integer layer_id);
Creates a topogeometry object for layer denoted by layer_id and registers it in the relations table in the toponame schema.
tg_type is an integer: 1:[multi]point (punctal), 2:[multi]line (lineal), 3:[multi]poly (areal), 4:collection. layer_id is the layer id in the topology.layer table.
노드들의 집합이 점형 레이어를 형성하고, 경계선들의 집합이 선형 레이어를 형성하고, 표면들의 집합이 면형 레이어를 형성하며, 노드, 경계선, 표면의 혼합 집합이 도형 집합을 형성할 수 있습니다.
구성 요소 배열을 생략하면 텅 빈 TopoGeometry 객체를 생성합니다.
Availability: 1.1
Create a topogeom in ri_topo schema for layer 2 (our ri_roads), of type (2) LINE, for the first edge (we loaded in ST_CreateTopoGeo).
INSERT INTO ri.ri_roads(road_name, topo) VALUES('Unknown', topology.CreateTopoGeom('ri_topo',2,2,'{{1,2}}'::topology.topoelementarray);
표면들의 집합으로 형성돼야 하는 도형을 가지고 있다고 해봅시다. 예를 들어 blockgroups 테이블이 있는데 각 블록 그룹의 TopoGeometry를 알고 싶습니다. 데이터가 완벽하게 정렬돼 있다면, 다음과 같이 할 수 있습니다:
Create the topogeometry column.
SELECT topology.AddTopoGeometryColumn(
'topo_boston',
'boston', 'blockgroups', 'topo', 'POLYGON');
1
Update the column assuming everything is perfectly aligned with the edges.
UPDATE boston.blockgroups AS bg
SET topo = topology.CreateTopoGeom(
'topo_boston',
3, 1,
foo.bfaces)
FROM (SELECT b.gid, topology.TopoElementArray_Agg(ARRAY[f.face_id,3]) As bfaces
FROM boston.blockgroups As b
INNER JOIN topo_boston.face As f ON b.geom && f.mbr
WHERE ST_Covers(b.geom, topology.ST_GetFaceGeometry('topo_boston', f.face_id))
GROUP BY b.gid) As foo
WHERE foo.gid = bg.gid;
The world is rarely perfect, so this version allows some error. It counts a face if 50 percent of it falls within the expected block group boundary.
UPDATE boston.blockgroups AS bg
SET topo = topology.CreateTopoGeom(
'topo_boston',
3, 1,
foo.bfaces)
FROM (SELECT b.gid, topology.TopoElementArray_Agg(ARRAY[f.face_id,3]) As bfaces
FROM boston.blockgroups As b
INNER JOIN topo_boston.face As f ON b.geom && f.mbr
WHERE ST_Covers(b.geom, topology.ST_GetFaceGeometry('topo_boston', f.face_id))
OR
( ST_Intersects(b.geom, topology.ST_GetFaceGeometry('topo_boston', f.face_id))
AND ST_Area(ST_Intersection(b.geom, topology.ST_GetFaceGeometry('topo_boston', f.face_id) ) ) >
ST_Area(topology.ST_GetFaceGeometry('topo_boston', f.face_id))*0.5
)
GROUP BY b.gid) As foo
WHERE foo.gid = bg.gid;
To convert the topogeometry back to a denormalized geometry aligned with faces and edges, cast the topogeometry to a geometry. The resulting geometries are aligned with the TIGER street centerlines.
UPDATE boston.blockgroups SET new_geom = topo::geometry;