-
-
Notifications
You must be signed in to change notification settings - Fork 369
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[docqueries] changes because manual assignment of poi
- Loading branch information
Showing
3 changed files
with
141 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,107 +1,107 @@ | ||
BEGIN; | ||
BEGIN | ||
SET client_min_messages TO NOTICE; | ||
SET | ||
/* -- q1 */ | ||
DROP TABLE IF EXISTS tmp_edges_vertices_pgr; | ||
NOTICE: table "tmp_edges_vertices_pgr" does not exist, skipping | ||
DROP TABLE | ||
CREATE TEMP TABLE tmp_edges_vertices_pgr AS | ||
SELECT id, in_edges, out_edges | ||
FROM pgr_extractVertices('SELECT id, geom FROM edges'); | ||
SELECT 17 | ||
SELECT * FROM pgr_degree( | ||
$$SELECT id FROM edges$$, | ||
$$SELECT id, in_edges, out_edges | ||
FROM tmp_edges_vertices_pgr$$); | ||
node | degree | ||
------+-------- | ||
1 | 1 | ||
2 | 1 | ||
3 | 2 | ||
4 | 1 | ||
5 | 1 | ||
6 | 3 | ||
7 | 4 | ||
8 | 3 | ||
9 | 1 | ||
10 | 3 | ||
11 | 4 | ||
12 | 3 | ||
13 | 1 | ||
14 | 1 | ||
15 | 2 | ||
16 | 3 | ||
17 | 2 | ||
(17 rows) | ||
/* -- q2 */ | ||
SELECT * FROM pgr_degree( | ||
$$SELECT id FROM edges WHERE id < 17$$, | ||
$$SELECT id, in_edges, out_edges | ||
FROM pgr_extractVertices('SELECT id, geom FROM edges')$$); | ||
node | degree | ||
------+-------- | ||
1 | 1 | ||
2 | 0 | ||
3 | 2 | ||
4 | 0 | ||
5 | 1 | ||
6 | 3 | ||
7 | 4 | ||
8 | 3 | ||
9 | 1 | ||
10 | 3 | ||
11 | 4 | ||
12 | 3 | ||
13 | 0 | ||
14 | 0 | ||
15 | 2 | ||
16 | 3 | ||
17 | 2 | ||
(17 rows) | ||
/* -- q3 */ | ||
SELECT * FROM pgr_degree( | ||
$$SELECT id FROM edges WHERE id < 17$$, | ||
$$SELECT id, in_edges, out_edges | ||
FROM pgr_extractVertices('SELECT id, geom FROM edges')$$, | ||
dryrun => true); | ||
NOTICE: | ||
WITH | ||
-- a sub set of edges of the graph goes here | ||
g_edges AS ( | ||
SELECT id FROM edges WHERE id < 17 | ||
), | ||
-- sub set of vertices of the graph goes here | ||
all_vertices AS ( | ||
SELECT id, in_edges, out_edges | ||
FROM pgr_extractVertices('SELECT id, geom FROM edges') | ||
), | ||
g_vertices AS ( | ||
SELECT id, | ||
unnest( | ||
coalesce(in_edges::BIGINT[], '{}'::BIGINT[]) | ||
|| | ||
coalesce(out_edges::BIGINT[], '{}'::BIGINT[])) AS eid | ||
FROM all_vertices | ||
), | ||
totals AS ( | ||
SELECT v.id, count(*) | ||
FROM g_vertices AS v | ||
JOIN g_edges AS e ON (e.id = eid) GROUP BY v.id | ||
) | ||
SELECT id::BIGINT, coalesce(count, 0)::BIGINT FROM all_vertices LEFT JOIN totals USING (id) | ||
; | ||
node | degree | ||
------+-------- | ||
(0 rows) | ||
/* -- q4 */ | ||
ROLLBACK; | ||
ROLLBACK | ||
BEGIN; | ||
BEGIN | ||
SET client_min_messages TO NOTICE; | ||
SET | ||
/* -- q1 */ | ||
DROP TABLE IF EXISTS tmp_edges_vertices_pgr; | ||
NOTICE: table "tmp_edges_vertices_pgr" does not exist, skipping | ||
DROP TABLE | ||
CREATE TEMP TABLE tmp_edges_vertices_pgr AS | ||
SELECT id, in_edges, out_edges | ||
FROM pgr_extractVertices('SELECT id, geom FROM edges'); | ||
SELECT 17 | ||
SELECT * FROM pgr_degree( | ||
$$SELECT id FROM edges$$, | ||
$$SELECT id, in_edges, out_edges | ||
FROM tmp_edges_vertices_pgr$$); | ||
node | degree | ||
------+-------- | ||
1 | 1 | ||
2 | 1 | ||
3 | 2 | ||
4 | 1 | ||
5 | 1 | ||
6 | 3 | ||
7 | 4 | ||
8 | 3 | ||
9 | 1 | ||
10 | 3 | ||
11 | 4 | ||
12 | 3 | ||
13 | 1 | ||
14 | 1 | ||
15 | 2 | ||
16 | 3 | ||
17 | 2 | ||
(17 rows) | ||
|
||
/* -- q2 */ | ||
SELECT * FROM pgr_degree( | ||
$$SELECT id FROM edges WHERE id < 17$$, | ||
$$SELECT id, in_edges, out_edges | ||
FROM pgr_extractVertices('SELECT id, geom FROM edges')$$); | ||
node | degree | ||
------+-------- | ||
1 | 1 | ||
2 | 0 | ||
3 | 2 | ||
4 | 0 | ||
5 | 1 | ||
6 | 3 | ||
7 | 4 | ||
8 | 3 | ||
9 | 1 | ||
10 | 3 | ||
11 | 4 | ||
12 | 3 | ||
13 | 0 | ||
14 | 0 | ||
15 | 2 | ||
16 | 3 | ||
17 | 2 | ||
(17 rows) | ||
|
||
/* -- q3 */ | ||
SELECT * FROM pgr_degree( | ||
$$SELECT id FROM edges WHERE id < 17$$, | ||
$$SELECT id, in_edges, out_edges | ||
FROM pgr_extractVertices('SELECT id, geom FROM edges')$$, | ||
dryrun => true); | ||
NOTICE: | ||
WITH | ||
|
||
-- a sub set of edges of the graph goes here | ||
g_edges AS ( | ||
SELECT id FROM edges WHERE id < 17 | ||
), | ||
|
||
-- sub set of vertices of the graph goes here | ||
all_vertices AS ( | ||
SELECT id, in_edges, out_edges | ||
FROM pgr_extractVertices('SELECT id, geom FROM edges') | ||
), | ||
|
||
g_vertices AS ( | ||
SELECT id, | ||
unnest( | ||
coalesce(in_edges::BIGINT[], '{}'::BIGINT[]) | ||
|| | ||
coalesce(out_edges::BIGINT[], '{}'::BIGINT[])) AS eid | ||
FROM all_vertices | ||
), | ||
|
||
totals AS ( | ||
SELECT v.id, count(*) | ||
FROM g_vertices AS v | ||
JOIN g_edges AS e ON (e.id = eid) GROUP BY v.id | ||
) | ||
|
||
SELECT id::BIGINT, coalesce(count, 0)::BIGINT FROM all_vertices LEFT JOIN totals USING (id) | ||
; | ||
node | degree | ||
------+-------- | ||
(0 rows) | ||
|
||
/* -- q4 */ | ||
ROLLBACK; | ||
ROLLBACK |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters