Last active
June 21, 2021 16:58
-
-
Save MarkTiedemann/4b41134134d40fcaa05bee9d4c9ca799 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
| let ziel_breite = 53.6659197; | |
| let ziel_hoehe = 10.2356524; | |
| require("https") | |
| .get("https://opendata.dwd.de/climate_environment/CDC/observations_germany/climate/10_minutes/air_temperature/now/zehn_now_tu_Beschreibung_Stationen.txt", async res => { | |
| let b = []; for await (let c of res) b.push(c); | |
| console.log( | |
| Buffer.concat(b) | |
| .toString("utf-8") | |
| .split("\r\n") | |
| .slice(2, -1) | |
| .map(l => { | |
| let stations_id = l.slice(0, 5).trim(); | |
| let breite = parseFloat(l.slice(39, 50).trim()); | |
| let hoehe = parseFloat(l.slice(51, 60).trim()); | |
| let stations_name = l.slice(61, 101).trim(); | |
| let bundesland = l.slice(102, 199).trim(); | |
| let distanz = Math.sqrt(Math.pow(breite - ziel_breite, 2) + Math.pow(hoehe - ziel_hoehe, 2)) | |
| return { stations_id, distanz, stations_name, bundesland }; | |
| }) | |
| .sort((a, b) => a.distanz - b.distanz) | |
| .slice(0, 5) | |
| ); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment