R/osm_prep_network.R

Defines functions osm_prep_network

Documented in osm_prep_network

#' Title
#'
#' @param old_file
#' @param new_file
#'
#' @return
#' @export
#'
#' @importFrom magrittr %>%
#'
#' @examples
#' new_osm <- osm_prep_network(old_osm = buffalo_osm)

osm_prep_network <- function(old_osm) {

  new_lines <- stringr::str_replace(old_osm,
                           "(?<=lon=\".{3,12}\")/",
                           " version = \"1\"/")

  new_lines <- stringr::str_replace(new_lines,
                           "(?<=lon=\".{3,12}\")>",
                           " version = \"1\">")

  new_lines <- stringr::str_replace(new_lines,
                           '(?<=way id=\".{3,12}\")>',
                           " version = \"1\">")

  new_lines <- stringr::str_replace(new_lines,
                           '(?<=relation id=\".{3,12}\")>',
                           " version = \"1\">")
  new_lines
}
c-voulgaris/scenRios documentation built on March 18, 2023, 9:49 a.m.