fto_checkosm.R 1.04 KB
Newer Older
Jean-Marie Lepioufle's avatar
first  
Jean-Marie Lepioufle committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#' fto_checkosm

#' fto_checkosm
#' @param ft_osmdata ft_osmdata
#' @param tags tags
#' @param osmdir path of osm files
#' @param place_name place_name
#' @keywords osmosm
#' @export
#' @examples
#' \dontrun{
#' fto_checkosm()
#' }
fto_checkosm <- function(ft_osmdata=NULL,
                        tags=c("roads"),
                        osmdir,
                        place_name
                     ){

    ft_osmdata_ <- ft_osmdata

    res <- lapply(1:length(ft_osmdata),function(x){
     lapply(1:length(ft_osmdata[[x]]),function(y){

       if (ft_osmdata[[x]][[y]]$tags %in% tags) {

         name <- paste0(place_name,"_",names(ft_osmdata)[x] , "_", names(ft_osmdata[[x]])[y],"_sf")

         cat("\n ** Targeting ",name, "...\n")
         filename <- paste0(name,".rda")
         if (file.exists(normalizePath(file.path(osmdir,filename),mustWork = FALSE))) {
           cat("\n -> File targeted \n")
           ft_osmdata_[[x]][[y]]$file <<- filename
         } else {cat("\n -> File does not exist \n")}

       }
     })
    })
    return(ft_osmdata_)

}