CreateTopoGeom — Cria uma novo objeto de topo geometria de um arranjo topo elemento - tg_type: 1:[multi]point, 2:[multi]line, 3:[multi]poly, 4:collection
topogeometry CreateTopoGeom(
varchar toponame, integer tg_type, integer layer_id, topoelementarray tg_objs)
;
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.
camadas pontuais são formadas a partir de um conjunto de nós, camadas lineares são formadas a partir de um conjunto de bordas, camadas areais são formadas a partir de um conjunto de faces e as coleções podem ser formadas a partir de uma mistura de nós, bordas e faces.
Omitir o arranjo de componentes gera um objeto TopoGeometria vazio.
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);
Digamos que tenhamos geometrias que deveriam ser formadas de uma coleção de faces. Nós temos, por exemplo, blockgroupos tables e queremos saber a topo geometria de cada block group. Se seus dados foram perfeitamente alinhados, podemos fazer isto:
-- create our topo geometry column -- SELECT topology.AddTopoGeometryColumn( 'topo_boston', 'boston', 'blockgroups', 'topo', 'POLYGON'); -- addtopgeometrycolumn -- 1 -- update our column assuming -- everything is perfectly aligned with our 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 allow for some error --count the face if 50% of it falls -- within what we think is our blockgroup 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; -- and if we wanted to convert our topogeometry back -- to a denormalized geometry aligned with our faces and edges -- cast the topo to a geometry -- The really cool thing is my new geometries -- are now aligned with my tiger street centerlines UPDATE boston.blockgroups SET new_geom = topo::geometry;