I wanted to create a mobile-friendly weather service for Finland which has the simplest possible user interface (in Finnish).
Sataako.fi fetches weather radar images from Finnish Meteorological Institute's Open Data APIs and shows them as Google Maps layers after some post-processing. The movement of rain clouds is shown as a short animation covering the last hour.
The node.js application runs in Heroku with a single Hobby dyno.
It's responsible for
- maintaing an up-to-date list of radar frames available from FMI
- delivering those frames as post-processed GIF images
To be able to serve a decent amount of concurrent users without exceeding the FMI API request rate, the following steps are done:
- requests to FMI API go through a task queue which limits concurrency
- radar frame list is cached internally for one minute before a re-fetch from FMI
- radar frame images are cached 1) locally for about one hour and 2) by an AWS Cloudfront distribution sitting in front of the Heroku app (at cdn.sataako.fi) for 24 hours
FMI provides a WMS compliant HTTP API for fetching a composite radar image covering all of Finland. To be able to use those images on top of Google Maps the following steps are taken:
- request a PNG image in EPSG:3857 projection to match Google Maps's projection
- decode PNG into raw 32bit pixel data
- change a solid gray background (0xf7f7f7) to fully transparent
- use a mask-image to change a solid orange border area (related to changing the projection obviously) to fully transparent
- encode image as GIF maintaining transparency
With a (modest) amount of concurrent users the service runs almost for free:
- 7€ - Heroku
- 1-3€ - AWS CloudFront (CDN) & Route53 (DNS)
- 1€ - FI domain