Skip to content

new function pgr_separateCrossing 3.8 #2851

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Apr 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ milestone for 3.8.0
* [#2790](https://github.com/pgRouting/pgrouting/issues/2790): pgr_contractionDeadEnd
* [#2791](https://github.com/pgRouting/pgrouting/issues/2791): pgr_contractionLinear

* Utilities

* [#2848](https://github.com/pgRouting/pgrouting/issues/2848):
pgr_separateCrossing

## pgRouting 3.7

### pgRouting 3.7.3 Release Notes
Expand Down
2 changes: 1 addition & 1 deletion doc/_static/page_history.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var titles = [


var newpages = [
{v: '3.8', pages: ['pgr_contractionDeadEnd', 'pgr_contractionLinear']},
{v: '3.8', pages: ['pgr_contractionDeadEnd', 'pgr_contractionLinear', 'pgr_separateCrossing']},

{v: '3.7', pages: ['metrics-family', 'pgr_betweennessCentrality']},

Expand Down
1 change: 1 addition & 0 deletions doc/conf.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ rst_epilog="""
.. |result-edge-color| replace:: ``(edge_id, color_id)``
.. |result-node| replace:: ``(node)``
.. |result-edge| replace:: ``(edge)``
.. |result-separate| replace:: ``(seq,id,sub_id,geom)``
.. |result-node-order| replace:: ``(seq, node)``
.. |result-degree| replace:: ``(node, degree)``
.. |result-extract| replace:: ``(id, in_edges, out_edges, x, y, geom)``
Expand Down
78 changes: 3 additions & 75 deletions doc/src/pgRouting-concepts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -624,8 +624,6 @@ There are lots of possible problems in a graph.
Crossing edges
...............................................................................

.. cross_edges_start

To get the crossing edges:

.. literalinclude:: concepts.queries
Expand Down Expand Up @@ -663,83 +661,13 @@ When it is incorrect, it needs fixing:
Once analyzed one by one the crossings, for the ones that need a local fix,
the edges need to be `split <https://postgis.net/docs/ST_Split.html>`__.

.. literalinclude:: concepts.queries
:start-after: -- cross2
:end-before: -- cross3

The new edges need to be added to the edges table, the rest of the attributes
need to be updated in the new edges, the old edges need to be
removed and the routing topology needs to be updated.

Adding split edges
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

For each pair of crossing edges a process similar to this one must be performed.

The columns inserted and the way are calculated are based on the application.
For example, if the edges have a trait **name**, then that column is to be
copied.

For pgRouting calculations

* **factor** based on the position of the intersection of the edges can be used
to adjust the ``cost`` and ``reverse_cost`` columns.
* Capacity information, used in the :doc:`flow-family` functions does not need
to change when splitting edges.

.. literalinclude:: concepts.queries
:start-after: -- cross3
:end-before: -- cross4

Adding new vertices
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

After adding all the split edges required by the application, the newly created
vertices need to be added to the vertices table.

.. literalinclude:: concepts.queries
:start-after: -- cross4
:end-before: -- cross5

Updating edges topology
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

.. literalinclude:: concepts.queries
:start-after: -- cross5
:end-before: -- cross6

Removing the surplus edges
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Once all significant information needed by the application has been transported
to the new edges, then the crossing edges can be deleted.

.. literalinclude:: concepts.queries
:start-after: -- cross6
:end-before: -- cross7

There are other options to do this task, like creating a view, or a materialized
view.

Updating vertices topology
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

To keep the graph consistent, the vertices topology needs to be updated

.. literalinclude:: concepts.queries
:start-after: -- cross7
:end-before: -- cross8

Checking for crossing edges
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

There are no crossing edges on the graph.

.. literalinclude:: concepts.queries
:start-after: -- cross8
:end-before: -- cross9

.. cross_edges_end
.. include:: pgr_separateCrossing.rst
:start-after: fix_intersection_start
:end-before: fix_intersection_end

Disconnected graphs
...............................................................................
Expand Down
6 changes: 6 additions & 0 deletions doc/src/proposed.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ Proposed Functions
:start-after: official-start
:end-before: official-end

.. rubric:: Utilities

.. include:: topology-functions.rst
:start-after: utility_proposed-start
:end-before: utility_proposed-end

.. toctree::
:hidden:

Expand Down
5 changes: 5 additions & 0 deletions doc/src/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ milestone for 3.8.0
* `#2790 <https://github.com/pgRouting/pgrouting/issues/2790>`__: pgr_contractionDeadEnd
* `#2791 <https://github.com/pgRouting/pgrouting/issues/2791>`__: pgr_contractionLinear

* Utilities

* `#2848 <https://github.com/pgRouting/pgrouting/issues/2848>`__:
pgr_separateCrossing

pgRouting 3.7
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Expand Down
7 changes: 4 additions & 3 deletions doc/src/routingFunctions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,11 @@ Function Families

:doc:`pgr_trsp` - Turn Restriction Shortest Path (TRSP)

.. rubric:: Utilities family
.. rubric:: Utilities

:doc:`pgr_findCloseEdges`
.. include:: topology-functions.rst
:start-after: utility_official-start
:end-before: utility_official-end

Functions by categories
===============================================================================
Expand Down Expand Up @@ -172,7 +174,6 @@ Functions by categories
reference
topology-functions
TSP-family
pgr_findCloseEdges

.. toctree::
:hidden:
Expand Down
21 changes: 2 additions & 19 deletions doc/topology/pgr_extractVertices.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
****************************************************************************

.. index::
single: Topology Family ; pgr_extractVertices
single: Utilities ; pgr_extractVertices
single: extractVertices

|
Expand Down Expand Up @@ -49,15 +49,13 @@ of edges of a graph.
Signatures
-------------------------------------------------------------------------------

.. rubric:: Summary

.. admonition:: \ \
:class: signatures

| pgr_extractVertices(`Edges SQL`_, [``dryrun``])

| RETURNS SETOF |result-extract|
| OR EMTPY SET
| OR EMPTY SET

:Example: Extracting the vertex information

Expand Down Expand Up @@ -283,21 +281,6 @@ Inspect the routing topology

.. create_routing_topology_end


Crossing edges
...............................................................................

.. include:: pgRouting-concepts.rst
:start-after: cross_edges_start
:end-before: cross_edges_end

Graphs without geometries
...............................................................................

.. include:: pgRouting-concepts.rst
:start-after: no_geometry_start
:end-before: no_geometry_end

See Also
-------------------------------------------------------------------------------

Expand Down
30 changes: 21 additions & 9 deletions doc/topology/topology-functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,33 @@ have special permissions given by the administrators to use them.
table.
- :doc:`pgr_analyzeOneWay` - to analyze directionality of the edges.
- :doc:`pgr_nodeNetwork` - to create nodes to a not noded edge table.
- :doc:`pgr_extractVertices` - Extracts vertex information based on the edge
table information.

.. official-end

pgRouting supplies some functions to create a routing topology and to analyze the
topology.
.. index:: Utilities

|

Utility functions
===============================================================================

.. utility_official-start

- :doc:`pgr_extractVertices` - Extracts vertex information based on the edge
table information.
- :doc:`pgr_findCloseEdges` - Finds close edges of points on the fly

Additional functions to create a graph:
.. utility_official-end

* :doc:`contraction-family`
.. include:: proposed.rst
:start-after: warning-begin
:end-before: end-warning

Additional functions to analyze a graph:
.. utility_proposed-start

* :doc:`components-family`
- :doc:`pgr_separateCrossing` - Breaks geometries that cross each other.

.. proposed-end
.. utility_proposed-end

.. toctree::
:hidden:
Expand All @@ -61,6 +71,8 @@ Additional functions to analyze a graph:
pgr_analyzeOneWay
pgr_nodeNetwork
pgr_extractVertices
pgr_findCloseEdges
pgr_separateCrossing

See Also
-------------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions doc/utilities/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
SET(LOCAL_FILES
pgr_findCloseEdges.rst
pgr_separateCrossing.rst
)

foreach (f ${LOCAL_FILES})
Expand Down
Loading