Coordinates as const
This commit is contained in:
+7
-3
@@ -9,11 +9,15 @@ use tokio::{task, time};
|
|||||||
const METEO_MUNICH_API_URL: &str =
|
const METEO_MUNICH_API_URL: &str =
|
||||||
"https://www.meteorologie.lmu.de/~quicklooks/aktuelle_messwerte/messwerte_stadt.html";
|
"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")]
|
#[tokio::main(flavor = "current_thread")]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
let (client, mut eventloop) = create_conn();
|
let (client, mut eventloop) = create_conn();
|
||||||
|
|
||||||
match meteo_weather(48.163142, 11.542922).await {
|
match meteo_weather().await {
|
||||||
Ok(weather) => {
|
Ok(weather) => {
|
||||||
task::spawn(async move {
|
task::spawn(async move {
|
||||||
publish(client.clone(), &weather).await;
|
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 = trpl::get(METEO_MUNICH_API_URL).await;
|
||||||
let response_text = response.text().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 {
|
if temperature == 999.0 {
|
||||||
let url = format!(
|
let url = format!(
|
||||||
"https://api.brightsky.dev/current_weather?lat={}&lon={}",
|
"https://api.brightsky.dev/current_weather?lat={}&lon={}",
|
||||||
latitude, longitude
|
LATITUDE_MUC, LONGITUDE_MUC
|
||||||
);
|
);
|
||||||
println!("Fetching DWD {}", url);
|
println!("Fetching DWD {}", url);
|
||||||
let result = trpl::get(&url).await.text().await;
|
let result = trpl::get(&url).await.text().await;
|
||||||
|
|||||||
Reference in New Issue
Block a user