Building an OpenStreetMap app in Rust, Part I

Tor Hovland
Bekk
Published in
4 min readFeb 8, 2021

--

Introduction

This year at work, I’ve joined a learning community of people who will build their own mobile app. I plan to get three things out of that:

  • To build an app that will help me (and hopefully others) in editing OpenStreetMap data.
  • To get some real experience in Rust programming.
  • To actually finish a personal project, or at least to get it to a stage where it functions well.
Photo by Annie Spratt on Unsplash

What’s the app about?

Are you familiar with OpenStreetMap? It’s like Wikipedia, but for geography. It contains information on roads, paths, buildings, points of interest, and a whole lot of other geographical features, all over the world. Anybody can contribute to this data, and anybody can use it.

If you’re using any kind of outdoors route planning or workout app, chances are that it uses OSM. Uber uses OSM. Facebook does too. And if you’ve ever played Pokémon Go, you will have been looking at an OSM generated map.

More interestingly, features in OSM can be tagged with custom data for special applications. For instance, mountain bike riders are tagging trails that are well suited for riding, as well as how difficult they are. When somebody is rendering a map, they can decide which data to use and which to ignore. My favorite custom map is MTBmap.no. It provides a comprehensive, yet easy to read, map of mountain bike trails in Norway.

When I’m out riding in less visited areas, I like to contribute to OSM. I may be adding trails that are completely missing, or I may be updating information about a trail or road. I may even add shelters, fire pits, picnic tables, and so on. I’m not editing OSM there and then, but I’m making a mental note to do so when I return home. The issue is remembering all the things I wanted to edit, and where exactly they are. I can always add waypoints to my GPS or mapping app, but often I won’t bother, because I don’t even know if the information I want to add might already be registered in OSM.

That’s where my app idea comes in. It will allow me to quickly check the registered tags on the line that I’m on, and to add a note on my current location that will help me when editing later.

Why not just upload changes to OSM there and then? Well, in some cases, that might make sense. But in other cases, maybe I’d like to add a note that says “all roads above this point are gravel.” That’s not an edit that would be simple to automate from the app.

Anyway, this is just the Minimum Viable Product. When this milestone is reached, there’s probably many feature ideas floating around. If you have any thoughts right now, don’t hesitate to comment!

Why Rust?

Rust is a powerful programming language that offers novel features, most notably the borrow checker, which guarantees safe memory management as well as safe multi-threaded code. Rust is designed to be a systems programming language, and is certainly overkill for a simple app like this one. I’m not choosing Rust in order to develop the app as rapidly as possible, but to get a chance to use Rust in a real project and to gain experience with it.

I’m not planning to develop a native mobile app, but rather a web app that is well-suited to running on a mobile phone. A Progressive Web App, if you will. Rust can compile to WebAssembly and run directly in a modern browser, as an alternative to Javascript. Again, I’m not doing this because it’s necessary in any way. Performance-wise, Javascript is actually pretty good. But I want to explore the tooling, get some experience with it, and get a feeling about how much of a bleeding edge it is. I expect that there are aspects I will enjoy a lot (e.g. Rust’s type system and excellent compiler error messages), and other aspects that I will enjoy less (the lack of debugging tools). But I’m sure I will learn a lot.

Stay tuned for part II, where we get started with an initial web app in Rust. Oh, and if you have a good idea for the name of the app, let me know!

--

--