Skip to content

Commit

Permalink
#884 add functions and view for routing centreline
Browse files Browse the repository at this point in the history
  • Loading branch information
chmnata committed Feb 22, 2024
1 parent 9aeac92 commit df7b9a9
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
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,

Check failure on line 2 in gis/centreline/sql/create_function_get_centreline_btwn_intersections.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

LT02: Expected indent of 4 spaces.
_node_end integer,

Check failure on line 3 in gis/centreline/sql/create_function_get_centreline_btwn_intersections.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

LT02: Expected indent of 4 spaces.
OUT _node_start_out integer,

Check failure on line 4 in gis/centreline/sql/create_function_get_centreline_btwn_intersections.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

LT02: Expected indent of 4 spaces.
OUT _node_end integer,

Check failure on line 5 in gis/centreline/sql/create_function_get_centreline_btwn_intersections.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

LT02: Expected indent of 4 spaces.
OUT links text[],

Check failure on line 6 in gis/centreline/sql/create_function_get_centreline_btwn_intersections.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

LT02: Expected indent of 4 spaces.

Check notice on line 6 in gis/centreline/sql/create_function_get_centreline_btwn_intersections.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

LT01: Expected single whitespace between 'text' keyword and start square bracket '['.
OUT geom geometry)

Check failure on line 7 in gis/centreline/sql/create_function_get_centreline_btwn_intersections.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

LT02: Expected indent of 4 spaces.

Check failure on line 7 in gis/centreline/sql/create_function_get_centreline_btwn_intersections.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

LT02: Expected line break and no indent before ')'.
RETURNS record

Check failure on line 8 in gis/centreline/sql/create_function_get_centreline_btwn_intersections.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

LT02: Line should not be indented.
LANGUAGE 'sql'

Check failure on line 9 in gis/centreline/sql/create_function_get_centreline_btwn_intersections.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

LT02: Line should not be indented.
COST 100

Check failure on line 10 in gis/centreline/sql/create_function_get_centreline_btwn_intersections.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

LT02: Line should not be indented.
STABLE STRICT PARALLEL UNSAFE

Check failure on line 11 in gis/centreline/sql/create_function_get_centreline_btwn_intersections.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

LT02: Line should not be indented.
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;

Check failure on line 26 in gis/centreline/sql/create_function_get_centreline_btwn_intersections.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

LT02: Line should not be indented.

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.';

Check failure on line 29 in gis/centreline/sql/create_function_get_centreline_btwn_intersections.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

LT02: Line should not be indented.

Check notice on line 29 in gis/centreline/sql/create_function_get_centreline_btwn_intersections.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

LT05: Line is too long (192 > 100).

GRANT EXECUTE ON FUNCTION gis_core.get_centreline_btwn_intersections(integer, integer) TO bdit_humans;

Check notice on line 31 in gis/centreline/sql/create_function_get_centreline_btwn_intersections.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

LT05: Line is too long (102 > 100).

GRANT EXECUTE ON FUNCTION gis_core.get_centreline_btwn_intersections(integer, integer) TO gis_admins;

Check notice on line 33 in gis/centreline/sql/create_function_get_centreline_btwn_intersections.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

LT05: Line is too long (101 > 100).

34 changes: 34 additions & 0 deletions gis/centreline/sql/create_view_routing_centreline_directional.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
CREATE OR REPLACE VIEW gis_core.routing_centreline_directional AS

Check notice on line 2 in gis/centreline/sql/create_view_routing_centreline_directional.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

LT01: Unnecessary trailing whitespace.
SELECT

Check notice on line 3 in gis/centreline/sql/create_view_routing_centreline_directional.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

LT01: Unnecessary trailing whitespace.
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,

Check failure on line 8 in gis/centreline/sql/create_view_routing_centreline_directional.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

RF04: Keywords should not be used as identifiers.
centreline.geom
FROM gis_core.centreline_latest centreline

Check failure on line 10 in gis/centreline/sql/create_view_routing_centreline_directional.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

LT02: Line should not be indented.

Check failure on line 10 in gis/centreline/sql/create_view_routing_centreline_directional.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

AL01: Implicit/explicit aliasing of table.

UNION

SELECT

Check notice on line 14 in gis/centreline/sql/create_view_routing_centreline_directional.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

LT01: Unnecessary trailing whitespace.
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,

Check failure on line 19 in gis/centreline/sql/create_view_routing_centreline_directional.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

RF04: Keywords should not be used as identifiers.
st_reverse(centreline.geom) AS geom
FROM gis_core.centreline_latest centreline

Check failure on line 21 in gis/centreline/sql/create_view_routing_centreline_directional.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

LT02: Line should not be indented.

Check failure on line 21 in gis/centreline/sql/create_view_routing_centreline_directional.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

AL01: Implicit/explicit aliasing of table.
WHERE centreline.oneway_dir_code = 0;

Check failure on line 22 in gis/centreline/sql/create_view_routing_centreline_directional.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

LT02: Line should not be indented.

ALTER TABLE gis_core.routing_centreline_directional
OWNER TO gis_admins;

Check failure on line 25 in gis/centreline/sql/create_view_routing_centreline_directional.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

LT02: Line should not be indented.

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.';

Check failure on line 28 in gis/centreline/sql/create_view_routing_centreline_directional.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

LT02: Line should not be indented.

Check notice on line 28 in gis/centreline/sql/create_view_routing_centreline_directional.sql

View workflow job for this annotation

GitHub Actions / SQLFluff Lint

SQLFluff

LT05: Line is too long (221 > 100).

GRANT SELECT ON TABLE gis_core.routing_centreline_directional TO bdit_humans;
GRANT ALL ON TABLE gis_core.routing_centreline_directional TO gis_admins;



0 comments on commit df7b9a9

Please sign in to comment.