Skip to content

Commit 9e58b04

Browse files
committed
(basic/withPoints) script for the documentation
1 parent 30398c6 commit 9e58b04

File tree

4 files changed

+166
-203
lines changed

4 files changed

+166
-203
lines changed

docs/scripts/basic/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ SET(PGR_WORKSHOP_DIR
99
pedestrian
1010
vehicles
1111
sql_function
12-
plpgsql_function
12+
withPoints
1313
)
1414

1515
foreach (d ${PGR_WORKSHOP_DIR})
@@ -25,4 +25,4 @@ add_dependencies(basic_pedestrian_scripts basic_graphs_scripts)
2525
add_dependencies(basic_vehicles_scripts basic_graphs_scripts)
2626
add_dependencies(basic_sql_function_scripts basic_graphs_scripts)
2727
add_dependencies(basic_sql_function_scripts basic_vehicles_scripts)
28-
add_dependencies(basic_plpgsql_function_scripts basic_sql_function_scripts)
28+
add_dependencies(basic_withPoints_scripts basic_sql_function_scripts)
Lines changed: 22 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,29 @@
1-
add_custom_target(basic_plpgsql_function_scripts)
2-
31
#---------------------
42
# Files
53
#---------------------
6-
configure_file(plpgsql_function.sql plpgsql_function.sql)
7-
8-
#---------------------------------------------
9-
# Generating the results files
10-
#---------------------------------------------
4+
configure_file(withPoints.sql withPoints.sql)
5+
configure_file(images.sql images.sql)
6+
7+
set(GENERATED_FILES
8+
closestedges.txt
9+
route_withPoints.txt
10+
wrk_withPoints.txt
11+
use_fn_1.txt
12+
use_fn_2.txt
13+
use_fn_3.txt
14+
file_end.txt
15+
warnings.txt
16+
)
1117

1218
add_custom_command(
13-
TARGET basic_plpgsql_function_scripts
14-
PRE_BUILD
15-
BYPRODUCTS
16-
excercise-8_1_1.txt
17-
excercise-8_1_2.txt
18-
excercise-8_1_3.txt
19-
excercise-8_1_4.txt
20-
21-
excercise-8_2_1.txt
22-
excercise-8_2_2.txt
23-
excercise-8_2_3.txt
24-
25-
excercise-8_3_1.txt
26-
excercise-8_3_2.txt
27-
excercise-8_3_3.txt
28-
excercise-8_3_4.txt
19+
COMMAND psql -d city_routing -f withPoints.sql 2> warnings.txt
20+
COMMAND psql -d city_routing -f images.sql
21+
OUTPUT ${GENERATED_FILES}
2922

30-
excercise-8_4.txt
23+
DEPENDS withPoints.sql images.sql
24+
COMMENT "running chapter withPoints scripts"
25+
)
3126

32-
excercise-8_5_1.txt
33-
excercise-8_5_2.txt
34-
excercise-8_5_3.txt
35-
excercise-8_5_4.txt
36-
37-
excercise-8_6.txt
38-
39-
excercise-8_7_1.txt
40-
excercise-8_7_2.txt
41-
excercise-8_7_3.txt
42-
43-
warnings.txt
44-
COMMAND psql -d city_routing -f plpgsql_function.sql 2> warnings.txt
45-
COMMENT "running plpgsql_function scripts"
46-
)
27+
add_custom_target(basic_withPoints_scripts
28+
DEPENDS ${GENERATED_FILES}
29+
)
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
DROP TABLE IF EXISTS points_on_map;
2+
WITH the_points AS (
3+
SELECT 1 AS id, ST_SetSRID(ST_Point(@POINT1_LON@, @POINT1_LAT@), 4326)
4+
UNION
5+
SELECT 2 AS id, ST_SetSRID(ST_Point(@POINT2_LON@, @POINT2_LAT@), 4326)
6+
)
7+
SELECT * INTO points_on_map
8+
FROM the_points;
9+
10+
11+
DROP TABLE IF EXISTS closest_walk;
12+
WITH the_closest AS (
13+
SELECT 1 AS pid, * from pgr_findCloseEdges(
14+
'SELECT id, geom from walk_net',
15+
ST_SetSRID(ST_Point(@POINT1_LON@, @POINT1_LAT@), 4326) , 0.5)
16+
17+
UNION
18+
19+
SELECT 2 AS pid, * from pgr_findCloseEdges(
20+
'SELECT id, geom from walk_net',
21+
ST_SetSRID(ST_Point(@POINT2_LON@, @POINT2_LAT@), 4326) , 0.5)
22+
)
23+
SELECT * INTO closest_walk FROM the_closest;
24+
25+
CREATE OR REPLACE VIEW using_vehicle AS
26+
SELECT * FROM wrk_withPoints(
27+
'vehicle_net',
28+
@POINT1_LAT@, @POINT1_LON@,
29+
@POINT2_LAT@, @POINT2_LON@);
30+
31+
CREATE OR REPLACE VIEW using_taxi AS
32+
SELECT * FROM wrk_withPoints(
33+
'taxi_net',
34+
@POINT1_LAT@, @POINT1_LON@,
35+
@POINT2_LAT@, @POINT2_LON@);
36+
37+
CREATE OR REPLACE VIEW using_walk AS
38+
SELECT *
39+
FROM wrk_withPoints(
40+
'walk_net',
41+
@POINT1_LAT@, @POINT1_LON@,
42+
@POINT2_LAT@, @POINT2_LON@);

0 commit comments

Comments
 (0)