2323# ' \item \code{hour}, the hour for which the frequency applies (24 hour format).
2424# ' \item \code{frequency}, the number of services for the route that depart from the first stop for the corresponding 60 minutes period.
2525# ' \item \code{is_bus_lane}, whether the way has a bus lane.
26+ # ' \item \code{n_lanes_parking}, the number of parking lanes.
27+ # ' \item \code{n_lanes_circulation}, the number of circulation lanes.
2628# ' \item \code{n_lanes}, the total number of lanes.
2729# ' \item \code{n_directions}, the number of travel directions.
28- # ' \item \code{n_lanes_direction}, the number of lanes per direction.
30+ # ' \item \code{n_lanes_circulation_direction}, the number of circulation lanes per direction.
31+ # ' \item \code{n_lanes_direction}, the number of total lanes per direction.
2932# ' \item \code{routes}, the list of route_ids that use the way, separated by semicolon.
3033# ' \item \code{geometry}, the route shape.
3134# ' \item (if \code{keep_osm_attributes = TRUE}) all OSM way attributes.
@@ -74,7 +77,20 @@ prioritize_lanes <- function(
7477 left_join(bus_lanes | > sf :: st_drop_geometry() | > select(osm_id ) | > mutate(is_bus_lane = TRUE ), by = c(" way_osm_id" = " osm_id" )) | >
7578 mutate(
7679 is_bus_lane = ifelse(is.na(is_bus_lane ), FALSE , is_bus_lane ),
77- n_lanes = coalesce(
80+ n_lanes_parking = dplyr :: case_when(
81+ # Any 'parking:both' or 'parking:lane:both' column present with value different from 'no'
82+ if_any(starts_with(" parking:both" ), ~ ! is.na(. ) & . != " no" ) ~ 2L ,
83+ # Otherwise, count left and right sides separately based on specific tags
84+ TRUE ~ (
85+ as.integer(
86+ if_any(starts_with(" parking:left" ),~ ! is.na(. ) & . != " no" )
87+ ) +
88+ as.integer(
89+ if_any(starts_with(" parking:right" ), ~ ! is.na(. ) & . != " no" )
90+ )
91+ )
92+ ),
93+ n_lanes_circulation = coalesce(
7894 # Global count
7995 parse_lanes(lanes ),
8096 # Directional count
@@ -85,11 +101,17 @@ prioritize_lanes <- function(
85101 2 # NA_integer_
86102 ),
87103 n_directions = case_when(
88- n_lanes == 1 ~ 1 , # When only one lane, assume one direction
104+ n_lanes_circulation == 1 ~ 1 , # When only one lane, assume one direction
89105 oneway %in% c(" yes" , " 1" , " -1" , " true" ) ~ 1 ,
90106 oneway %in% c(" no" , " 0" , " false" ) ~ 2 ,
91107 TRUE ~ 2
92108 ),
109+ n_lanes_circulation_direction = case_when(
110+ n_lanes_circulation / n_directions < 1 ~ 1 ,
111+ ! is.na(n_lanes_circulation ) & ! is.na(n_directions ) ~ n_lanes_circulation / n_directions ,
112+ TRUE ~ NA_real_
113+ ),
114+ n_lanes = n_lanes_circulation + n_lanes_parking ,
93115 n_lanes_direction = case_when(
94116 n_lanes / n_directions < 1 ~ 1 ,
95117 ! is.na(n_lanes ) & ! is.na(n_directions ) ~ n_lanes / n_directions ,
@@ -99,7 +121,7 @@ prioritize_lanes <- function(
99121
100122 if (! keep_osm_attributes ) {
101123 lanes = lanes | >
102- select(way_osm_id , hour , frequency , is_bus_lane , n_lanes , n_directions , n_lanes_direction , routes , geometry )
124+ select(way_osm_id , hour , frequency , is_bus_lane , n_lanes_parking , n_lanes_circulation , n_lanes , n_directions , n_lanes_circulation_direction , n_lanes_direction , routes , geometry )
103125 }
104126
105127 return (lanes )
0 commit comments