An iOS App To Automatically Track Polluting Travel – Eco

Seb Jachec - May 20 '20 - - Dev Community

This is a summary of my Computer Science degree dissertation & project completed at the University of Portsmouth, in support of my entry into $ git remote graduation.

The Project

For the final project of my degree, I built Eco (working title): an iOS app that automatically tracks your polluting travel, and gives suggestions and goals to reduce it.

Travel summary screen of the iOS app
Settings screen of the iOS app

The overall goal was to improve people’s understanding of one high-impact area of their carbon footprint – travel (at least, before the COVID-19 pandemic 😅) – and to try and affect a change in behaviour.

Automatic tracking, rather than manual input, was a must in order to avoid guesswork and inaccurate estimates from users. Beyond this, the three main pillars of the project were identifying journeys travelled from GPS location data, classifying each journey into a specific mode of transport, and then presenting this in such a way as to encourage and change behaviour.

How I Built It

The app was designed in Figma, and built entirely with SwiftUI in 6 months.

Data flow through the app was achieved through a unidirectional architecture that could be considered Redux-like, or similar to Point-Free’s fantastic Composable Architecture (which I’ll definitely be using in future SwiftUI projects!)

The app required ‘Always’ location permission in order to collect visited location data in the background throughout the day via CoreLocation, of which 2 weeks’ worth were stored on-disk. Some heuristics were created to identify the mode of transport (walking, running, cycling, driving, bus or train) between pairs of visited locations based on time, speed and distance – these worked well for most modes of transport, but accuracy could still be improved in future, especially for bus and train travel.

Travel was shown from most recent to oldest, grouped by day, with a set of generated ‘Highlights’ above on the feed for average pollution, average travel time, a goal for the number of days carbon-free this week based on last week’s travel, and the average air quality at visited locations (from data supplied by OpenAQ, using location & timestamp combinations reduced via K-Means clustering to save network requests & processing).

Open-Sourced Components

Misc Thoughts

The project was as much an exercise in code quality, organisation, and project management as it was in pure coding effort (an area I’ve never felt lacking for). I feel as though I’m happy with the quality of the code, the unit tests that were written along the way (87% of non-View code), minimising SwiftLint warnings, and my management of user stories, bugs and tasks. Also managed to fit some Gitmoji into my commits!

An interesting find was the balancing act of larger more intensive feature work along with smaller and more enjoyable under-the-hood technical tweaks and UI work, in order to avoid occasional monotony and burnout.

.
Terabox Video Player