53 lines
1.5 KiB
Rust
53 lines
1.5 KiB
Rust
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,
|
|
}
|
|
}
|
|
}
|