mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-24 09:24:26 +03:00
122 lines
4.5 KiB
Bash
Executable File
122 lines
4.5 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
only_map=""
|
|
release="--release"
|
|
for arg in "$@"; do
|
|
if [ "$arg" == "--debug" ]; then
|
|
release="";
|
|
else
|
|
only_map=$arg;
|
|
fi
|
|
done
|
|
|
|
# First prepare input.
|
|
|
|
function get_if_needed {
|
|
if [ ! -f $2 ]; then
|
|
wget $1 -O $2;
|
|
fi
|
|
}
|
|
|
|
mkdir -p data/input data/raw_maps
|
|
|
|
# TODO refactor a variant for .zips?
|
|
if [ ! -d data/input/google_transit_2018_18_08/ ]; then
|
|
get_if_needed \
|
|
https://metro.kingcounty.gov/GTFS/google_transit_2018_18_08.zip \
|
|
data/input/google_transit_2018_18_08.zip;
|
|
unzip -d data/input/google_transit_2018_18_08 data/input/google_transit_2018_18_08.zip;
|
|
rm -f data/input/google_transit_2018_18_08.zip;
|
|
fi
|
|
|
|
if [ ! -f data/input/neighborhoods.geojson ]; then
|
|
# https://data.seattle.gov/dataset/Neighborhoods/2mbt-aqqx in GeoJSON, not SHP
|
|
get_if_needed \
|
|
https://github.com/seattleio/seattle-boundaries-data/raw/master/data/neighborhoods.geojson \
|
|
data/input/neighborhoods.geojson;
|
|
fi
|
|
|
|
if [ ! -f data/input/Seattle.osm ]; then
|
|
get_if_needed \
|
|
http://download.bbbike.org/osm/bbbike/Seattle/Seattle.osm.gz \
|
|
data/input/Seattle.osm.gz;
|
|
gunzip data/input/Seattle.osm.gz;
|
|
fi
|
|
|
|
for poly in `ls data/polygons/`; do
|
|
name=`basename -s .poly $poly`;
|
|
if [ ! -f data/input/$name.osm ]; then
|
|
osmosis \
|
|
--read-xml enableDateParsing=no file=data/input/Seattle.osm \
|
|
--bounding-polygon file=data/polygons/$name.poly completeWays=true \
|
|
--write-xml data/input/$name.osm
|
|
fi
|
|
done
|
|
|
|
if [ ! -f data/shapes/blockface.bin ]; then
|
|
# From http://data-seattlecitygis.opendata.arcgis.com/datasets/blockface
|
|
get_if_needed https://opendata.arcgis.com/datasets/a1458ad1abca41869b81f7c0db0cd777_0.kml data/input/blockface.kml;
|
|
|
|
cd kml
|
|
time cargo run --release -- \
|
|
--input=../data/input/blockface.kml \
|
|
--output=../data/shapes/blockface.bin
|
|
cd ..
|
|
fi
|
|
|
|
if [ ! -f data/shapes/street_signs.bin ]; then
|
|
# From http://data-seattlecitygis.opendata.arcgis.com/datasets/411a96b39c834a2380a256b8afa5003b_0
|
|
get_if_needed https://opendata.arcgis.com/datasets/411a96b39c834a2380a256b8afa5003b_0.kml data/input/street_signs.kml;
|
|
|
|
cd kml
|
|
time cargo run --release -- \
|
|
--input=../data/input/street_signs.kml \
|
|
--output=../data/shapes/street_signs.bin
|
|
cd ..
|
|
fi
|
|
|
|
if [ ! -f data/input/household_vehicles.kml ]; then
|
|
# From https://gis-kingcounty.opendata.arcgis.com/datasets/acs-household-size-by-vehicles-available-acs-b08201-householdvehicles
|
|
get_if_needed https://opendata.arcgis.com/datasets/7842d815523c4f1b9564e0301e2eafa4_2372.kml data/input/household_vehicles.kml;
|
|
get_if_needed https://www.arcgis.com/sharing/rest/content/items/7842d815523c4f1b9564e0301e2eafa4/info/metadata/metadata.xml data/input/household_vehicles.xml;
|
|
fi
|
|
|
|
if [ ! -f data/input/commute_time.kml ]; then
|
|
# From https://gis-kingcounty.opendata.arcgis.com/datasets/acs-travel-time-to-work-acs-b08303-traveltime
|
|
get_if_needed https://opendata.arcgis.com/datasets/9b5fd85861a04c5ab8b7407c7b58da7c_2375.kml data/input/commute_time.kml;
|
|
get_if_needed https://www.arcgis.com/sharing/rest/content/items/9b5fd85861a04c5ab8b7407c7b58da7c/info/metadata/metadata.xml data/input/commute_time.xml;
|
|
fi
|
|
|
|
if [ ! -f data/input/commute_mode.kml ]; then
|
|
# From https://gis-kingcounty.opendata.arcgis.com/datasets/acs-means-of-transportation-to-work-acs-b08301-transportation
|
|
get_if_needed https://opendata.arcgis.com/datasets/1da9717ca5ff4505826aba40a7ac0a58_2374.kml data/input/commute_mode.kml;
|
|
get_if_needed https://www.arcgis.com/sharing/rest/content/items/1da9717ca5ff4505826aba40a7ac0a58/info/metadata/metadata.xml data/input/commute_mode.xml;
|
|
fi
|
|
|
|
if [ ! -f data/input/offstreet_parking.kml ]; then
|
|
# From https://data.seattle.gov/Transportation/Public-Garages-or-Parking-Lots/xefx-khzm
|
|
get_if_needed http://data-seattlecitygis.opendata.arcgis.com/datasets/8e52dfde6d5d45948f7a90654c8d50cd_0.kml data/input/offstreet_parking.kml;
|
|
fi
|
|
|
|
cd convert_osm
|
|
for poly in `ls ../data/polygons/`; do
|
|
name=`basename -s .poly $poly`;
|
|
if [ "$only_map" != "" ] && [ "$only_map" != "$name" ]; then
|
|
continue;
|
|
fi
|
|
|
|
rm -rf ../data/neighborhoods/$name ../data/maps/${name}.bin;
|
|
RUST_BACKTRACE=1 cargo run $release -- \
|
|
--osm=../data/input/$name.osm \
|
|
--parking_shapes=../data/shapes/blockface.bin \
|
|
--offstreet_parking=../data/input/offstreet_parking.kml \
|
|
--gtfs=../data/input/google_transit_2018_18_08 \
|
|
--neighborhoods=../data/input/neighborhoods.geojson \
|
|
--clip=../data/polygons/$name.poly \
|
|
--output=../data/raw_maps/$name.bin
|
|
# Disabled, because it removes lots of parking that's really there.
|
|
#--street_signs=../data/shapes/street_signs.bin \
|
|
done
|