-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#884 add functions and view for routing centreline
- Loading branch information
Showing
2 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
gis/centreline/sql/create_function_get_centreline_btwn_intersections.sql
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
CREATE OR REPLACE FUNCTION gis_core.get_centreline_btwn_intersections( | ||
_node_start integer, | ||
_node_end integer, | ||
OUT _node_start_out integer, | ||
OUT _node_end integer, | ||
OUT links text[], | ||
OUT geom geometry) | ||
RETURNS record | ||
LANGUAGE 'sql' | ||
COST 100 | ||
STABLE STRICT PARALLEL UNSAFE | ||
AS $BODY$ | ||
WITH results as ( | ||
SELECT * | ||
FROM pgr_dijkstra('SELECT id, source::int, target::int, cost::int | ||
as cost from gis_core.routing_centreline_directional', _node_start, _node_end) | ||
) | ||
|
||
SELECT _node_start, _node_end, array_agg(centreline_id), ST_union(ST_linemerge(geom)) as geom | ||
from results | ||
inner join gis_core.routing_centreline_directional on edge=id | ||
|
||
$BODY$; | ||
|
||
ALTER FUNCTION gis_core.get_centreline_btwn_intersections(integer, integer) | ||
OWNER TO gis_admins; | ||
|
||
COMMENT ON FUNCTION gis_core.get_centreline_btwn_intersections(integer, integer) | ||
IS 'Routing function for centreline, takes in start intersection_id and end intersection_id and returns an array of centreline_id, as well as one line geometry between two intersections.'; | ||
|
||
GRANT EXECUTE ON FUNCTION gis_core.get_centreline_btwn_intersections(integer, integer) TO bdit_humans; | ||
|
||
GRANT EXECUTE ON FUNCTION gis_core.get_centreline_btwn_intersections(integer, integer) TO gis_admins; | ||
|
34 changes: 34 additions & 0 deletions
34
gis/centreline/sql/create_view_routing_centreline_directional.sql
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
CREATE OR REPLACE VIEW gis_core.routing_centreline_directional AS | ||
|
||
SELECT | ||
centreline.centreline_id, | ||
concat(centreline.centreline_id, 0)::integer AS id, | ||
centreline.from_intersection_id AS source, | ||
centreline.to_intersection_id AS target, | ||
centreline.shape_length AS cost, | ||
centreline.geom | ||
FROM gis_core.centreline_latest centreline | ||
|
||
UNION | ||
|
||
SELECT | ||
centreline.centreline_id, | ||
concat(centreline.centreline_id, 1)::integer AS id, | ||
centreline.to_intersection_id AS source, | ||
centreline.from_intersection_id AS target, | ||
centreline.shape_length AS cost, | ||
st_reverse(centreline.geom) AS geom | ||
FROM gis_core.centreline_latest centreline | ||
WHERE centreline.oneway_dir_code = 0; | ||
|
||
ALTER TABLE gis_core.routing_centreline_directional | ||
OWNER TO gis_admins; | ||
|
||
COMMENT ON VIEW gis_core.routing_centreline_directional | ||
IS 'A view that contains centreline streets for routing, with duplicated rows for two-way streets and flipped geometries when necessary. A new id has been assigned to each centreline to distinguish duplicated lines.'; | ||
|
||
GRANT SELECT ON TABLE gis_core.routing_centreline_directional TO bdit_humans; | ||
GRANT ALL ON TABLE gis_core.routing_centreline_directional TO gis_admins; | ||
|
||
|
||
|