Skip to content

weather/noaa: Port the provider to the newer openAPI

Ismael Asensio requested to merge work/iasensio/noaa-new-api into master

Reason for the change

The NOAA service has developed a new openAPI service, and it's slowly but firmly deprecating the old one, with some of the old resources suffering outages or getting unavailable.

The new API has some differences with the old one, besides using JSON data instead of XML (geoJSON or LD-JSON).

The main difference is that it doesn't provide geolocation mapping between place names and stations/locations.

An important internal refactor has been made, but the way it interacts with the consumers is still based on the previous dataengine mechanics, so let's use for now a local copy of the (mostly static) XML list of available stations.

See: https://weather-gov.github.io/api/general-faqs

Test plan

Use the weather applet with a noaa location.

Requires kdeplasma-addons!596 (merged) for the right visuals. (Otherwise we get just a long row of day/night forecasts)

Other commits

  • This MR is based on top of !4431 (merged).
    • Although the line count seems scary, that is the one adding lots of lines (for the stations file)
    • The actual line count is slightly reddish: 4 files changed, 410 insertions(+), 547 deletions(-)
  • Always use the station list from the local file
  • dataengines/weather: Inform the applet whether the forecast starts at night
    • The applet was doing a small hack to guess this, which worked for the envcan provider, but now the noaa provider also uses 12h forecasts, we need to explicitly indicate this.
  • weather/noaa: Improve translation of the forecast summary
    • The forecast summary can now include several single conditions that follow a temporary sequence, separated by " then ". It is not fully orthodox, but since we cannot cover every possible iteration, translate the conditions separately and join them with a temporal separator.

Screenshots or screen recordings

The new API provides 12h forecasts divided into day and night, instead of the previous 24h daily forecasts.

Before After
Screenshot_20240526_125356 Screenshot_20240605_030257
Edited by Ismael Asensio

Merge request reports