Skip to content

Commit

Permalink
Merge pull request #29 from OPENER-next/export_cycle_barriers
Browse files Browse the repository at this point in the history
Export cycle barrier as access spaces
  • Loading branch information
Robbendebiene authored Oct 19, 2023
2 parents 1af0ae9 + 7627c23 commit 3bc7aad
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
6 changes: 3 additions & 3 deletions pipeline/routing/ppr.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ def insertAccessSpaces(cur, currentEdge, previousEdge, relation_id):
try:
# use INSERT INTO ... ON CONFLICT DO NOTHING to avoid duplicate entries
cur.execute(
'INSERT INTO access_spaces (osm_id, relation_id, "level", "IFOPT", tags, geom) VALUES (%s, %s, trim_scale(%s), %s, %s, ST_GeomFromText(%s, 4326)) ON CONFLICT DO NOTHING',
(currentEdge["from_node_osm_id"], relation_id, current_level, newDHID, None, geomString)
'INSERT INTO access_spaces (node_id, relation_id, "level", "IFOPT", geom) VALUES (%s, %s, trim_scale(%s), %s, ST_GeomFromText(%s, 4326)) ON CONFLICT DO NOTHING',
(currentEdge["from_node_osm_id"], relation_id, current_level, newDHID, geomString)
)
except Exception as e:
exit(e)
Expand Down Expand Up @@ -136,7 +136,7 @@ def requiresAccessSpace(currentEdge, previousEdge):
# They always have the same level, regardless of the direction. So the access spaces are identified by the level of the previous edge when going into the stairs,
# and the level of the current edge when going out of the stairs.

special_edge_types = ["elevator"]
special_edge_types = ["elevator", "cycle_barrier"]
special_street_types = ["stairs", "escalator", "moving_walkway"]

edge_type = currentEdge["edge_type"]
Expand Down
7 changes: 3 additions & 4 deletions pipeline/setup/sql/02_setup.sql
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,15 @@ CREATE TYPE category AS ENUM ('QUAY', 'ENTRANCE', 'PARKING', 'ACCESS_SPACE', 'SI
* Create access_spaces table:
* Table for the access spaces that will be generated from the paths.
* This table will be filled in the "routing" step of the pipeline.
* The osm_ids of the nodes have to be stored as BIGINT because the OSM ids are too big for INT.
* The node_ids of the nodes have to be stored as BIGINT because the OSM ids are too big for INT.
* Levels are stored as NUMERIC because they can be e.g. 0.5 or -1.
* The constraint PK_id is used to make sure, that there is only one access space per node and level.
*/
CREATE TABLE access_spaces (
osm_id BIGINT NOT NULL,
node_id BIGINT NOT NULL,
relation_id INT NOT NULL,
"level" NUMERIC NOT NULL,
"IFOPT" TEXT NOT NULL,
tags jsonb,
geom GEOMETRY,
CONSTRAINT PK_id PRIMARY KEY (osm_id,"level")
CONSTRAINT PK_id PRIMARY KEY (node_id,"level")
);
26 changes: 17 additions & 9 deletions pipeline/stop_places/sql/stop_places.sql
Original file line number Diff line number Diff line change
Expand Up @@ -452,13 +452,19 @@ CREATE OR REPLACE FUNCTION ex_keyList_AccessSpace(tags jsonb, additionalPairs xm
$$
SELECT create_keyList(xmlconcat(
additionalPairs,
-- 2080: bicycle barrier
COALESCE(
delfi_attribute_check_values_xml('2080', tags->>'barrier', 'cycle_barrier'),
delfi_attribute_check_values_xml('2080', tags->>'crossing:chicane')
),
-- 2081: movement area into, through and out of the narrow section
-- delfi_attribute_check_values_xml('2081', tags->>),
-- 2080: bicycle barrier opening width
-- 2081: bicycle barrier spacing width
(SELECT CASE
WHEN tags->>'barrier' = 'cycle_barrier' AND tags->>'cycle_barrier' IN ('single', 'tilted', 'diagonal') THEN
xmlconcat(
create_KeyValue('2080 ', parse_length(tags->>'maxwidth:physical'))
)
WHEN tags->>'barrier' = 'cycle_barrier' AND tags->>'cycle_barrier' IN ('double', 'triple') THEN
xmlconcat(
create_KeyValue('2080 ', parse_length(tags->>'opening')),
create_KeyValue('2081 ', parse_length(tags->>'spacing'))
)
END),
-- 2091: door width of the elevator
-- just the entry (door) of the elevator is considered as an access space
create_KeyValue('2091',
Expand Down Expand Up @@ -1126,8 +1132,10 @@ CREATE OR REPLACE VIEW final_entrances AS (
* Create view that matches all access spaces to public transport areas
*/
CREATE OR REPLACE VIEW final_access_spaces AS (
SELECT *
FROM access_spaces
SELECT acc.*, pois.tags
FROM access_spaces acc
LEFT JOIN pois
ON acc.node_id = pois.osm_id AND pois.osm_type = 'N'
);


Expand Down

0 comments on commit 3bc7aad

Please sign in to comment.