example/
example.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*! Example usage of library demonstrating how to read an EPW File from the filesystem and
access both header data and weather data
!*/
use epw_rs::EPWFile;

fn main() {
    let parsed = EPWFile::from_path("./data/USA_FL_Tampa_TMY2.epw");
    match parsed {
        Ok(epw) => {
            let location = epw.header.location;
            let data = epw.data;
            println!(
                "Location: {:.4}, {:.4} [{}, {}]",
                location.latitude,
                location.longitude,
                location.city,
                location.state_province_region
            );
            let max_temp = match data.dry_bulb_temperature.into_iter().reduce(f64::max) {
                Some(t) => t,
                None => panic!("Couldn't calculate max temperature"),
            };
            println!("Max Temperature: {:.2}°C", max_temp);
        }
        Err(e) => println!("{:?}", e),
    }
}