fabianhinz / rkicasesdashboard

tracks the spread of the disease in germany on a state and county level
https://rkicasesapi.web.app/
3 stars 0 forks source link

Recovered pro BL / LK / SK einbinden #35

Open fabianhinz opened 4 years ago

fabianhinz commented 4 years ago

sofern die API Daten zurückliefert:

fetch("https://services7.arcgis.com/mOBPykOjAyBO2ZKk/arcgis/rest/services/RKI_Landkreisdaten/FeatureServer/0/query?where=1%3D1&outFields=recovered,county,BL&returnGeometry=false&orderByFields=recovered DESC&outSR=4326&f=json")
    .then(response => response.json())
    .then(json => console.log(json.features))
fabianhinz commented 4 years ago

hier werden bereits Daten für BL und LK/SK zurückgeliefert. Jedoch sind nur 3 Bundesländer im response enhalten

fetch("https://services7.arcgis.com/mOBPykOjAyBO2ZKk/arcgis/rest/services/RKI_COVID19/FeatureServer/0/query?where=1%3D1&outFields=Bundesland,Landkreis,Altersgruppe,Geschlecht,AnzahlGenesen,Datenstand&returnGeometry=false&outSR=4326&f=json")
    .then(response => response.json())
    .then(json => {
        new Set(json.features.map(f => f.attributes.Bundesland)).forEach(state => {
            const gen = json.features
                .filter(f => f.attributes.Bundesland === state)
                .reduce((acc, f) => acc += f.attributes.AnzahlGenesen, 0)
            console.log(state, " ", gen)
        })
    }
    )

Response

BL Anzahl Genesen
Schleswig-Holstein 1376 
Hamburg 2019 
Niedersachsen 829 
fabianhinz commented 4 years ago

ein weiterer Endpunkt liefert pro Bundesland die Anzahl der Genesen wieder

https://services7.arcgis.com/mOBPykOjAyBO2ZKk/arcgis/rest/services/RKI_COVID19_Recovered_BL/FeatureServer/0/query?f=json&where=Bundesland%3D%27Hamburg%27&returnGeometry=false&spatialRel=esriSpatialRelIntersects&outFields=*&outStatistics=%5B%7B%22statisticType%22%3A%22sum%22%2C%22onStatisticField%22%3A%22Genesen%22%2C%22outStatisticFieldName%22%3A%22value%22%7D%5D&cacheHint=true

bei Bundesland IS NOT NULL im where query param reicht ein request aus https://services7.arcgis.com/mOBPykOjAyBO2ZKk/arcgis/rest/services/RKI_COVID19_Recovered_BL/FeatureServer/0/query?f=json&where=Bundesland%20IS%20NOT%20NULL&returnGeometry=false&spatialRel=esriSpatialRelIntersects&outFields=Bundesland,Genesen,DiffVortag,Datenstand&cacheHint=true

um folgendes Schmea in json.features zu erhalten

"attributes": {
  "Bundesland": string,
  "Genesen": number,
  "DiffVortag": number,
  "Datenstand": string
 }
fabianhinz commented 4 years ago

ToDo