|
2 | 2 | utils::globalVariables(c("edge_paths", "influence_network", "all_fastest_bicycle_go_dutch", |
3 | 3 | "weight", "to_linegraph", "edges", "group", "mean_potential", "LAD23NM", |
4 | 4 | "road_function", "grid_id", "density", |
5 | | - "max_value", "min_value", "arterialness", "road_score", "value", "key_attribute", "n_group",".data", "n_removeDangles", "path_type", "maxDistPts", "minDistPts","penalty_value","penalty", "use_stplanr", "group_column")) |
6 | | - |
| 5 | + "max_value", "min_value", "arterialness", "road_score", "value", "key_attribute", "n_group",".data", "n_removeDangles", "path_type", "maxDistPts", "minDistPts","penalty_value","penalty", "use_stplanr", "group_column", |
| 6 | + # Variables from net_eval.R functions |
| 7 | + "geometry", "InterZone", "TotPop2011", "StdAreaKm2", "ResPop2011", "W_i", |
| 8 | + "has_intersection", "covered_area", "covered_area_km2", "pop_density", |
| 9 | + "covered_population", "distance_to_network", "all", "length_m", "km", |
| 10 | + "target_id", "id")) |
7 | 11 | #' Prepare a cohesive cycling network using NPT data |
8 | 12 | #' |
9 | 13 | #' This function prepares the base network for generating a cohesive cycling network |
@@ -193,9 +197,9 @@ corenet = function(influence_network, cohesive_base_network, target_zone, key_at |
193 | 197 |
|
194 | 198 | # Perform DBSCAN clustering |
195 | 199 | coordinates = sf::st_coordinates(centroids) |
196 | | - coordinates_clean = coordinates[complete.cases(coordinates), ] |
| 200 | + coordinates_clean = coordinates[stats::complete.cases(coordinates), ] |
197 | 201 | clusters = dbscan::dbscan(coordinates_clean, eps = 18, minPts = 1) |
198 | | - centroids_clean = centroids[complete.cases(coordinates), ] |
| 202 | + centroids_clean = centroids[stats::complete.cases(coordinates), ] |
199 | 203 | centroids_clean$cluster = clusters$cluster |
200 | 204 | unique_centroids = centroids_clean[!duplicated(centroids_clean$cluster), ] |
201 | 205 |
|
@@ -321,6 +325,9 @@ corenet = function(influence_network, cohesive_base_network, target_zone, key_at |
321 | 325 | # Prepare network and calculate paths |
322 | 326 | prepared_network = prepare_network(cohesive_base_network, key_attribute , road_scores, transform_crs = crs , penalty_value = penalty_value) |
323 | 327 |
|
| 328 | + # Initialize cache environment for path calculations |
| 329 | + path_cache_env = new.env(parent = emptyenv()) |
| 330 | + assign("path_cache_env", path_cache_env, envir = .GlobalEnv) |
324 | 331 |
|
325 | 332 | all_paths = purrr::map_dfr( |
326 | 333 | seq_len(nrow(unique_centroids)), |
@@ -479,12 +486,10 @@ prepare_network = function(network, key_attribute = "all_fastest_bicycle_go_dutc |
479 | 486 | #' @param minDistPts The minimum distance (in meters) to consider for path calculations. |
480 | 487 | #' @param centroids An sf object containing centroids to which paths are calculated. |
481 | 488 | #' @param path_type A character string indicating the type of path calculation: 'shortest', 'all_shortest', or 'all_simple'. |
482 | | -#' @param max_path_weight |
| 489 | +#' @param max_path_weight Maximum weight allowed for paths in network calculations. |
| 490 | +#' @param crs_transform The coordinate reference system to transform to, default is 27700 (British National Grid). |
483 | 491 | #' |
484 | | -#' - 'shortest': Calculates the shortest path considering weights. |
485 | | -#' - 'all_shortest': Calculates all paths that tie for the shortest distance, considering weights. |
486 | | -#' - 'all_simple': Calculates all simple paths, ignoring weights. |
487 | | -#' @return An sf object containing the paths that meet the criteria or NULL if no paths meet the criteria. |
| 492 | +#' @return A list containing the computed paths and their associated weights. |
488 | 493 | #' @export |
489 | 494 |
|
490 | 495 | calculate_paths_from_point_dist = function( |
|
0 commit comments