Skip to content

Commit 7aaaa2a

Browse files
committed
Using pgr_findCloseEdges to determine gaps
1 parent 4ed2a36 commit 7aaaa2a

File tree

4 files changed

+56
-11
lines changed

4 files changed

+56
-11
lines changed

doc/src/migration.rst

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,32 +68,41 @@ For example:
6868

6969
.. rubric:: Dead ends.
7070

71-
Instead of counting the dead ends, determine all the dead ends of the graph.
71+
Instead of counting the dead ends, determine all the dead ends of the graph
72+
using :doc:`pgr_degree`.
73+
74+
For example:
7275

7376
.. literalinclude:: migration.queries
7477
:start-after: --analysis2
7578
:end-before: --analysis3
7679

7780
.. rubric:: Potential gaps near dead ends.
7881

79-
Instead of counting potential gaps between geometries, determine geometric
80-
relationships between geometries.
82+
Instead of counting potential gaps between geometries, determine the geometric
83+
gaps in the graph using :doc:`pgr_findCloseEdges`.
8184

82-
Several PostGIS functions can be used, for example:
85+
For example:
8386

84-
* `ST_ClosestPoint <https://postgis.net/docs/ST_ClosestPoint.html>`__
85-
* `ST_Distance <https://postgis.net/docs/ST_Distance.html>`__
87+
.. literalinclude:: migration.queries
88+
:start-after: --analysis3
89+
:end-before: --analysis4
8690

8791
.. rubric:: Topological relationships.
8892

8993
Instead of counting intersections, determine topological relationships between
9094
geometries.
9195

92-
Several PostGIS functions can be used, for example:
96+
Several PostGIS functions can be used:
97+
`ST_Intersects <https://postgis.net/docs/ST_Intersects.html>`__,
98+
`ST_Crosses <https://postgis.net/docs/ST_Crosses.html>`__,
99+
`ST_Overlaps <https://postgis.net/docs/ST_Overlaps.html>`__, etc.
93100

94-
* `ST_Intersects <https://postgis.net/docs/ST_Intersects.html>`__
95-
* `ST_Crosses <https://postgis.net/docs/ST_Crosses.html>`__
96-
* `ST_Overlaps <https://postgis.net/docs/ST_Overlaps.html>`__
101+
For example:
102+
103+
.. literalinclude:: migration.queries
104+
:start-after: --analysis4
105+
:end-before: --analysis5
97106

98107
.. migrate_pgr_analyzeGraph_end
99108

doc/topology/pgr_analyzeGraph.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
|
1515
16-
``pgr_analyzeGraph``
16+
``pgr_analyzeGraph`` -- Deprecated since 3.8.0
1717
===============================================================================
1818

1919
``pgr_analyzeGraph`` — Analyzes the network topology.

docqueries/src/migration.pg

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,3 +388,16 @@ SELECT *
388388
FROM pgr_degree($$SELECT id, source, target FROM edges$$)
389389
WHERE degree = 1;
390390
/* --analysis3*/
391+
WITH
392+
deadends AS (
393+
SELECT id,geom, (in_edges || out_edges)[1] as inhere
394+
FROM vertices where array_length(in_edges || out_edges, 1) = 1),
395+
results AS (
396+
SELECT (pgr_findCloseEdges('SELECT id, geom FROM edges WHERE id != ' || inhere , geom, 0.001)).*
397+
FROM deadends)
398+
SELECT d.id, edge_id, distance, st_AsText(geom) AS point, st_asText(edge) edge
399+
FROM results JOIN deadends d USING (geom);
400+
/* --analysis4*/
401+
SELECT e1.id AS id1, e2.id AS id2
402+
FROM edges e1, edges e2 WHERE e1 < e2 AND st_crosses(e1.geom, e2.geom);
403+
/* --analysis5*/

docqueries/src/migration.result

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,5 +1283,28 @@ WHERE degree = 1;
12831283
(7 rows)
12841284

12851285
/* --analysis3*/
1286+
WITH
1287+
deadends AS (
1288+
SELECT id,geom, (in_edges || out_edges)[1] as inhere
1289+
FROM vertices where array_length(in_edges || out_edges, 1) = 1),
1290+
results AS (
1291+
SELECT (pgr_findCloseEdges('SELECT id, geom FROM edges WHERE id != ' || inhere , geom, 0.001)).*
1292+
FROM deadends)
1293+
SELECT d.id, edge_id, distance, st_AsText(geom) AS point, st_asText(edge) edge
1294+
FROM results JOIN deadends d USING (geom);
1295+
id | edge_id | distance | point | edge
1296+
----+---------+-------------------+---------------------------+--------------------------------------
1297+
4 | 14 | 1.00008890058e-12 | POINT(1.999999999999 3.5) | LINESTRING(1.999999999999 3.5,2 3.5)
1298+
(1 row)
1299+
1300+
/* --analysis4*/
1301+
SELECT e1.id AS id1, e2.id AS id2
1302+
FROM edges e1, edges e2 WHERE e1 < e2 AND st_crosses(e1.geom, e2.geom);
1303+
id1 | id2
1304+
-----+-----
1305+
13 | 18
1306+
(1 row)
1307+
1308+
/* --analysis5*/
12861309
ROLLBACK;
12871310
ROLLBACK

0 commit comments

Comments
 (0)