I am trying to understand this code in pgRouting for creating topology:
CREATE OR REPLACE VIEW road_ext AS
SELECT *, startpoint(the_geom), endpoint(the_geom)
CREATE TABLE node AS
SELECT row_number() OVER (ORDER BY foo.p)::integer AS id,
foo.p AS the_geom
SELECT DISTINCT road_ext.startpoint AS p FROM road_ext
SELECT DISTINCT road_ext.endpoint AS p FROM road_ext
GROUP BY foo.p;
CREATE TABLE network AS
SELECT a.*, b.id as start_id, c.id as end_id
FROM road_ext AS a
JOIN node AS b ON a.startpoint = b.the_geom
JOIN node AS c ON a.endpoint = c.the_geom;
From this code, can anyone explain this code a bit please. I am confused and want to know if it generates entries of individual road segments in separate rows even if I digitize some road segments into a single road.
Clearly, I want to know what way we need to digitise roads for creating a road network? Shall we need to split a long road into new segments at every connection to a small road or do the below code generates it automatically? Please help!!
As the code only says startpoint and endpoint, I dont get how it can identify the intermediate nodes where there are connecting roads.
For Example, in the below image I digitised the long road in a single entry. Now if I run the above code, will it generates the individual line segments?