PostGIS 3.5 Topology Cheatsheet

New in this release 1Enhanced in this release 2   Requires GEOS (3.9,3.10,3.11,3.12) or higher g3.9  
Tipos de topologia
getfaceedges_returntype    A composite type that consists of a sequence number and an edge number.
TopoGeometry    A composite type representing a topologically defined geometry.
validatetopology_returntype    A composite type that consists of an error message and id1 and id2 to denote location of error. This is the return type for ValidateTopology.

Domínios de Topologia
TopoElement    Um arranjo de 2 inteiros geralmente usado para identificar um componente TopoGeometry.
TopoElementArray    An array of TopoElement objects.

Gerenciamento de Topologia e TopoGeometria
AddTopoGeometryColumn    Adiciona uma coluna topogeometria a uma table, registra essa coluna nova como uma camada topology.layer e retorna a nova layer_id.
  1. topology_name, schema_name, table_name, column_name, feature_type
  2. topology_name, schema_name, table_name, column_name, feature_type, child_layer
RenameTopoGeometryColumn (layer_table, feature_column, new_name)    Renames a topogeometry column
DropTopology (topology_schema_name)    Cuidado ao usar: Derruba um esquema topologia e deleta sua referência da table topology.topology e referências para tables naquele esquema da table geometry_columns.
RenameTopology (old_name, new_name)    Renames a topology
DropTopoGeometryColumn (schema_name, table_name, column_name)    Derruba a coluna topogeometria da table nomeada table_name no esquema schema_name e tira os registros da
Populate_Topology_Layer ()    Adds missing entries to topology.layer table by reading metadata from topo tables.
TopologySummary (topology_schema_name)    Takes a topology name and provides summary totals of types of objects in topology.
ValidateTopology (toponame, bbox)    Returns a set of validatetopology_returntype objects detailing issues with topology.
ValidateTopologyRelation (toponame)    Returns info about invalid topology relation records
FindTopology    Returns a topology record by different means.
  1. topogeom
  2. layerTable, layerColumn
  3. layerSchema, layerTable, layerColumn
  4. topoName
  5. id
FindLayer    Returns a topology.layer record by different means.
  1. tg
  2. layer_table, feature_column
  3. schema_name, table_name, feature_column
  4. topology_id, layer_id

Topology Statistics Management

Construtores de topologia
CreateTopology    Creates a new topology schema and registers it in the topology.topology table.
  1. topology_schema_name
  2. topology_schema_name, srid
  3. topology_schema_name, srid, prec
  4. topology_schema_name, srid, prec, hasz
CopyTopology (existing_topology_name, new_name)    Makes a copy of a topology (nodes, edges, faces, layers and TopoGeometries) into a new schema
ST_InitTopoGeo  mm (topology_schema_name)    Creates a new topology schema and registers it in the topology.topology table.
ST_CreateTopoGeo  mm (atopology, acollection)    Adiciona uma coleção de geometrias para uma dada topologia vazia e retorna uma mensagem detalhando sucesso.
TopoGeo_AddPoint (atopology, apoint, tolerance)    Adiciona um ponto a uma topologia usando uma tolerância e possivelmente dividindo um limite existente.
TopoGeo_AddLineString (atopology, aline, tolerance)    Adds a linestring to an existing topology using a tolerance and possibly splitting existing edges/faces. Returns edge identifiers.
TopoGeo_AddPolygon (atopology, apoly, tolerance)    Adds a polygon to an existing topology using a tolerance and possibly splitting existing edges/faces. Returns face identifiers.
TopoGeo_LoadGeometry  1 (atopology, ageom, tolerance)    Load a geometry into an existing topology, snapping and splitting as needed.

Editores de Topologia
ST_AddIsoNode  mm (atopology, aface, apoint)    Adiciona um nó isolado a uma face em uma topologia e retorna a id do novo nó. Se a face é nula, o nó continua sendo criado.
ST_AddIsoEdge  mm (atopology, anode, anothernode, alinestring)    Adiciona um limite isolado definido pela geometria alinestring a uma topologia conectando dois nós isoladosanode e anothernode e retorna a nova id do novo limite.
ST_AddEdgeNewFaces  mm (atopology, anode, anothernode, acurve)    Adiciona um novo limite e, se uma face for dividida, deleta a face original e substitui por duas novas faces.
ST_AddEdgeModFace  mm (atopology, anode, anothernode, acurve)    Adiciona um novo limite e, se uma face for dividida, modifica a face original e adiciona uma nova face.
ST_RemEdgeNewFace  mm (atopology, anedge)    Remove um limite e, se o limite removido separava duas faces, deleta as faces originais e as substitui por uma nova face.
ST_RemEdgeModFace  mm (atopology, anedge)    Removes an edge, and if the edge separates two faces deletes one face and modifies the other face to cover the space of both.
ST_ChangeEdgeGeom  mm (atopology, anedge, acurve)    Modifica a forma de um limite sem afetar a estrutura da topologia.
ST_ModEdgeSplit  mm (atopology, anedge, apoint)    Divide um limite criando um novo nó junto de um limite existente, modificando o limite original e adicionando um novo limite.
ST_ModEdgeHeal  mm (atopology, anedge, anotheredge)    Heals two edges by deleting the node connecting them, modifying the first edge and deleting the second edge. Returns the id of the deleted node.
ST_NewEdgeHeal  mm (atopology, anedge, anotheredge)    Heals two edges by deleting the node connecting them, deleting both edges, and replacing them with an edge whose direction is the same as the first edge provided.
ST_MoveIsoNode  mm (atopology, anode, apoint)    Moves an isolated node in a topology from one point to another. If new apoint geometry exists as a node an error is thrown. Returns description of move.
ST_NewEdgesSplit  mm (atopology, anedge, apoint)    Divide um limite criando um novo nó ao longo do limite existente, deletando o limite original e substituindo-o por dois novos. Retorna a id do novo nó criado que integra os novos limites.
ST_RemoveIsoNode  mm (atopology, anode)    Remove um nó isolado e retorna descrição de ação. Se o nó não for isolado (for começo ou fim de um limite), então, uma exceção é lançada.
ST_RemoveIsoEdge  mm (atopology, anedge)    Removes an isolated edge and returns description of action. If the edge is not isolated, then an exception is thrown.

