Skip to content
Open
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
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ To see all issues & pull requests closed by this release see the

* [#2966](https://github.com/pgRouting/pgrouting/issues/2966): pgr_withPoints does not pick optimal route when fraction = 1
* [#3034](https://github.com/pgRouting/pgrouting/issues/3034): metrics driver should not be using new
* [#3010](https://github.com/pgRouting/pgrouting/issues/3010): Performance issue with pgr_separateTouching()

**Code enhancements**

Expand Down
1 change: 1 addition & 0 deletions doc/src/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ To see all issues & pull requests closed by this release see the

* :issue:`2966`: pgr_withPoints does not pick optimal route when fraction = 1
* :issue:`3034`: metrics driver should not be using new
* :issue:`3010`: Performance issue with pgr_separateTouching()

.. rubric:: Code enhancements

Expand Down
16 changes: 10 additions & 6 deletions docqueries/utilities/separateTouching.result
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,28 @@ FROM pgr_separateTouching('SELECT id, geom FROM edges', dryrun => true);
NOTICE:
WITH
edges_table AS (
SELECT id, geom FROM edges
SELECT id, geom,
ST_StartPoint(geom) AS startpoint,
ST_EndPoint(geom) AS endpoint
FROM (SELECT id, geom FROM edges) _edges
),

get_touching AS (
SELECT e1.id id1, e2.id id2, ST_Snap(e1.geom, e2.geom, 0.01) AS geom, e1.geom AS g1, e2.geom AS g2
SELECT e1.id id1, e2.id id2, ST_Snap(e1.geom, e2.geom, 0.01) AS geom, e1.geom AS g1, e2.geom AS g2,
e1.startpoint AS sp1, e1.endpoint AS ep1
FROM edges_table e1, edges_table e2
WHERE e1.id != e2.id AND ST_DWithin(e1.geom, e2.geom, 0.01) AND NOT(
ST_StartPoint(e1.geom) = ST_StartPoint(e2.geom) OR ST_StartPoint(e1.geom) = ST_EndPoint(e2.geom)
OR ST_EndPoint(e1.geom) = ST_StartPoint(e2.geom) OR ST_EndPoint(e1.geom) = ST_EndPoint(e2.geom))
e1.startpoint = e2.startpoint OR e1.startpoint = e2.endpoint
OR e1.endpoint = e2.startpoint OR e1.endpoint = e2.endpoint)
),

touchings AS (
SELECT id1, g1, g2, st_intersection(geom, g2) AS point
FROM get_touching
WHERE NOT (geom = g1) OR
(ST_touches(g1, g2) AND NOT
(ST_Intersection(geom, g2) = ST_StartPoint(g1)
OR ST_Intersection(geom, g2) = ST_EndPoint(g1)))
(ST_Intersection(geom, g2) = sp1
OR ST_Intersection(geom, g2) = ep1))
),

blades AS (
Expand Down
5 changes: 5 additions & 0 deletions locale/en/LC_MESSAGES/pgrouting_doc_strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -15064,6 +15064,11 @@ msgid ""
"driver should not be using new"
msgstr ""

msgid ""
"`#3010 <https://github.com/pgRouting/pgrouting/issues/3010>`__: Performance "
"issue with pgr_separateTouching()"
msgstr ""

msgid ""
"`#3044 <https://github.com/pgRouting/pgrouting/issues/3044>`__: Check and "
"fix assert.hpp for cppcoreguidelines-explicit-virtual-functions"
Expand Down
3 changes: 3 additions & 0 deletions locale/pot/pgrouting_doc_strings.pot
Original file line number Diff line number Diff line change
Expand Up @@ -12718,6 +12718,9 @@ msgstr ""
msgid "`#3034 <https://github.com/pgRouting/pgrouting/issues/3034>`__: metrics driver should not be using new"
msgstr ""

msgid "`#3010 <https://github.com/pgRouting/pgrouting/issues/3010>`__: Performance issue with pgr_separateTouching()"
msgstr ""

msgid "`#3044 <https://github.com/pgRouting/pgrouting/issues/3044>`__: Check and fix assert.hpp for cppcoreguidelines-explicit-virtual-functions"
msgstr ""

Expand Down
16 changes: 10 additions & 6 deletions sql/utilities/separateTouching.sql
Original file line number Diff line number Diff line change
Expand Up @@ -59,24 +59,28 @@ BEGIN
the_query := format($$
WITH
edges_table AS (
%s
SELECT id, geom,
ST_StartPoint(geom) AS startpoint,
ST_EndPoint(geom) AS endpoint
FROM (%s) _edges
),

get_touching AS (
SELECT e1.id id1, e2.id id2, ST_Snap(e1.geom, e2.geom, %2$s) AS geom, e1.geom AS g1, e2.geom AS g2
SELECT e1.id id1, e2.id id2, ST_Snap(e1.geom, e2.geom, %2$s) AS geom, e1.geom AS g1, e2.geom AS g2,
e1.startpoint AS sp1, e1.endpoint AS ep1
FROM edges_table e1, edges_table e2
WHERE e1.id != e2.id AND ST_DWithin(e1.geom, e2.geom, %2$s) AND NOT(
ST_StartPoint(e1.geom) = ST_StartPoint(e2.geom) OR ST_StartPoint(e1.geom) = ST_EndPoint(e2.geom)
OR ST_EndPoint(e1.geom) = ST_StartPoint(e2.geom) OR ST_EndPoint(e1.geom) = ST_EndPoint(e2.geom))
e1.startpoint = e2.startpoint OR e1.startpoint = e2.endpoint
OR e1.endpoint = e2.startpoint OR e1.endpoint = e2.endpoint)
),

touchings AS (
SELECT id1, g1, g2, st_intersection(geom, g2) AS point
FROM get_touching
WHERE NOT (geom = g1) OR
(ST_touches(g1, g2) AND NOT
(ST_Intersection(geom, g2) = ST_StartPoint(g1)
OR ST_Intersection(geom, g2) = ST_EndPoint(g1)))
(ST_Intersection(geom, g2) = sp1
OR ST_Intersection(geom, g2) = ep1))
),

blades AS (
Expand Down