Last active
October 14, 2020 18:49
-
-
Save mschmitt/887bc2cb557422a8544b72c663284343 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
BASH_LOADABLES_PATH=/usr/lib/bash:/usr/local/lib/bash | |
enable -f finfo finfo | |
declare -A query_counties | |
query_counties['Gießen']='https://services7.arcgis.com/mOBPykOjAyBO2ZKk/arcgis/rest/services/RKI_Landkreisdaten/FeatureServer/0/query?where=county%20%3D%20%27LK%20GIESSEN%27&outFields=cases7_per_100k&outSR=4326&f=json' | |
query_counties['Frankfurt']='https://services7.arcgis.com/mOBPykOjAyBO2ZKk/arcgis/rest/services/RKI_Landkreisdaten/FeatureServer/0/query?where=county%20%3D%20%27SK%20FRANKFURT%20AM%20MAIN%27&outFields=cases7_per_100k&outSR=4326&f=json' | |
query_counties['Amsterdam']='https://services.arcgis.com/nSZVuSZjHpEZZbRo/arcgis/rest/services/COVID19_gemeente_actueel_vlak/FeatureServer/0/query?f=json&where=Gemeentenummer%3D363&returnGeometry=false&spatialRel=esriSpatialRelIntersects&outFields=Total_reported_delta7_100k' | |
out="Covid-19-Fälle 7 Tage auf 100000:" | |
for county_name in "${!query_counties[@]}" | |
do | |
printf -v data_file "%s.json" "${county_name}" | |
if [[ -s "${data_file}" ]] | |
then | |
data_mtime="$(finfo -m "${data_file}")" | |
data_age=$(( $(date +%s) - $data_mtime )) | |
fi | |
if [[ ! -s "${data_file}" || $data_age -gt 3600 ]] | |
then | |
county_url="${query_counties["${county_name}"]}" | |
curl "${county_url}" > "${data_file}" || continue | |
fi | |
if [[ "${county_name}" == "Amsterdam" ]] | |
then | |
cases7_per_100k="$(jq '.features[0].attributes.Total_reported_delta7_100k' < "${data_file}")" || continue | |
else | |
cases7_per_100k="$(jq -e '.features[0].attributes.cases7_per_100k' < "${data_file}")" || continue | |
fi | |
printf -v out "%s %s=%.0f" "${out}" "${county_name}" "${cases7_per_100k}" | |
done | |
printf "%s\n" "${out}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment