Skip to content

Commit

Permalink
Linting
Browse files Browse the repository at this point in the history
  • Loading branch information
wrridgeway committed Nov 3, 2024
1 parent d2b07d6 commit 9f067ee
Showing 1 changed file with 21 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,9 @@ walk(parquet_files, \(file_key) {
shapefile_data <- shapefile_data %>%
select(all_of(existing_columns)) %>%
mutate(
road_type = if ("FCNAME" %in% colnames(.)) FCNAME
else if ("FC_NAME" %in% colnames(.)) FC_NAME else NA,
road_type = if ("FCNAME" %in% colnames(.)) {

Check warning on line 108 in etl/scripts-ccao-data-warehouse-us-east-1/spatial/spatial-environment-traffic.R

View workflow job for this annotation

GitHub Actions / lint

file=/github/workspace/etl/scripts-ccao-data-warehouse-us-east-1/spatial/spatial-environment-traffic.R,line=108,col=21,[brace_linter] Either both or neither branch in `if`/`else` should use curly braces.
FCNAME
} else if ("FC_NAME" %in% colnames(.)) FC_NAME else NA,
lanes = if ("LNS" %in% colnames(.)) LNS else NA,
surface_type = if ("SURF_TYP" %in% colnames(.)) SURF_TYP else NA,
surface_width = if ("SURF_WTH" %in% colnames(.)) SURF_WTH else NA,
Expand All @@ -118,7 +119,11 @@ walk(parquet_files, \(file_key) {
road_name = if ("ROAD_NAME" %in% colnames(.)) ROAD_NAME else NA,
distress_with = if ("DTRESS_WTH" %in% colnames(.)) DTRESS_WTH else NA,
distress_opposing = if ("DTRESS_OPP" %in%
colnames(.)) DTRESS_OPP else NA,
colnames(.)) {

Check warning on line 122 in etl/scripts-ccao-data-warehouse-us-east-1/spatial/spatial-environment-traffic.R

View workflow job for this annotation

GitHub Actions / lint

file=/github/workspace/etl/scripts-ccao-data-warehouse-us-east-1/spatial/spatial-environment-traffic.R,line=122,col=10,[indentation_linter] Indentation should be 34 spaces but is 10 spaces.
DTRESS_OPP
} else {
NA
},
speed_limit = if ("SP_LIM" %in% colnames(.)) SP_LIM else NA,
inventory_id = if ("INVENTORY" %in% colnames(.)) INVENTORY else NA
) %>%
Expand Down Expand Up @@ -161,8 +166,10 @@ walk(parquet_files, \(file_key) {
mutate(across(-geometry, ~ replace(., . %in% c(0, "0000"), NA))) %>%
mutate(surface_year = ifelse(surface_year == 9999, NA, surface_year)) %>%
# Group by the characteristics that we want
group_by(road_name, speed_limit, lanes,
surface_type, daily_traffic, year, road_type) %>%
group_by(
road_name, speed_limit, lanes,
surface_type, daily_traffic, year, road_type
) %>%
# Create a union of the streets based on the summarized features
summarize(geometry = st_union(geometry), .groups = "drop") %>%
mutate(geometry_3435 = st_transform(geometry, 3435)) %>%
Expand All @@ -185,7 +192,7 @@ walk(parquet_files, \(file_key) {
)
})
) %>%
filter(polygon_1 != polygon_2) # Remove self-matches
filter(polygon_1 != polygon_2) # Remove self-matches
# Add polygon IDs and relevant columns for merging
data_with_ids <- data %>%
mutate(polygon_id = row_number()) %>%
Expand Down Expand Up @@ -228,13 +235,17 @@ walk(parquet_files, \(file_key) {
left_join(averages, by = c("polygon_id" = "polygon_1")) %>%
mutate(
daily_traffic = if_else(is.na(daily_traffic), average_daily_traffic,
daily_traffic),
daily_traffic
),
speed_limit = if_else(is.na(speed_limit), average_speed_limit,
speed_limit),
speed_limit
),
lanes = if_else(is.na(lanes), average_lanes, lanes)
) %>%
select(-c(average_daily_traffic, average_speed_limit,
average_lanes, polygon_id))
select(-c(
average_daily_traffic, average_speed_limit,
average_lanes, polygon_id
))

return(shapefile_data_final)
}
Expand Down Expand Up @@ -276,4 +287,3 @@ walk(parquet_files, \(file_key) {
print(paste(file_key, "cleaned and uploaded."))
}
}, .progress = TRUE)

0 comments on commit 9f067ee

Please sign in to comment.