Aeris Weather is a provider of weather content like local forecasts and time dependent radar overlays. In this tutorial we add an animated layer of up to date weather imagery from Aeris to WhirlyGlobe-Maply.
NoteVersion 2.4.1 (or better) Required
You will need WhirlyGlobe-Maply version 2.4.1 or better to use the new MaplyAeris classes.
You will need to have already run through the remote image layer tutorial. Let’s get started by opening your HelloEarth project.
If you haven’t got one here is a suitable ViewController file to start with (for Objective-C or Swift). This version is from the previous tutorial for a remote image layer.
Setup the Aeris layer
Let’s get started by adding five member variables to the ViewController class. Add them to the implementation block in Objective C, or to the class properties in Swift. We’ll explain what these do later.
Add a method call as the final line in viewDidLoad.
And begin implementing it as follows:
Aeris provides quite a few time slices in their data layers, more than we can easily display. The frameCount member controls how many we will show. The animationPeriod is how long we’ll take to run through the whole animation and the importanceScale controls how much data we’ll load relative to the underlying map.
WhirlyGlobe-Maply Aeris classes
There are three WhirlyGlobe-Maply Aeris-related classes needed to make animated Aeris weather happen. MaplyAerisTiles provides a list of available Aeris layers. The MaplyAerisLayerInfo class contains the relevant information for a particular layer. And MaplyAerisTileSet provides the tile sources to add to a WhirlyGlobe-Maply layer.
Go back to the beginning of the implementation block in Objective C (or the beginning of the class in Swift), and add four more member variables here. We’ll need these to keep track of the Aeris layers.
Now add this to the setupAerisOverlayLayer method:
That gets the MaplyAerisLayerInfo object for the radar layer, and constructs a MaplyAerisTileSet object for it. That tells us where to get the actual data from, but we’ll need to do one more thing to find out how many time steps are available and where they are.
This refreshAerisOverlayLayer method will query the Aeris service to figure out the end points for the timesteps in the data layer, radar in this case. When it gets that information back it will put together a MaplyMultiplexTileSource which is just a tile source that deals with animated data sets. From there it sets up a layer to fetch and draw the data and off it goes.
Staying current with a periodic refresh
You’ll notice that in the refreshAerisOverlayLayer method we first remove the aerisLayer from the view if it already exists. This anticipates our final change, which is to periodically refresh the imagery to get the latest data.
At the end of the setupAerisOverlayLayer method, schedule a timer to refresh the imagery.
More Data Layers
The other layers available from the WhirlyGlobe-Maply Aeris classes are Infrared Satellite, Global Satellite, and Hi-Res Visible Satellite. For a Global Satellite example, substitute the following assignments in setupAerisOverlayLayer: