Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion API.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,45 @@ JSON shapes for all public types are frozen in [CONTRACT.md](CONTRACT.md).

## Weather Alerts

### `fetch_alerts_detailed`

```rust
pub async fn fetch_alerts_detailed(latitude: f64, longitude: f64) -> Result<AlertReport>

pub struct AlertReport {
pub alerts: Vec<AlertEntry>,
pub region_filtered: bool,
}

pub struct AlertEntry {
pub alert: Alert,
pub area_desc: String,
}
```

The same dispatch as `fetch_alerts` below, plus two things a consumer cannot
otherwise know:

- `area_desc` -- the provider's name for the area each entry covers. MeteoAlarm
`cap:areaDesc`, NWS `areaDesc` (a `;`-separated county list), the containing
ECCC polygon's `areaDesc`. BOM sends none, so it is `""`.
- `region_filtered` -- `false` only when a MeteoAlarm national feed was returned
unfiltered: no EMMA_ID resolved for the location, or the feed carries no
EMMA_ID geocodes to filter on (France tags entries with NUTS3), so the entries
are national, not local. NWS, ECCC and BOM filter by point, polygon and
geohash, and an empty result is trivially filtered, so all of those are `true`.

When an EMMA_ID did resolve, MeteoAlarm entries carrying no geocode are dropped
rather than shown, since they cannot be placed in any region.

### `fetch_alerts`

```rust
pub async fn fetch_alerts(latitude: f64, longitude: f64) -> Result<Vec<Alert>>
```

Dispatches to the right provider based on location:
Thin wrapper over `fetch_alerts_detailed` that drops `area_desc` and the
filtering flag. Dispatches to the right provider based on location:

| Region | Provider | Notes |
|-----------|------------|-------------------------------------------------|
Expand Down
44 changes: 44 additions & 0 deletions CONTRACT.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,50 @@ EU standard:
}
```

### AlertEntry (array element of the detailed alerts payload)
```json
{
"alert": {
"id": "NWS-IDP-PROD-123",
"event": "Severe Thunderstorm Warning",
"severity": "Severe",
"headline": "Severe thunderstorm until 10 PM EDT",
"description": "Wind gusts to 60 mph expected.",
"expires": "2026-06-11T22:00:00Z"
},
"area_desc": "Warszawa"
}
```

`area_desc` is the provider's name for the area the entry covers; `""` where
the provider sends none (BOM), per the missing-strings rule.

### AlertReport (the detailed alerts payload)
```json
{
"alerts": [
{
"alert": {
"id": "NWS-IDP-PROD-123",
"event": "Severe Thunderstorm Warning",
"severity": "Severe",
"headline": "Severe thunderstorm until 10 PM EDT",
"description": "Wind gusts to 60 mph expected.",
"expires": "2026-06-11T22:00:00Z"
},
"area_desc": "Warszawa"
}
],
"region_filtered": true
}
```

`region_filtered` is `false` only when a MeteoAlarm national feed was returned
unfiltered: no EMMA_ID resolved for the location, or the feed carries no
EMMA_ID geocodes to filter on (France tags entries with NUTS3), so the entries
are national, not local. NWS, ECCC and BOM filter by point, polygon and
geohash, and an empty result is trivially filtered, so all of those are `true`.

### PollenData
Inside CAMS European coverage:
```json
Expand Down
Loading