Mobile Weather

Los Angeles is suing The Weather Channel for selling the data of mobile users. This behaviour shouldn’t be surprising. Most mobile software, from the operating system on up, seems to exist primarily to provide some base modicum of functionality in exchange for the privilege of fucking you in new and exciting ways.

There are exceptions to the rule. I starting using Arcus for mobile weather in 2014, and it seems pretty respectable. But it exists solely to display data from the Dark Sky API, which is something that a web browser is also capable of doing, thus raising the question: why install anything?

About a month ago I simply bookmarked Dark Sky‘s website and had Firefox add a shortcut to that bookmark on my home screen. Dark Sky’s website is responsive, so it works fine in any viewport size. I bookmarked the URL for my home location, allowing me to see weather at home in a single tap. Elsewhere, it required two taps: one tap to open the bookmark, and one tap on their geolocation icon to get the correct forecast for my current location.

I find Dark Sky’s data to be great for reporting on the hyper-local now. For reports that are wider in scope – either in terms of time or space – nothing beats the National Weather Service. They provide a mobile specific site that is perfectly usable on small viewports. Annoyingly, they don’t make use of the web geolocation API, instead requiring users to manually enter a location. When travelling I may not know what zip code I’m in or have a nearby address. To work around this I created a shim with a few lines of Javascript that geolocates the user, uses the resulting coordinates to build the proper NWS URL, and redirects the user to that URL. I also added support for building a Dark Sky URL so that I could avoid that second tap when not at home.

<!doctype html>
        <meta charset="utf-8">
        <link rel="icon" type="image/ico" href="https://www.weather.gov/favicon.ico">
            function geoWeather() {
                navigator.geolocation.getCurrentPosition(function(pos) {
                    var currentURL = new URL(window.location.href);
                    if (currentURL.searchParams.has('darksky')) {
                        var forecastURL = 'https://darksky.net/forecast/' + pos.coords.latitude + ',' + pos.coords.longitude;
                    } else if (window.screen.width < 800) {
                        var forecastURL = 'https://mobile.weather.gov/index.php?lat=' + pos.coords.latitude + '&lon=' + pos.coords.longitude;
                    } else {
                        var forecastURL = 'https://forecast.weather.gov/MapClick.php?lat=' + pos.coords.latitude + '&lon=' + pos.coords.longitude;
                    var el = document.getElementById('result');
                    el.innerHTML = '<p>Forecast URL is <a href="' + forecastURL + '"> ' + forecastURL + '</a></p>';
            window.onload = geoWeather;
        <div id="result"></div>

Now I have two URLs bookmarked on my home screen that accomplish everything I need: one for NWS and one for Dark Sky.

Shortly after creating this shim I discovered that the NWS has a beta website that is intended to replace both the current mobile and standard sites with a consistent interface. This site does make use of the geolocation API, requiring the user to click an icon to get the current location. It is unclear why they have yet to deploy this to their main domain. It’s been available since August 2017 and the data on the beta site seems to be the same as the data on the standard site and the data on the mobile site. For now I’m sticking with the officially supported domains in my shim.

A locally installed weather program is useful if your requirements include lock screen widgets or notifications of hazardous conditions. Mine do not. These two bookmarks provide all the weather information I need on my telephone, and do so in a way that does not expand my attack surface in the way installing software does. They are indicative of the usefulness of this World Wide Web thing – an emerging technology that I intend to watch with great interest. I think it’ll go places.

This post was published on . It was tagged with android.