Assessores de Topologia
GetEdgeByPoint (atopology, apoint, tol1)    Finds the edge-id of an edge that intersects a given point.
GetFaceByPoint (atopology, apoint, tol1)    Finds face intersecting a given point.
GetFaceContainingPoint (atopology, apoint)    Finds the face containing a point.
GetNodeByPoint (atopology, apoint, tol1)    Finds the node-id of a node at a point location.
GetTopologyID (toponame)    Retorna a id de uma topologia na table topology.topology dado o nome da topologia.
GetTopologySRID (toponame)    Retorna o SRID de uma topologia na table topology.topology dado o nome da topologia.
GetTopologyName (topology_id)    Retorna o nome de uma topologia (esquema) dada a id da topologia.
ST_GetFaceEdges  mm (atopology, aface)    Retorna um conjunto de limites ordenados que amarram aface.
ST_GetFaceGeometry  mm (atopology, aface)    Retorna o polígono na topologia dada com a id de face especificada.
GetRingEdges (atopology, aring, max_edges=null)    Retorna o conjunto ordenado de identificadores de limites assinados, conhecidos caminhando em um lado da beirada.
GetNodeEdges (atopology, anode)    Retorna um conjunto ordenado de limites incidentes no dado nó.

Processamento de Topologia
Polygonize (toponame)    Finds and registers all faces defined by topology edges.
AddNode (toponame, apoint, allowEdgeSplitting=false, computeContainingFace=false)    Adiciona um ponto nó na table nó no esquema topológico específico e retorna a nodeid do novo nó. Se o ponto já existe, a nodeid é retornada.
AddEdge (toponame, aline)    Adiciona uma linestring limite à edge table e os pontos de início e fim associados à table ponto nó do esquema de topologia especificado usando a linestring geometria específica e retorna a bordaid da nova borda (ou da borda já existente).
AddFace (toponame, apolygon, force_new=false)    Registra uma face primitiva a uma topologia e pega seu identificador.
ST_Simplify (tg, tolerance)    Retorna uma versão "simplificada" da geometria da dada TopoGeometria usando o algorítimo Douglas-Peucker.
RemoveUnusedPrimitives (topology_name, bbox)    Removes topology primitives which not needed to define existing TopoGeometry objects.

Construtores de TopoGeometria
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
  1. toponame, tg_type, layer_id, tg_objs
  2. toponame, tg_type, layer_id
toTopoGeom    Converts a simple Geometry into a topo geometry.
  1. geom, toponame, layer_id, tolerance
  2. geom, topogeom, tolerance
TopoElementArray_Agg (tefield)    Returns a topoelementarray for a set of element_id, type arrays (topoelements).
TopoElement (topo)    Converts a topogeometry to a topoelement.

Editores de TopoGeometria
clearTopoGeom (topogeom)    Clears the content of a topo geometry.
TopoGeom_addElement (tg, el)    Adds an element to the definition of a TopoGeometry.
TopoGeom_remElement (tg, el)    Removes an element from the definition of a TopoGeometry.
TopoGeom_addTopoGeom (tgt, src)    Adds element of a TopoGeometry to the definition of another TopoGeometry.
toTopoGeom    Adds a geometry shape to an existing topo geometry.

Assessores de TopoGeometria
GetTopoGeomElementArray    Returns a topoelementarray (an array of topoelements) containing the topological elements and type of the given TopoGeometry (primitive elements).
  1. toponame, layer_id, tg_id
  2. tg
GetTopoGeomElements    Returns a set of topoelement objects containing the topological element_id,element_type of the given TopoGeometry (primitive elements).
  1. toponame, layer_id, tg_id
  2. tg
ST_SRID  mm (tg)    Returns the spatial reference identifier for a topogeometry.

TopoGeometry Outputs
AsGML    Retorna a representação GML de uma topogeometria.
  1. tg
  2. tg, nsprefix_in
  3. tg, visitedTable
  4. tg, visitedTable, nsprefix
  5. tg, nsprefix_in, precision, options
  6. tg, nsprefix_in, precision, options, visitedTable
  7. tg, nsprefix_in, precision, options, visitedTable, idprefix
  8. tg, nsprefix_in, precision, options, visitedTable, idprefix, gmlversion
AsTopoJSON (tg, edgeMapTable)    Retorna a representação TopoJSON de uma topogeometria.

Relações de Topologia Espacial
Equals  3d (tg1, tg2)    Retorna verdade se duas topogeometrias forem compostas da mesma topologia primitiva
Intersects  3d (tg1, tg2)    Retorna verdade se algum par de primitivos das duas topologias se intersectar.

Importing and exporting Topologies