Update: Source code now available on CodePlex.
Update: See http://veloviewer.com for latest info.
Update: Info on WP7 GPS recording for Strava: see esfuerza a Strava recorder and uploader for Windows Phone.
A bit of a side project to my normal work here at Tribal Labs but building a Strava app for the Windows Phone has been a fantastic learning experience touching on many of the key features of mobile development. I’m fairly new to Strava having recently been introduced to it by one of the guys at my cycling club and now I’m pretty much addicted! It ticks all my excite boxes of cycling, mobile technologies, data visualisation and a healthy slice of competition. For those of you who haven’t heard of it “Strava lets athletes all over the world experience social fitness—sharing, comparing and competing with each other’s personal fitness data via mobile and online apps”.
It does many things very well but there are definitely some gaps in functionality and device support so time to step up and plug some of those holes with a Windows Phone app.
Details and video on the flip…
What is Strava?
The best way to see what Strava gives you above and beyond the out-the-box GPS stats package is by looking at a ride details page like this one of mine. If you look at the elevation profile you’ll notice lots of green sections highlighted which are user-created “segments”, typically marking out climbs. Discussing various stats on these segments has now become the prime topic of conversation on our ride’s café stops and is the standout feature of Strava. If you ride a hill that doesn’t currently have a segment then any user can create it and after a couple of hours Strava will have populated a leader board for all the rides in its database that included that particular climb. If you are logged in then you get to see far more detailed information and can drill down into the segment leader boards and other people’s rides along with many other features.
Current Strava shortcomings
It’s not all roses though. When you upload a ride then that ride’s segment stats are seemingly set in stone even if subsequent users upload rides that alter your segment placing. There is no kind of notification should you be knocked off from the hard fought for segment podium position or top spot (KOM – King Of the Mountain). You can only view a list of your KOM’s (segments where you are in 1st position), there’s no overview of all your segment placings which is a bit limiting to those without a number of 1st places. Also, currently Strava doesn’t provide a Windows Phone app but I can let them off with that, for now, particularly when it’s so easy to build your own. So my main drivers for this Windows Phone app were to:
- Provide alerts when position on segments change
- Provide a view of all segment placings
- Provide up-to-date segment stats on rides
- Find newly created segments
- Get Strava into a Windows Phone app
Note: seeing as I use a GPS device for my rides I am not bothered about trying to record rides in this app. Here’s a video of my progress so far:
How it works
First off Strava provide documentation for a number of their older API’s although a quick Fiddler while using their website shows that there are a number of V3 API’s being used that we can also hook in to. It is surprising how many of these API’s are available without having to use any authentication. I was returning all ride and segment info and leader boards back fine and in fact, currently I only need to authenticate to bring back my ride’s map data. I cache all the ride, segment, leader board and map data in Isolated Storage on the device which allows me to view my data when out of mobile signal (which is often the case at our Peak District café stops). It also allows for a fairly fast start up time as it pulls the data out of a file and lazy loads the maps and leader board data as required. An object model is populated from the cache (and/or web service calls) and using a simple MVVMmodel I easily databind up to a XAML front end which allows for a very flexible UI that probably stills needs a bit more flexing.
Storing this cache also allows us to achieve our main objective and raise alerts when segment placings change. It isn’t the quickest process to run as it needs to get the latest leader board for each segment and then check that off against each segment’s leader board in the object model. Currently it takes about a minute to perform this check for my 180 or so segments but half that time is taken loading and saving data from/to isolated storage which I’ll have to look into. I’m using the Bing Maps control but using the excellent Open Cycle Map layer in order to show contour lines. Very easy to do once you’ve found the right blog post telling you what to do.
Very much work in progress but this definitely plugs a few holes in my own Strava experience. If I get much interest in this then I’ll put it up on CodePlex for others to use and who knows, if some proper coders can sort out my dodgy C# then it could make its way to the Windows Phone Marketplace!
Also possibilities with other technologies which support caching (e.g. browser apps, or Windows 8 Metro apps which could cache on the cloud to give alerts on any device, even when moving between devices…)