Last active
January 17, 2021 12:34
-
-
Save KevCui/b32e3aeaa09e91b80d04f7fddc2bbe70 to your computer and use it in GitHub Desktop.
Show COVID-19 7-days incidence of a specific location in Germany
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
#!/usr/bin/env sh | |
# | |
# Show COVID-19 7-days incidence of a specific location in Germany | |
# Data fetched from https://hotspotornot.de/ | |
# | |
#/ Usage: | |
#/ ./hotspot.sh <location_name|postcode> | |
#/ | |
#/ Examples: | |
#/ $ ./hotspot.sh berlin | |
#/ $ ./hotspot.sh 10117 | |
for dependency in curl jq; do | |
if ! command -v "$dependency" > /dev/null; then | |
echo "[ERROR] Missing dependency: $dependency" && exit 1 | |
fi | |
done | |
locationdata=$(curl -sS "https://nominatim.openstreetmap.org/search?q=${1}&format=json&countrycodes=DE" -H 'Accept-Language: en') | |
if [ "$locationdata" = "[]" ]; then | |
echo "[ERROR] Location not found!" && exit 1 | |
fi | |
coorditnate=$(echo "$locationdata" | jq -r '.[0] | "\(.lon),\(.lat)"') | |
location=$(echo "$locationdata" | jq -r '.[0].display_name') | |
incidence=$(curl -sS "https://services7.arcgis.com/mOBPykOjAyBO2ZKk/arcgis/rest/services/RKI_Landkreisdaten/FeatureServer/0/query?outFields=OBJECTID,cases7_per_100k,GEN,last_update,BL&geometryType=esriGeometryPoint&spatialRel=esriSpatialRelWithin&inSR=4326&outSR=4326&f=json&geometry=${coorditnate}" -H 'Origin: x' | jq -r '.features[].attributes.cases7_per_100k') | |
printf '%s\n7-days incidence: %0.2f\n' "$location" "$incidence" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment