After creating some topological elements, it's time to link them with a feature table. A function, topology.CreateTopoGeom, is used to instantiate a TopoGeometry. It takes four arguments:
- Topology name
- Geometry type: 1 - Point, 2 - Line, 3 - Area, 4 - Collection
- TopoGeometry layer ID
- Array of TopoElements
Let's add the first created face as a fictional country, Nulland, to the countries table:
INSERT INTO countries(name,topogeom) VALUES('Nulland',topology.CreateTopoGeom('my_topology',3,1,'{{4258,3}}'::topology.topoelementarray));
A topoelementarray is a special helper type. It's an array of two-dimensional arrays, each composed of a topology element ID and its type (1-node,2-edge,3-face). The element's types must match the TopoGeometry type if it's not a collection (type 4); for type 1, only nodes are allowed; for type 2, only edges; and for type 3, only faces.
The next face we create with TopoGeo_AddPolygon is another fictional country, Neverland, from the following:
INSERT INTO countries(name,topogeom) VALUES('Neverland',topology.CreateTopoGeom('my_topology',3,1,'{{4259,3}}'::topology.topoelementarray));