Adding a small feature to PostGIS topology
Scott Smith
smiths at latfor.state.ny.us
Sun Mar 15 12:10:13 PDT 2026
I'm familiar with next_left_edge/next_right_edge in edge_data and made use of it in edge_topo. I'll try to explain the difference between their usages.
Suppose topogeometry 1 in layer 1 is composed of faces 1, 2, 3, and 4. The next_xx_edge fields od edge_data would provide the next edge for each of faces 1 through 4, but would provide no information as to whether the opposite side of that edge is another face in topogeometry 1 or not.
The fields next_xx_edge in edge_topo share the following attribute with their equivalents in edge_data: next_left_edge shares the edn_node and next_right_edge shares the start_node. The difference is that whereas in edge_data next_xx_edge has the same face on one of its sides as the previous edge, in edge_topo next_xx_edge has the same topogeometry one one side and a different topogeometry on the other. Further edges that are not a boundary between two topogeometries for a given layer are not included for the layer in edge_topo. Thus an edge with left_face 1 and right_face 4 would not be in edge_topo with layer 1 since both it is an internal edge of topogeometry 1.
Now let's say that layer 2 has child_layer 1 and that topogeometry 1 in layer 2 consists of topogeometries 1, 10, and 15 from layer 1. It would use the edge_topo table to determine which edges are edges of 1, 10, or 15 in layer 1, and thus topogeometry 1 of layer 2, as well as whether the opposite side is one of the other components of layer 2 topogeometry 1, and thus and internal edge of that topogeometry, or not.
I've written a script that takes edge_id, left_face, and right_face from edge_data and fills edge_id, layer_id, left_topo, and right_topo. I wrote another script that fills in next_xx_edge for each edge_id/layer_id combination I described above. The first pass with that script found instances where more than one edge bordering the same topogeometry met the start_ or end_ node. As far as I could identify, those were all cases where an interior ring touched an exterior ring of the topogeometry. With that information, a single WITH RECURSIVE query can get all the edges of one ring on a y topogeometry from any member of the ring, in order.
Sent from my Verizon, Samsung Galaxy smartphone
Get Outlook for Android<https://aka.ms/AAb9ysg>
________________________________
From: Sandro Santilli <strk at kbt.io>
Sent: Sunday, March 15, 2026 7:41:48 AM
To: Scott Smith <smiths at latfor.state.ny.us>
Cc: postgis-devel at lists.osgeo.org <postgis-devel at lists.osgeo.org>
Subject: Re: Adding a small feature to PostGIS topology
On Sun, Mar 15, 2026 at 01:44:06AM +0000, Scott Smith wrote:
> The edge_topo table was populated using those indices. However, I am
> not aware of anything in the indices that identifies what edges follow
> each other.
Those are the the next_left_edge and next_right_edge fields.
Those tell you which edge follows while you walk on the specific
side of the edge (forward on the left, backward on the right).
Once you are on the next edge, if the other side face is still part of
the topogeometry you can continue looking for the next one and so on.
--strk;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-devel/attachments/20260315/176c3fbf/attachment.htm>
More information about the postgis-devel
mailing list