Skip to content

Deprecate pgr create topology #2830

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 3 commits into from
Apr 8, 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
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ milestone for 3.8.0
pgr_analyzeOneWay
* [#2753](https://github.com/pgRouting/pgrouting/issues/2753):
pgr_analyzeGraph
* [#2750](https://github.com/pgRouting/pgrouting/issues/2750):
pgr_createTopology
* [#2826](https://github.com/pgRouting/pgrouting/issues/2826):
pgr_createVerticesTable

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 @@ -220,7 +220,7 @@ var filesArr = [
]),
new createInfo('pgr_createTopology', '2.0', [
{ v: '2.1', n: 'src/common/doc/functions/create_topology'},
{ v: '2.3', n: 'src/topology/doc/pgr_createTopology'},
{ v: '2.3', n: 'src/topology/doc/pgr_createTopology'}, 3.8
]),
new createInfo('pgr_analyzeOneWay', '2.0', [
{ v: '2.1', n: 'src/common/doc/functions/analyze_oneway'},
Expand Down
2 changes: 1 addition & 1 deletion doc/contraction/pgr_contractionDeadEnd.rst
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ Contraction optional parameters
- Type
- Default
- Description
* - ``forbidden_vertices``
* - ``forbidden``
- ``ARRAY[`` |ANY-INTEGER| ``]``
- **Empty**
- Identifiers of vertices forbidden for contraction.
Expand Down
2 changes: 1 addition & 1 deletion doc/max_flow/pgr_maxFlow.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Description
- Calculates the maximum flow from the sources to the targets.

- When the maximum flow is **0** then there is no flow and **0** is returned.
- There is no flow when source has the same vaule as target.
- There is no flow when source has the same value as target.

- Any duplicated values in source or target are ignored.
- Uses the :doc:`pgr_pushRelabel <pgr_pushRelabel>` algorithm.
Expand Down
2 changes: 1 addition & 1 deletion doc/max_flow/pgr_maxFlowMinCost_Cost.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Description
- **The cost value of all input edges must be nonnegative.**
- When the maximum flow is 0 then there is no flow and **0** is returned.

- There is no flow when source has the same vaule as target.
- There is no flow when source has the same value as target.

- Any duplicated values in source or target are ignored.
- Uses :doc:`pgr_maxFlowMinCost`.
Expand Down
19 changes: 19 additions & 0 deletions doc/src/migration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,25 @@ Results can be different because of the changes.
.. contents:: Contents
:depth: 2

.. migrate_pgr_createTopology_start

Migration of ``pgr_createTopology``
-------------------------------------------------------------------------------

Starting from `v3.8.0 <https://docs.pgrouting.org/3.8/en/migration.html>`__

**Before Deprecation:** The following was calculated:

* A table with `<edges>_vertices_pgr` was created.

**After Deprecation:** The user is responsible to create the complete topology.

.. include:: pgRouting-concepts.rst
:start-after: createTopology_start
:end-before: createTopology_end

.. migrate_pgr_createTopology_end

.. migrate_pgr_createVerticesTable_start

Migration of ``pgr_createVerticesTable``
Expand Down
11 changes: 10 additions & 1 deletion doc/src/pgRouting-concepts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@ The use of indexes on the database design in general:
Please consult the `PostgreSQL <https://www.postgresql.org/docs/>`__
documentation and the `PostGIS <https://postgis.net/>`__ documentation.

.. createTopology_start

Build a routing topology
...............................................................................
Expand Down Expand Up @@ -516,10 +517,18 @@ If the columns do not exist they need to be added to the table in question. (see
The function :doc:`pgr_extractVertices` is used to create a vertices table
based on the edge identifier and the geometry of the edge of the graph.

.. literalinclude:: concepts.queries
:start-after: -- createTopology1
:end-before: -- createTopology2

Finally using the data stored on the vertices tables the ``source`` and
``target`` are filled up.

See :doc:`sampledata` for an example for building a topology.
.. literalinclude:: concepts.queries
:start-after: -- createTopology2
:end-before: -- createTopology3

.. createTopology_end

Data coming from OSM and using `osm2pgrouting
<https://github.com/pgRouting/osm2pgrouting>`__ as an import tool, comes with
Expand Down
2 changes: 2 additions & 0 deletions doc/src/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ milestone for 3.8.0
pgr_analyzeOneWay
* `#2753 <https://github.com/pgRouting/pgrouting/issues/2753>`__:
pgr_analyzeGraph
* `#2750 <https://github.com/pgRouting/pgrouting/issues/2750>`__:
pgr_createTopology
* `#2826 <https://github.com/pgRouting/pgrouting/issues/2826>`__:
pgr_createVerticesTable

Expand Down
5 changes: 0 additions & 5 deletions doc/topology/pgr_analyzeGraph.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ The edge table to be analyzed must contain a source column and a target column
filled with id's of the vertices of the segments and the corresponding vertices
table <edge_table>_vertices_pgr that stores the vertices information.

- Use :doc:`pgr_createTopology` to create the topology and the vertices table.

Parameters
-------------------------------------------------------------------------------

Expand Down Expand Up @@ -95,9 +93,6 @@ The function returns:

.. rubric:: The Vertices Table

The vertices table can be created with
:doc:`pgr_createTopology <pgr_createTopology>`

The structure of the vertices table is:

:id: ``bigint`` Identifier of the vertex.
Expand Down
9 changes: 0 additions & 9 deletions doc/topology/pgr_analyzeOneWay.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ The edge table to be analyzed must contain a source column and a target column
filled with id's of the vertices of the segments and the corresponding vertices
table <edge_table>_vertices_pgr that stores the vertices information.

- Use :doc:`pgr_createTopology` to create the topology and the vertices table.

|Boost| Boost Graph Inside

Signatures
Expand Down Expand Up @@ -96,10 +94,6 @@ Parameters
:two_way_if_null: ``boolean`` flag to treat oneway NULL values as
bi-directional. Default value is ``true``.

.. note::
It is strongly recommended to use the named notation. See
:doc:`pgr_createTopology` for examples.

The function returns:

- ``OK`` after the analysis has finished.
Expand All @@ -120,9 +114,6 @@ condition.

.. rubric:: The Vertices Table

The vertices table can be created with
:doc:`pgr_createTopology`

The structure of the vertices table is:

:id: ``bigint`` Identifier of the vertex.
Expand Down
14 changes: 11 additions & 3 deletions doc/topology/pgr_createTopology.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,32 @@
****************************************************************************

.. index::
single: Topology Family ; pgr_createTopology
single: createTopology
single: Topology Family ; pgr_createTopology - Deprecated since v3.8.0
single: createTopology - Deprecated since v3.8.0

|

``pgr_createTopology``
``pgr_createTopology`` - Deprecated since v3.8.0
===============================================================================

``pgr_createTopology`` — Builds a network topology based on the geometry
information.

.. rubric:: Availability

* Version 3.8.0

* Deprecated function.

* Version 2.0.0

* Official function.
* Renamed from version 1.x

.. include:: migration.rst
:start-after: migrate_pgr_createTopology_start
:end-before: migrate_pgr_createTopology_end

Description
-------------------------------------------------------------------------------

Expand Down
2 changes: 0 additions & 2 deletions doc/topology/pgr_createVerticesTable.rst
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,6 @@ See Also
* :doc:`sampledata`
* :doc:`topology-functions` for an overview of a topology for routing
algorithms.
* :doc:`pgr_createTopology` <pgr_create_topology>` to create a topology based on
the geometry.

.. rubric:: Indices and tables

Expand Down
7 changes: 2 additions & 5 deletions doc/topology/pgr_nodeNetwork.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,8 @@ The output table will have for ``edge_table_noded``
:id: ``bigint`` Unique identifier for the table
:old_id: ``bigint`` Identifier of the edge in original table
:sub_id: ``integer`` Segment number of the original edge
:source: ``integer`` Empty source column to be used with
:doc:`pgr_createTopology` function
:target: ``integer`` Empty target column to be used with
:doc:`pgr_createTopology` function
:source: ``integer`` Empty source column
:target: ``integer`` Empty target column
:the geom: ``geometry`` Geometry column of the noded network

Examples
Expand Down Expand Up @@ -234,7 +232,6 @@ See Also
-------------------------------------------------------------------------------

:doc:`topology-functions` for an overview of a topology for routing algorithms.
:doc:`pgr_createTopology` to create a topology based on the geometry.

.. rubric:: Indices and tables

Expand Down
21 changes: 11 additions & 10 deletions docqueries/lineGraph/proofOfConcept1.pg
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
-- Creative Commons Attribution-Share Alike 3.0 License : https://creativecommons.org/licenses/by-sa/3.0/
-- TODO move to pgtap

-- getting same results using pgr_createTopology
DROP TABLE IF EXISTS edges1;
SELECT id, NULL::BIGINT as source, NULL::BIGINT as target, cost, reverse_cost, x1, x2, y1, y2, geom AS the_geom
SELECT id, source, target, cost, reverse_cost, x1, x2, y1, y2, geom
INTO edges1
FROM edges ORDER BY id;
UPDATE edges1 SET the_geom = st_makeline(st_point(x1,y1),st_point(x2,y2));
SELECT pgr_createTopology('edges1',0.001);

DROP TABLE IF EXISTS edges1_vertices_pgr;
SELECT *
INTO edges1_vertices_pgr
FROM vertices ORDER BY id;

-- this is a hand made test
UPDATE edges1 SET id = id * 100, source = 1000 * source, target = 1000 * target;
Expand Down Expand Up @@ -100,20 +101,20 @@ WHERE
DROP TABLE IF EXISTS q_result_1;
SELECT * INTO q_result_1
FROM pgr_dijkstra($$SELECT seq AS id, * FROM result2$$,
(SELECT array_agg(id) FROM result2_vertices_pgr where original_id = 2000),
(SELECT array_agg(id) FROM result2_vertices_pgr where original_id = 3000)
(SELECT array_agg(id) FROM result2_vertices_pgr where original_id = 6000),
(SELECT array_agg(id) FROM result2_vertices_pgr where original_id = 10000)
);
SELECT * FROM q_result_1;
-- choosing the best many to many
SELECT min(agg_cost) FROM q_result_1 WHERE edge = -1;
SELECT path_seq, start_vid, end_vid FROM q_result_1 WHERE edge = -1 and agg_cost = 5;
SELECT * FROM q_result_1 WHERE start_vid = -3 AND end_vid = 3000;
SELECT * FROM q_result_1 WHERE start_vid = -3 AND end_vid = 10000;
-- not showing the 0 cost edges
SELECT * FROM q_result_1 WHERE start_vid = -3 AND end_vid = 3000 AND (cost != 0 OR edge = -1);
SELECT * FROM q_result_1 WHERE start_vid = -3 AND end_vid = 10000 AND (cost != 0 OR edge = -1);
-- not showing the 0 cost edges and showing the original edges
WITH a AS (
SELECT * FROM q_result_1
WHERE start_vid = -3 AND end_vid = 3000 AND (cost != 0 OR edge = -1))
WHERE start_vid = -3 AND end_vid = 10000 AND (cost != 0 OR edge = -1))
SELECT
a.seq, a.path_seq,
(SELECT original_id FROM result2_vertices_pgr AS b WHERE a.start_vid = b.id) AS start_vid,
Expand All @@ -124,4 +125,4 @@ FROM a;

-- A Dijkstra
SELECT * from pgr_dijkstra($$SELECT id, * FROM edges1$$,
ARRAY[2000], ARRAY[3000]);
ARRAY[6000], ARRAY[10000]);
Loading