|
4 | 4 |
|
5 | 5 | ## Pre-process the OpenStreetMap Roads |
6 | 6 |
|
7 | | - |
8 | | -## Clean the data |
9 | | - |
10 | | -The following query converts multi-linestring data to multiple rows of |
11 | | -`LINESTRING` records required by `pgRouting`. |
12 | | - |
| 7 | +The following query converts `ST_MultiLineString` data to individual rows of |
| 8 | +`LINESTRING` records. |
13 | 9 |
|
14 | 10 | ```sql |
15 | 11 | CREATE TABLE routing.osm_road_intermediate AS |
@@ -68,18 +64,17 @@ CREATE INDEX ix_routing_road_line_osm_id |
68 | 64 | ``` |
69 | 65 |
|
70 | 66 |
|
71 | | - |
72 | 67 | ## Split Long Segments |
73 | 68 |
|
74 | 69 | Use the `pgr_separateTouching()` function to split line segments into smaller |
75 | 70 | segments and persist into a table. |
76 | 71 | This is necessary because pgRouting can only route through the ends |
77 | 72 | of line segments. It cannot switch from Line A to Line B from a point in the middle. |
78 | 73 |
|
79 | | -> FIXME: Make this a temp table instead?? It is not needed post-processing. |
80 | 74 |
|
81 | 75 | > Warning: This is an expensive query that does not parallelize in Postgres. The |
82 | | -> Washington D.C. example (34k rows) takes roughly an hour (55 minutes) to run. |
| 76 | +> Washington D.C. example (34k rows) takes roughly an hour (55 minutes) to run |
| 77 | +> in Docker on my laptop. |
83 | 78 |
|
84 | 79 | ```sql |
85 | 80 | DROP TABLE IF EXISTS routing.road_separate_touching; |
@@ -242,6 +237,9 @@ Use the `start_id` and `end_id` values from this query |
242 | 237 | in subsequent queries through the `:start_id` and `:end_id` variables |
243 | 238 | via DBeaver. |
244 | 239 |
|
| 240 | +> This query simulates a GUI allowing user to click on start/end points on a map, |
| 241 | +> resulting in longitude and latitude values. |
| 242 | +
|
245 | 243 |
|
246 | 244 | ```sql |
247 | 245 | WITH s_point AS ( |
@@ -466,3 +464,14 @@ SELECT d.*, n.geom AS node_geom, e.geom AS edge_geom |
466 | 464 |  |
467 | 465 |
|
468 | 466 |
|
| 467 | + |
| 468 | +## Cleanup Intermediary tables |
| 469 | + |
| 470 | +There are 2 tables used to build the routing network that are not needed |
| 471 | +after the `routing.osm_road_edge` and `routing.osm_road_vertex` tables are |
| 472 | +populated. |
| 473 | + |
| 474 | +```sql |
| 475 | +DROP TABLE IF EXISTS routing.osm_road_intermediate; |
| 476 | +DROP TABLE IF EXISTS routing.road_separate_touching; |
| 477 | +``` |
0 commit comments