|
|
@@ -7,21 +7,22 @@
|
|
|
#' @keywords postgis, maps, ESRI Shpfile, OSM
|
|
|
#' @export
|
|
|
#' @examples
|
|
|
-#' ## Not run:
|
|
|
-#' ##
|
|
|
-#' ## osm_shp()
|
|
|
-#' ##
|
|
|
-#' ## End(**Not run**)
|
|
|
+#' \dontrun{
|
|
|
+#'
|
|
|
+#' conf <- ruut::get_config()
|
|
|
+#' osm_shp(conf = conf)
|
|
|
+#' }
|
|
|
osm_shp <- function(conf = NULL) {
|
|
|
- ans <- utils::askYesNo("Do you want to import maps into database?")
|
|
|
- if (!ans) {
|
|
|
+ ans <- utils::askYesNo("Do you want to import maps into database?", default = F)
|
|
|
+ if (!ans | is.na(ans)) {
|
|
|
cat("\n------------------------\n")
|
|
|
cat("Kaardikihte ei lisatud.")
|
|
|
cat("\n------------------------\n")
|
|
|
+ return()
|
|
|
}
|
|
|
if (ans) {
|
|
|
# Temp directory
|
|
|
- tmp_dir <- "/tmp/osm_shp"
|
|
|
+ tmp_dir <- sprintf("%s/tmp/%s", system.file(package = "estmap"), "osm_shp")
|
|
|
if (!dir.exists(tmp_dir)) {
|
|
|
dir.create(tmp_dir)
|
|
|
}
|
|
|
@@ -67,7 +68,7 @@ osm_shp <- function(conf = NULL) {
|
|
|
ls[i], conf$schema, conf$table
|
|
|
))
|
|
|
}
|
|
|
- # Delete temp directory
|
|
|
- # system(sprintf("rm -rf %s/*", tmp_dir))
|
|
|
+ # Delete unnecessary files.
|
|
|
+ system(sprintf("find %s -type f -not -name '%s' -print0 | xargs -0 rm --", tmp_dir, map_shapefile))
|
|
|
}
|
|
|
}
|