Last active
August 13, 2020 12:46
-
-
Save DeoHeo/f17f28733891176d096f1948639d928b to your computer and use it in GitHub Desktop.
The local check Next Corona Wave can use for all countys in Germany to see the new cases in 7 days per 100,000 inhabitants. When the value is growing up 50, than start the state restrictions.
This file contains 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
#requires -Version 3.0 | |
<# | |
.SYNOPSIS | |
This local check helps to know the next Corona Wave is starting. | |
.DESCRIPTION | |
The local check Next Corona Wave can use for all countys in Germany to see the new cases in 7 days | |
per 100,000 inhabitants. When the value is growing up 50, than start the state restrictions. | |
.EXAMPLE | |
.\NextCoronaWave.ps1 | |
0 Corona_Warn_App count=;40;50;; OK - neue Fälle in den letzten 7 Tage pro 100.000 Einwohner im | |
in.\\nWenn der Schwellwert von 50 überstiegen ist wird es neue Restriktionen geben. | |
.NOTES | |
Author: Deo_Heo | |
Last Updated: 13.08.2020 | |
Version: 0.1 | |
Requires: | |
PowerShell | |
#> | |
#OBJECTID choose under the following web page for the appropriate county: | |
#https://npgeo-corona-npgeo-de.hub.arcgis.com/datasets/917fc37a709542548cc3be077a786c17_0?geometry=-26.087%2C46.269%2C46.994%2C55.886 | |
$objectid = 357 | |
#set the warn value | |
$warn = 40 | |
#set the crit value(should be left at 50) | |
$crit = 50 | |
#set it the service name(it must be a word) | |
$servicename = "Corona_Warn_App" | |
#choice the language german, default is english | |
$ger = $true | |
$choice = 0 | |
$crashed ='' | |
Function GetContent { | |
param( | |
$objectid | |
) | |
#get json content | |
try{ | |
$site = Invoke-WebRequest "https://services7.arcgis.com/mOBPykOjAyBO2ZKk/arcgis/rest/services/RKI_Landkreisdaten/FeatureServer/0/query?where=OBJECTID=%27$objectid%27&outFields=OBJECTID,BL,county,cases7_per_100k&returnGeometry=false&f=json" | |
IF ($site.StatusDescription -eq "OK"){ | |
$objoutput = New-Object -TypeName PSObject -Property @{ | |
value = $site.Content | ConvertFrom-Json | |
status = $true | |
} | |
} | |
ELSE{ | |
$objoutput = New-Object -TypeName PSObject -Property @{ | |
value = $site.StatusDescription | |
status = $false | |
} | |
} | |
} | |
catch{ | |
$objoutput = New-Object -TypeName PSObject -Property @{ | |
value = $_ | |
status = $false | |
} | |
} | |
return $objoutput | |
} | |
$objoutput = GetContent -objectid $objectid | |
If ($objoutput.status){ | |
$lankreis = $objoutput.value.features.attributes.county | |
$bundesland = $objoutput.value.features.attributes.BL | |
$var = $objoutput.value.features.attributes.cases7_per_100k | |
IF ($ger){ | |
#convert the value cases7_per_100k in the germany format | |
$var = „{0:N2}“ –f $var | |
} | |
ELSE{ | |
$var =„{0:C2}“ –f 4 | |
} | |
#choice the state | |
IF ($var -ge $warn){ | |
$choice = 1 | |
} | |
IF ($var -ge $crit){ | |
$choice = 2 | |
} | |
ELSE{ | |
$choice = 0 | |
} | |
} | |
ELSE{ | |
$choice = 3 | |
$crashed = $objoutput.value | |
} | |
SWITCH ($choice){ | |
0 {"0 $servicename count=$var;$warn;$crit;; OK - $var neue Fälle in den letzten 7 Tage pro 100.000 Einwohner im $lankreis in $bundesland.\\nWenn der Schwellwert $crit übersteigt, gibt es neue Restriktionen vom Bundesland $bundesland."} | |
1 {"1 $servicename count=$var;$warn;$crit;; WARN - $var neue Fälle in den letzten 7 Tage pro 100.000 Einwohner im $lankreis in $bundesland.\\nWenn der Schwellwert $crit übersteigt, gibt es neue Restriktionen vom Bundesland $bundesland."} | |
2 {"2 $servicename count=$var;$warn;$crit;; CRIT - $var neue Fälle in den letzten 7 Tage pro 100.000 Einwohner im $lankreis in $bundesland.\\nEs wird neue Restriktionen geben."} | |
3 {"3 $servicename count=$var;$warn;$crit;; UNKNOWN - API hat Probleme.\\n$crashed"} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment