#weather #forecast #dwml

weather_dot_gov_rs

Parses DWML XML from forecast.weather.gov

1 unstable release

new 0.1.0 Jan 15, 2025

#4 in #forecast

Download history 72/week @ 2025-01-10

72 downloads per month

AGPL-3.0

17KB
154 lines

weather_dot_gov_rs

Parses the DWML machine-readable format produced by forecast.weather.gov.

e.g. cargo run --example reqwest 40.71 -74.01 yields:

Dwml {
    head: Head {
        product: Product {
            creation_date: CreationDate {
                refresh_frequency: "PT1H",
                value: "2025-01-14T18:08:11-05:00",
            },
        },
        source: Source {
            production_center: "New York, NY",
        },
    },
    data: (
        Forecast {
            location: Location {
                area_description: None,
                description: Some(
                    "New York, NY",
                ),
            },
            time_layout: (
                TimeLayout {
                    time_coordinate: Local,
                    layout_key: K12Hourly,
                    start_valid_time: [
                        StartValidTime {
                            period_name: "Tonight",
                            value: "2025-01-14T20:00:00-05:00",
                        },
                        ...
                        StartValidTime {
                            period_name: "Tuesday",
                            value: "2025-01-21T06:00:00-05:00",
                        },
                    ],
                },
                TimeLayout {
                    time_coordinate: Local,
                    layout_key: K24Hourly1,
                    start_valid_time: [
                        StartValidTime {
                            period_name: "Tonight",
                            value: "2025-01-14T20:00:00-05:00",
                        },
                        ...
                        StartValidTime {
                            period_name: "Monday Night",
                            value: "2025-01-20T18:00:00-05:00",
                        },
                    ],
                },
                TimeLayout {
                    time_coordinate: Local,
                    layout_key: K24Hourly2,
                    start_valid_time: [
                        StartValidTime {
                            period_name: "Wednesday",
                            value: "2025-01-15T06:00:00-05:00",
                        },
                        ...
                        StartValidTime {
                            period_name: "Tuesday",
                            value: "2025-01-21T06:00:00-05:00",
                        },
                    ],
                },
            ),
            parameters: Parameters {
                temperature: (
                    Temperature {
                        temp_type: Minimum,
                        units: Fahrenheit,
                        time_layout: K24Hourly1,
                        value: [
                            26,
                            24,
                            27,
                            34,
                            34,
                            24,
                            17,
                        ],
                    },
                    Temperature {
                        temp_type: Maximum,
                        units: Fahrenheit,
                        time_layout: K24Hourly2,
                        value: [
                            33,
                            32,
                            39,
                            43,
                            39,
                            30,
                            24,
                        ],
                    },
                ),
                probability_of_precipitation: ProbabilityOfPrecipitation {
                    time_layout: K12Hourly,
                    value: [
                        PrecipitationValue {
                            value: None,
                        },
                        ...
                        PrecipitationValue {
                            value: Some(
                                30,
                            ),
                        },
                        PrecipitationValue {
                            value: None,
                        },
                        PrecipitationValue {
                            value: None,
                        },
                    ],
                },
                weather: Weather {
                    time_layout: K12Hourly,
                    weather_conditions: [
                        WeatherCondition {
                            weather_summary: "Mostly Clear",
                        },
                        ...
                        WeatherCondition {
                            weather_summary: "Mostly Sunny",
                        },
                    ],
                },
            },
        },
        CurrentObservations {
            location: Location {
                area_description: Some(
                    "New York City, Central Park, NY",
                ),
                description: None,
            },
            time_layout: TimeLayout {
                time_coordinate: Local,
                layout_key: K1Hour,
                start_valid_time: [
                    StartValidTime {
                        period_name: "current",
                        value: "2025-01-14T19:51:00-05:00",
                    },
                ],
            },
        },
    ),
}

Dependencies

~1.5–2.2MB
~42K SLoC