Coordinates as const

This commit is contained in:
Dimitris
2026-06-12 11:39:17 +02:00
parent 8409c94f7a
commit 8696357787
+7 -3
View File
@@ -9,11 +9,15 @@ use tokio::{task, time};
const METEO_MUNICH_API_URL: &str =
"https://www.meteorologie.lmu.de/~quicklooks/aktuelle_messwerte/messwerte_stadt.html";
const LATITUDE_MUC: f64 = 48.163142;
const LONGITUDE_MUC: f64 = 11.542922;
#[tokio::main(flavor = "current_thread")]
async fn main() {
let (client, mut eventloop) = create_conn();
match meteo_weather(48.163142, 11.542922).await {
match meteo_weather().await {
Ok(weather) => {
task::spawn(async move {
publish(client.clone(), &weather).await;
@@ -42,7 +46,7 @@ async fn main() {
}
}
pub async fn meteo_weather(latitude: f64, longitude: f64) -> Result<MucWeather, reqwest::Error> {
pub async fn meteo_weather() -> Result<MucWeather, reqwest::Error> {
let response = trpl::get(METEO_MUNICH_API_URL).await;
let response_text = response.text().await;
@@ -104,7 +108,7 @@ pub async fn meteo_weather(latitude: f64, longitude: f64) -> Result<MucWeather,
if temperature == 999.0 {
let url = format!(
"https://api.brightsky.dev/current_weather?lat={}&lon={}",
latitude, longitude
LATITUDE_MUC, LONGITUDE_MUC
);
println!("Fetching DWD {}", url);
let result = trpl::get(&url).await.text().await;