Map - Fixed OSM map downloader with new logic to scrape new HTML format on Geofabrik site. This could be a moving target, but it is worth updating once more.

This commit is contained in:
Gaston Gonzalez
2024-12-03 06:19:42 -07:00
parent 419abfa615
commit 2fce9d042e
+4 -4
View File
@@ -1,6 +1,7 @@
#!/bin/bash
# Author : Gaston Gonzalez
# Date : 4 November 2024
# Updated : 3 December 2024
# Purpose : Downloads OSM .pbf file selected by user
HTML=page.html
@@ -25,12 +26,11 @@ et-log "Extracting state-level .pbf file list..."
options=()
while IFS= read -r state_html; do
state_file_suffix=$(echo $state_html | sed -n 's/.*href="\([^"]*\)".*/\1/p')
pbf_file=$(echo $state_file_suffix | sed 's|bz2|pbf|')
state_url="http://download.geofabrik.de/north-america/${pbf_file}"
state_file=$(echo $state_html | sed -n 's|.*href="\([^"]*\.osm\.pbf\)".*|\1|p')
state_url="http://download.geofabrik.de/north-america/${state_file}"
# Extract a display friendly name for the state
state_name=$(echo $state_file_suffix | sed 's|us/||' | sed 's|-latest.osm.bz2||')
state_name=$(echo $state_file | sed 's|us/||' | sed 's|-latest.osm.pbf||')
options+=("$state_name" "$state_url")
done < <(grep "[.]pbf" page.html | grep 'href="us/' | sort)