1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
#!/bin/sh
set -e
[ -n "$DEBUG" ] && { set -x; curl_args='-v'; }
# incidence = (sumCasesLast7Days / EWZ) * 100000
lat=52.54
lon=13.44
fields='GEN,RS,EWZ,EWZ_BL,BL_ID,cases,cases_per_100k,cases7_per_100k,cases7_bl_per_100k,last_update,BL,IBZ'
uri="https://services7.arcgis.com/mOBPykOjAyBO2ZKk/arcgis/rest/services/RKI_Landkreisdaten/FeatureServer/0/query?where=1%3D1&outFields=${fields}&geometry=${lon}%2C${lat}&geometryType=esriGeometryPoint&inSR=4326&spatialRel=esriSpatialRelWithin&returnGeometry=false&outSR=4326&f=json"
_data=$(curl -sSL -H 'Accept: application/json' ${curl_args} ${uri} | jq -r '.features[0].attributes')
loc=$(printf "${_data}" | jq -r '.GEN')
incidence_f=$(printf "%.1f" $(printf "${_data}" | jq -r '.cases7_bl_per_100k'))
incidence_i=$(printf "%.0f" "${incidence_f}")
color='green'
if [ "${incidence_i}" -eq "0" ]; then
color='gray'
fi
if [ "${incidence_i}" -gt "1" ]; then
color='green'
fi
if [ "${incidence_i}" -gt "25" ]; then
color='yellow'
fi
if [ "${incidence_i}" -gt "35" ]; then
color='orange'
fi
if [ "${incidence_i}" -gt "50" ]; then
color='red'
fi
if [ "${incidence_i}" -gt "100" ]; then
color='darkred'
fi
if [ "${incidence_i}" -gt "250" ]; then
color='darkdarkred'
fi
jq -nr \
--arg "if" "${incidence_f}" \
--arg "ii" "${incidence_i}" \
"{ text: \$if, percentage: \$ii, class: \"${color}\", alt: \"${color}\", tooltip: \"7 Tage Inzidenz für \\n${loc}\" } | @text"
|