Skip to content

dataengines/weather/bbcukmet: Port to JSON API

Ismael Asensio requested to merge work/iasensio/bbcukmet-json-api into master

Reason for the change

In the BBC UK Met provider we were using and old RSS/XML based API, both for forecasts and observations.

Port to the newer JSON API which provides more information, it is more reliable and easier to parse

This provider has a worldwide scope and for most places in the world it is the only one serving information (from our current providers, besides the limited wetter.com)

The added benefits for the users are:

  • 7 days forecast (up from 3). It offers up to 14 but let's limit that for now so as not to break the applet
  • Probability of precipitation (%)
  • Fixes the station names which were usually missing

Test plan

Search and use some location using the bbcukmet provider

Screenshots or screen recordings

Before After
bbcukmet-tokyo-before bbcukmet-tokyo-after

Previous refactor commits

There was a lot of refactoring involved previous and in preparation to the API change

Those changes are split into smaller chunks for easier consumption but with the purpose of get squashed altogether later

  • Refactor and simplify API requests

    Unify the methods and member variables to keep track of the jobs when making API requests. Also simplify how the results of two search API request and processed and merged. This fixes getting extra duplicates on some locations

    For code convenience, this removes backwards compatibility with a provider change in 2018. Worst case (unlikely) scenario, the user will have to configure its location again

  • Refactor some data structures

    • Do not use pointers to store forecasts in a QList

      QList will automatically manage and clean them more appropriately

    • Initialize structs directly

    • Extract observation data onto its own struct, so it's easier to reset and manipulate its values

    • Simplify the "source" keys used in hashmaps by removing the redundant prefix bbcukmet

  • Streamline and reorganize methods

    • Improve separation of scope within the methods that read and parse the data and those that carry the code flow
    • Rename methods to showcase its current purpose
    • Extract the method getSolarData()
Edited by Ismael Asensio

Merge request reports