Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Commit

Permalink
download major city maps
Browse files Browse the repository at this point in the history
  • Loading branch information
mdlincoln committed Apr 5, 2019
1 parent d96a4e8 commit 921f740
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
*.rda
*.mp4
drake_backups/
cities/
27 changes: 27 additions & 0 deletions osmar/drake.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ library(konigsbergr)
library(pathfinder)
library(jsonlite)
library(htmltools)
library(bigosm)

# Load all functions
dir_walk("osmar/R", source)
Expand Down Expand Up @@ -99,3 +100,29 @@ pgh_plan <- drake_plan(
),
mapshot(leaflet_map, url = file_out(fs::path(getwd(), "osmar/output_data/pgh_leaflet.html")))
)

city_bbs <- read_tsv(file = "https://raw.githubusercontent.com/dSHARP-CMU/boundingbox-cities/master/boundbox.txt", col_names = c("city", "ymax", "xmax", "ymin", "xmin"), col_types = "cnnnn")

city_plan <- drake_plan(
city_xml = GET("https://overpass-api.de/api/map?bbox=xmin__,ymin__,xmax__,ymax__", write_disk(file_out("cities/city.xml"))),
city_osm = read_big_osm(file_in("cities/city.xml"), way_keys = "highway"),
city_base_graph = base_konigsberg_graph(city_osm),
city_marked_graph = konigsberg_graph(city_base_graph, path_filter = automobile_highways, bridge_filter = main_bridges),
city_pathway = cross_all_bridges(city_marked_graph, cheat = TRUE),
city_visual = view_konigsberg_path(city_marked_graph, city_pathway)
)

route_plan <- pmap_df(city_bbs, function(city, ymax, xmax, ymin, xmin) {
city_slug <- str_replace_all(city, " ", "")

city_plan %>%
mutate(
target = str_replace(target, "city", city_slug),
command = str_replace_all(command, pattern = c("city" = city_slug,
"xmin__" = xmin,
"xmax__" = xmax,
"ymin__" = ymin,
"ymax__" = ymax)))
})

str_subset(route_plan$target, "osm")

0 comments on commit 921f740

Please sign in to comment.