Skip to content

Commit

Permalink
fix conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
wangzhao0217 committed Dec 2, 2024
1 parent 836fd04 commit 59a7eec
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 90 deletions.
19 changes: 12 additions & 7 deletions R/corenet_build_OS.R
Original file line number Diff line number Diff line change
Expand Up @@ -239,14 +239,19 @@ corenet_build_OS = function(os_scotland, osm_scotland, la_names) {
)

# Define the file path for the combined GeoJSON
combined_CN_file = glue::glue("{output_folder}/combined_CN_{date_folder}_OS.geojson")
combined_CN_geojson_file = glue::glue("{output_folder}/combined_CN_{date_folder}_OS.geojson")
combined_CN_gpkg_file = glue::glue("{output_folder}/combined_CN_{date_folder}_OS.gpkg")

# Write the combined GeoJSON to a file
sf::st_write(combined_CN_geojson, combined_CN_file, delete_dsn = TRUE)
cat("Combined cohesive networks GeoJSON file for group has been saved to:", combined_CN_file, "\n")
# Write the combined data to GeoJSON and GeoPackage files
sf::st_write(final_la_coherent, combined_CN_geojson_file, delete_dsn = TRUE)
sf::st_write(final_la_coherent, combined_CN_gpkg_file, delete_dsn = TRUE)

# Print messages indicating where the files have been saved
cat("Combined cohesive networks GeoJSON file has been saved to:", combined_CN_geojson_file, "\n")
cat("Combined cohesive networks GeoPackage file has been saved to:", combined_CN_gpkg_file, "\n")

# Define the path for the PMtiles
combined_CN_pmtiles = glue::glue("{output_folder}/combined_CN_{number}_{date_folder}_OS.pmtiles")
combined_CN_pmtiles = glue::glue("{output_folder}/{output_folder}/combined_CN_{date_folder}_OS.pmtiles")

# Construct the Tippecanoe command for the current group
command_tippecanoe = paste0(
Expand All @@ -261,11 +266,11 @@ corenet_build_OS = function(os_scotland, osm_scotland, la_names) {
' --buffer=5',
' -rg',
' --force ',
combined_CN_file
combined_CN_geojson_file
)

# Execute the command and capture output
system_output = system(command_tippecanoe, intern = TRUE)
cat("Tippecanoe output for group", number, ":\n", system_output, "\n")

}

93 changes: 27 additions & 66 deletions _targets.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ tar_option_set(
# Turn off when memory is not an issue as it's slow:
# https://github.com/ropensci/targets/issues/1349
# garbage_collection = FALSE
# See https://books.ropensci.org/targets/performance.html#memory:
# Turn off when memory is not an issue as it's slow:
# https://github.com/ropensci/targets/issues/1349
# garbage_collection = FALSE
)

# Targets -----------------------------------------------------------------
Expand Down Expand Up @@ -216,68 +220,24 @@ list(
}),

# School routing ----------------------------------------------------------

tar_target(rs_school_fastest, {
rs = get_routes(
od = od_school |> slice_max(n = parameters$max_to_route, order_by = all, with_ties = FALSE),
plans = "fastest",
purpose = "school",
folder = region_folder,
date = parameters$date_routing,
segments = "both"
)
rs
}),
tar_target(done_school_fastest, {
length(rs_school_fastest) # Hack for scheduling
}),
tar_target(rs_school_quietest, {
length(done_school_fastest)
rs = get_routes(
od = od_school |> slice_max(n = parameters$max_to_route, order_by = all, with_ties = FALSE),
plans = "quietest",
purpose = "school",
folder = region_folder,
date = parameters$date_routing,
segments = "both"
)
rs
}),
tar_target(done_school_quietest, {
length(rs_school_quietest) # Hack for scheduling
}),

# Balanced:
tar_target(rs_school_balanced, {
length(done_school_quietest)
rs = get_routes(
od = od_school |> slice_max(n = parameters$max_to_route, order_by = all, with_ties = FALSE),
plans = "balanced",
purpose = "school",
folder = region_folder,
date = parameters$date_routing,
segments = "both"
)
rs
}),
tar_target(done_school_balanced, {
length(rs_school_balanced) # Hack for scheduling
}),
tar_target(rs_school_ebike, {
length(done_school_quietest)
rs = get_routes(
od = od_school |> slice_max(n = parameters$max_to_route, order_by = all, with_ties = FALSE),
plans = "ebike",
purpose = "school",
folder = region_folder,
date = parameters$date_routing,
segments = "both"
)
rs
}),
tar_target(done_school_ebike, {
length(rs_school_ebike) # Hack for scheduling
}),
tar_target(plans, {
parameters$plans
}),

tar_target(rs_school, {
get_routes(
od = od_school |> slice_max(n = parameters$max_to_route, order_by = all, with_ties = FALSE),
plans = plans,
purpose = "school",
folder = region_folder,
date = parameters$date_routing,
segments = "both")
},
pattern = map(plans),
iteration = "list"
)

,

# Commute routing ---------------------------------------------------------

Expand All @@ -298,16 +258,16 @@ list(
# Commute routing post-processing -----------------------------------------

tar_target(r_commute_fastest, {
rs_commute_fastest[[1]]$routes
rs_commute[[1]][[1]]$routes
}),
tar_target(r_commute_quietest, {
rs_commute_quietest[[1]]$routes
rs_commute[[3]][[1]]$routes
}),
tar_target(r_commute_ebike, {
rs_commute_ebike[[1]]$routes
rs_commute[[4]][[1]]$routes
}),
tar_target(r_commute_balanced, {
rs_commute_balanced[[1]]$routes
rs_commute[[2]][[1]]$routes
}),
tar_target(rnet_gq_commute_fastest, {
segments2rnet(rs_commute[[1]][[1]]$segments)
Expand Down Expand Up @@ -1197,6 +1157,7 @@ list(
use_sf_s2_status = sf::sf_use_s2()
sf::sf_use_s2(FALSE)
rnet_simple = simplify_network(combined_network_tile, region_name, region_boundary)
rnet_simple = simplify_network(combined_network_tile, region_name, region_boundary)
make_geojson_zones(rnet_simple, paste0(region_folder, "/simplified_network.geojson"))
# Restore previous status
sf::sf_use_s2(use_sf_s2_status)
Expand Down
17 changes: 0 additions & 17 deletions route_ids.csv
Original file line number Diff line number Diff line change
@@ -1,21 +1,4 @@
nrow,plan,purpose,region,date,id
18924,quietest,utility,city_of_edinburgh,2024-11-31,11366
100,balanced,utility,city_of_edinburgh,2024-11-30,11014
100,balanced,commute,city_of_edinburgh,2024-11-30,11011
100,quietest,school,city_of_edinburgh,2024-11-30,11009
100,balanced,utility,clackmannanshire,2024-11-30,11005
100,quietest,commute,clackmannanshire,2024-11-30,11003
100,ebike,school,clackmannanshire,2024-11-30,11001
100,quietest,utility,city_of_edinburgh,2024-11-30,10878
100,quietest,commute,city_of_edinburgh,2024-11-30,10876
100,balanced,school,city_of_edinburgh,2024-11-30,10871
100,ebike,utility,clackmannanshire,2024-11-30,10868
100,ebike,commute,clackmannanshire,2024-11-30,10865
100,fastest,school,clackmannanshire,2024-11-30,10861
100,balanced,school,clackmannanshire,2024-11-30,10857
100,balanced,utility,clackmannanshire,2024-10-01,10818
100,balanced,commute,clackmannanshire,2024-10-01,10813
100,fastest,commute,clackmannanshire,2024-10-01,10810
100,ebike,commute,City of Edinburgh,2024-10-01,10793
100,balanced,school,City of Edinburgh,2024-10-01,10789
100,quietest,school,City of Edinburgh,2024-10-01,10785
Expand Down

0 comments on commit 59a7eec

Please sign in to comment.