feat: weather graphs
This commit is contained in:
52
src/data.rs
Normal file
52
src/data.rs
Normal file
@@ -0,0 +1,52 @@
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use crate::dwd::{DwdCache, DwdStation};
|
||||
|
||||
pub struct Data {
|
||||
pub dwd_cache: DwdCache,
|
||||
pub dwd_stations: BTreeMap<(String, usize), DwdStation>,
|
||||
pub dwd_stations_pos_range: (f64, f64, f64, f64, f64, f64),
|
||||
}
|
||||
|
||||
impl Data {
|
||||
pub fn new() -> Self {
|
||||
let dwd_stations = crate::dwd::load_stations();
|
||||
let dwd_stations_pos_range = (
|
||||
dwd_stations
|
||||
.values()
|
||||
.map(|v| v.pos.0)
|
||||
.min_by(|a, b| a.total_cmp(b))
|
||||
.unwrap(),
|
||||
dwd_stations
|
||||
.values()
|
||||
.map(|v| v.pos.0)
|
||||
.max_by(|a, b| a.total_cmp(b))
|
||||
.unwrap(),
|
||||
dwd_stations
|
||||
.values()
|
||||
.map(|v| v.pos.1)
|
||||
.min_by(|a, b| a.total_cmp(b))
|
||||
.unwrap(),
|
||||
dwd_stations
|
||||
.values()
|
||||
.map(|v| v.pos.1)
|
||||
.max_by(|a, b| a.total_cmp(b))
|
||||
.unwrap(),
|
||||
dwd_stations
|
||||
.values()
|
||||
.map(|v| v.pos.2)
|
||||
.min_by(|a, b| a.total_cmp(b))
|
||||
.unwrap(),
|
||||
dwd_stations
|
||||
.values()
|
||||
.map(|v| v.pos.2)
|
||||
.max_by(|a, b| a.total_cmp(b))
|
||||
.unwrap(),
|
||||
);
|
||||
Self {
|
||||
dwd_cache: DwdCache::default(),
|
||||
dwd_stations,
|
||||
dwd_stations_pos_range,
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user