The tropics are busy and so are the teams at AerisWeather! Last month’s AerisWeather Android SDK update added new tropical cyclone imagery from the Aeris Mapping Platform (AMP). Today we’re excited to announce that we’re putting even more tropical cyclone information into your hands (and apps). Version 2.5.0 expands the Aeris Android SDK tropical API support for the Aeris API Tropical Cyclone endpoint to include point and polygon data!
The Aeris API provides rich data support for active global tropical systems. You can get all the details in the full rundown of the cool new Tropical Cyclones endpoint blog. With v2.5.0 of the Aeris Android SDK, we’ve baked in the usual support to help get that tropical data into your apps.
Here’s an example using the Android SDK tropical API integration to query the Aeris API tropical cyclones endpoint:
AerisRequest request = new AerisRequest( Constants.CLIENT_ID, Constants.CLIENT_SECRET, Constants.APP_ID, new Endpoint(EndpointType.TROPICAL_CYCLONES), ""); JSONObject object = NetworkUtils.getJSONZipped(request, true); TropicalCyclonesResponse response = new TropicalCyclonesResponse().fromTropicalJSON(object); if (response.getError() != null) //we might not have any data { assertTrue(response.getError().code.compareTo("warn_no_data") == 0); } else //if we have data, check it { AerisDataJSON data = response.getFirstResponse(); Profile profile = data.profile; String name = profile.name; }
Assuming there is at least one active tropical storm out there (and if it’s July, Aug or Sept, that’s a pretty good bet), we’ve got storm data!
Okay, so we can see how easy it is to get information about active tropical storms using the Aeris API Tropical Cyclone endpoint. But everybody knows that a picture is worth a thousand API queries, so let’s take a look at bringing that data to life on a map.
The updated Android SDK tropical API components give us a streamlined way to access the different sets of map data provided by the Aeris API Tropical Cyclones endpoint.
For point data, we have a few nifty bits of data to plot. Track data provide points along the storm’s historical path. Forecast point data gives us coordinates indicating the storm’s future path. At each point, we combine the location data (lat, lon) with the relevant info about the storm like wind speed and category. Using this data with a click event allows for an interactive user experience, like tapping a point along the storm track to reveal specific storm details.
Polygon data for tropical storms provide a geopoly coordinate set specifying the error cone. This region indicates the probable area where the storm is forecast to go. Plotted on a map with the track and forecast point data, we get a really cool and informative view of the storm.
Okay, that sounds great – so how do I take advantage of the Android SDK tropical API integration? Here’s an example showing how to request point data from the Aeris API. Once you’ve initialized your map, it’s a simple one-liner:
m_aerisMapView.addLayer(AerisPointData.TROPICAL_CYCLONES);
Adding the error cone polygons for tropical storms is super easy too:
m_aerisMapView.addLayer(AerisPolygonData.TROPICAL_CYCLONE_ERROR_CONES);
So, now we’ve seen some simple examples adding the new tropical layers to your map. The examples above give you point and polygon data with the default parameters for the active storms. However, maybe you want to tweak the results a bit. Or you might want to add a custom UI, allowing the user to choose a specific storm, etc. With this in mind, we’ll need to go a little further and dig into some options.
To drill down and refine the results, check out this example:
Endpoint endpoint = new Endpoint(EndpointType.TROPICAL_CYCLONES); Action action = Action.NONE; tropicalCycloneParameterBuilder = new ParameterBuilder() .withLimit(2) .withSort("dt:-1"); AerisRequest request = new AerisRequest(endpoint, action, m_tropicalCycloneParameterBuilder.build()); if (pointDataTask != null) { pointDataTask.cancel(true); } pointDataTask = new AerisCommunicationTask(mapView.getContext(), data.getHandler(this), request); pointDataTask.withProgress(this); pointDataTask.execute();
The code above is straight from the map library, just behind the curtain providing the results in the examples above. Notice that we limited the number of storms in our result to 2. Next, we see that we’ve asked the API to sort the results with the most recent listed first. Using the ParameterBuilder class in the SDK, we can tweak the results to exactly what we need.
For specifics regarding the allowed parameters, filters, actions, etc. for the Tropical Cyclones endpoint, take a look at the endpoint docs.
To get more information on the ParameterBuilder class, check out the Aeris Android SDK docs.
Looking for more example code using the Tropical Cyclones point and polygon data? Download the Aeris Demo project from GitHub and load it up in Android Studio. Expand the core and map libraries under the Project view. Now you can browse through the classes and check out the request and response handling code we’re using.
We hope you enjoy the new version and can’t wait to see what you make next!
Not currently an AerisWeather user? Check out our free developer trial and start using the Android SDK today!
Happy Coding!
The Aeris Android Team
No comments yet.
Be the first to respond to this article.