Skip to content

Commit c6ac76a

Browse files
committed
(docqueries/separateCrossing) Order matters and making geom readable
1 parent 6763283 commit c6ac76a

2 files changed

Lines changed: 23 additions & 69 deletions

File tree

docqueries/utilities/separateCrossing.pg

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
-- pgr_nodeNetwork
44
--------------------------------------------------------------------------------
55
/* --q1 */
6-
SELECT *
6+
SELECT id, sub_id, ST_AsText(geom)
77
FROM pgr_separateCrossing('SELECT id, geom FROM edges');
8+
ORDER BY id, sub_id;
89
/* --q2 */
910
SELECT *
1011
FROM pgr_separateCrossing('SELECT id, geom FROM edges', dryrun => true);

docqueries/utilities/separateCrossing.result

Lines changed: 21 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -3,81 +3,43 @@ BEGIN
33
SET client_min_messages TO NOTICE;
44
SET
55
/* --q1 */
6-
SELECT *
6+
SELECT id, sub_id, ST_AsText(geom)
77
FROM pgr_separateCrossing('SELECT id, geom FROM edges');
8-
seq | id | sub_id | geom
9-
-----+----+--------+------------------------------------------------------------------------------------
10-
1 | 18 | 1 | 0102000000020000000000000000000C4066666666666602400000000000000C400000000000000840
11-
2 | 18 | 2 | 0102000000020000000000000000000C4000000000000008400000000000000C400000000000001040
12-
3 | 13 | 1 | 010200000002000000000000000000084000000000000008400000000000000C400000000000000840
13-
4 | 13 | 2 | 0102000000020000000000000000000C40000000000000084000000000000010400000000000000840
8+
id | sub_id | st_astext
9+
----+--------+---------------------------
10+
13 | 1 | LINESTRING(3 3,3.5 3)
11+
13 | 2 | LINESTRING(3.5 3,4 3)
12+
18 | 1 | LINESTRING(3.5 2.3,3.5 3)
13+
18 | 2 | LINESTRING(3.5 3,3.5 4)
1414
(4 rows)
1515

16+
ORDER BY id, sub_id;
17+
ERROR: syntax error at or near "ORDER"
18+
LINE 1: ORDER BY id, sub_id;
19+
^
1620
/* --q2 */
1721
SELECT *
1822
FROM pgr_separateCrossing('SELECT id, geom FROM edges', dryrun => true);
19-
NOTICE:
20-
WITH
21-
edges_table AS (
22-
SELECT id, geom FROM edges
23-
),
24-
25-
get_crossings AS (
26-
SELECT e1.id id1, e2.id id2, e1.geom AS g1, e2.geom AS g2, ST_Intersection(e1.geom, e2.geom) AS point
27-
FROM edges_table e1, edges_table e2
28-
WHERE e1.id < e2.id AND ST_Crosses(e1.geom, e2.geom)
29-
),
30-
31-
crossings AS (
32-
SELECT id1, g1, point FROM get_crossings
33-
UNION
34-
SELECT id2, g2, point FROM get_crossings
35-
),
36-
37-
blades AS (
38-
SELECT id1, g1, ST_Union(point) as blade
39-
FROM crossings
40-
GROUP BY id1, g1
41-
),
42-
43-
collection AS (
44-
SELECT id1, (st_dump(st_split(st_snap(g1, blade, 0.01), blade))).*
45-
FROM blades
46-
)
47-
48-
SELECT row_number() over()::INTEGER AS seq, id1::BIGINT, path[1], geom
49-
FROM collection;
50-
;
51-
seq | id | sub_id | geom
52-
-----+----+--------+------
53-
(0 rows)
54-
23+
ERROR: current transaction is aborted, commands ignored until end of transaction block
5524
/* --q3 */
5625
SELECT *
5726
FROM pgr_dijkstra('SELECT id, source, target, cost, reverse_cost FROM edges', 1, 18);
58-
seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost
59-
-----+----------+-----------+---------+------+------+------+----------
60-
(0 rows)
61-
27+
ERROR: current transaction is aborted, commands ignored until end of transaction block
6228
/* --q4 */
6329
SELECT
6430
e1.id id1, e2.id id2,
6531
ST_AsText(ST_Intersection(e1.geom, e2.geom)) AS point
6632
FROM edges e1, edges e2
6733
WHERE e1.id < e2.id AND ST_Crosses(e1.geom, e2.geom);
68-
id1 | id2 | point
69-
-----+-----+--------------
70-
13 | 18 | POINT(3.5 3)
71-
(1 row)
72-
34+
ERROR: current transaction is aborted, commands ignored until end of transaction block
7335
/* --q5 */
7436
ALTER TABLE edges ADD old_id BIGINT, ADD sub_id BIGINT;
75-
ALTER TABLE
37+
ERROR: current transaction is aborted, commands ignored until end of transaction block
7638
/* --q6 */
7739
INSERT INTO edges (old_id, sub_id, geom)
7840
SELECT id, sub_id, geom
7941
FROM pgr_separateCrossing('SELECT id, geom FROM edges');
80-
INSERT 0 4
42+
ERROR: current transaction is aborted, commands ignored until end of transaction block
8143
/* --q7 */
8244
WITH
8345
costs AS (
@@ -88,7 +50,7 @@ costs AS (
8850
UPDATE edges e
8951
SET (cost, reverse_cost) = (c.cost, c.reverse_cost)
9052
FROM costs AS c WHERE e.id = c.id;
91-
UPDATE 4
53+
ERROR: current transaction is aborted, commands ignored until end of transaction block
9254
/* --q8 */
9355
WITH
9456
new_vertex AS (
@@ -98,33 +60,24 @@ new_vertex AS (
9860
WHERE v IS NULL)
9961
INSERT INTO vertices (in_edges, out_edges,x,y,geom)
10062
SELECT in_edges, out_edges,x,y,geom FROM new_vertex;
101-
INSERT 0 1
63+
ERROR: current transaction is aborted, commands ignored until end of transaction block
10264
/* --q9 */
10365
/* -- set the source information */
10466
UPDATE edges AS e
10567
SET source = v.id, x1 = x, y1 = y
10668
FROM vertices AS v
10769
WHERE source IS NULL AND ST_StartPoint(e.geom) = v.geom;
108-
UPDATE 4
70+
ERROR: current transaction is aborted, commands ignored until end of transaction block
10971
/* -- set the target information */
11072
UPDATE edges AS e
11173
SET target = v.id, x2 = x, y2 = y
11274
FROM vertices AS v
11375
WHERE target IS NULL AND ST_EndPoint(e.geom) = v.geom;
114-
UPDATE 4
76+
ERROR: current transaction is aborted, commands ignored until end of transaction block
11577
/* --q10 */
11678
SELECT *
11779
FROM pgr_dijkstra('SELECT id, source, target, cost, reverse_cost FROM edges', 1, 18);
118-
seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost
119-
-----+----------+-----------+---------+------+------+------+----------
120-
1 | 1 | 1 | 18 | 1 | 6 | 1 | 0
121-
2 | 2 | 1 | 18 | 3 | 7 | 1 | 1
122-
3 | 3 | 1 | 18 | 7 | 10 | 1 | 2
123-
4 | 4 | 1 | 18 | 8 | 12 | 1 | 3
124-
5 | 5 | 1 | 18 | 12 | 21 | 0.5 | 4
125-
6 | 6 | 1 | 18 | 18 | -1 | 0 | 4.5
126-
(6 rows)
127-
80+
ERROR: current transaction is aborted, commands ignored until end of transaction block
12881
/* --q11 */
12982
/* --qend */
13083
ROLLBACK;

0 commit comments

Comments
 (0)