OpenStreetMap logo OpenStreetMap

While editing the next edition of WeeklyOSM, I stumbled upon a fascinating case study that caught my full attention.

A certain team, responding to a certain request, set out to display a mobile device’s geolocation on a map—completely offline, without any network access.


Their initial approach? Crawling OpenStreetMap tile images one by one and storing them locally.

It didn’t take long before they hit a wall: the data size exploded, and keeping the tiles up-to-date turned into a maintenance nightmare. Sensibly, they scrapped that plan.


Next, they evaluated two open-source tools: tileserver-gl (JavaScript) and mbtileserver (Go).

In the end, they opted for mbtileserver, citing Go’s “security” over JavaScript. I still don’t fully grasp that reasoning (somehow, it involves a decision between verifying their own source code and verifying the entire JavaScript interpreter), and I even asked them in the comments section. But for now, let’s accept that as a given and move on.

After choosing mbtileserver, they needed MBTiles files to serve. Eventually, they discovered tilemaker, a tool that converts .osm.pbf files into .mbtiles.

They successfully tested it on a small area. Encouraged, they moved on to larger datasets. Then came the pain.

“…half an hour passes, and we experience a computer freeze as all the RAM runs out.”

Their machine couldn’t handle the memory load. So they requested a beefy VM—256 GB of RAM—and tried again. Still no luck.

That’s when they discovered tilemaker’s --store option, which dumps intermediate stages to disk instead of holding everything in RAM. That tweak made it work.


Creating an offline, custom OSM map has been my white whale for years. So I decided to replicate their setup on my own desktop.

I began with installing mbtileserver. That’s when I hit this cryptic error:

cc1.exe: sorry, unimplemented: 64-bit mode not compiled in

According to StackOverflow, the issue stemmed from a broken GCC toolchain. The fix? Replace it with TDM-GCC. That worked.

Next, I needed an .mbtiles file to test.

The BBBike Extract Service came to the rescue—letting me select a custom region. I grabbed one for my hometown and placed it in the required tilesets/ directory.

Running mbtileserver… and it crashed.

Apparently, this kind of crash typically happens when Go calls external C code and something goes wrong—like a segmentation fault. Likely, this server-side tool hasn’t been stress-tested on Windows desktops like mine.


As a last resort, I turned to the JavaScript-based tileserver-gl.

The trick is to download the sample ZIP file (which contains a config file, style sheet, and a sample Zurich MBTiles file), then replace the Zurich MBTiles file with my own hometown MBTiles file that I just extracted from the BBBike extract service.

It started—but with missing text labels.

Even worse, the server would occasionally exit with no log at all.

After some digging, I found others had experienced similar issues—again, only on Windows.


Despite the original team’s success, I hit too many roadblocks—most of them likely tied to running server software in a desktop Windows environment. Their success probably hinged on using a properly configured server environment.

Someday, with access to a dedicated Linux VM, I’ll try again. Maybe.

Email icon Bluesky Icon Facebook Icon LinkedIn Icon Mastodon Icon Telegram Icon X Icon

Discussion

Comment from SomeoneElse on 24 May 2025 at 09:28

Was there any reason why you chose Windows Server here (other than “it was what you had lying around”)? Windows versions of OSM tools always suffer because basically “no-one developing them uses Windows”.

One thing that you might try include WSL - I’ve not tested that on your particular environment but I’d be surprised if it didn’t work, based on the things that have worked in the past.

Serving vector tiles is basically just “serving a small portion of a big file”. In the past I’ve used Apache on Windows without problems, so one avenue to explore might be that with mod_mbtiles. I haven’t tried that on Windows, but it works fine on Debian Linux.

Comment from rphyrin on 24 May 2025 at 10:07

Yes, for my daily online activities (writing, coding, browsing), I only have this one Windows laptop. So when I do web development, I usually handle both development and testing in my Windows environment before deploying to a Linux-based server (or maybe I should really consider setting up a Linux dual boot for a better development environment in the future).

I’ve been curious for a long time about how to serve my own tile server using the openstreetmap-carto stylesheet. In the past, I’ve successfully set up several vector tile servers using other stylesheets, but I still don’t know how to use the openstreetmap-carto itself (the other currently available vector stylesheets still don’t satisfy me for some reason, and I really like osm-carto 😂).

What I really want to build is something similar to the slippy map on the osm.kr homepage : a raster tile server (using openstreetmap-carto style) showing only a limited region, with some local modifications to the osm-carto rendering (i heard somewhere that tiles.osm.kr excludes military bases to comply with local regulations, something like that).

I read the openstreetmap-carto installation guide, but it seems to be intended for someone who wants to process data for the entire planet.

I wonder if there’s a simpler way to do this instead. And finally, this article I read recently gave me some hope : gather the MBTiles and serve them via TileServer-GL (or mbtileserver). That’s the kind of simplicity I’ve been looking for for a long time 😂.

Comment from SomeoneElse on 24 May 2025 at 10:21

how to serve my own tile server using the openstreetmap-carto stylesheet

That’s using raster tiles, do do that on you’re laptop I’d suggest installing WSL with either Debian or Ubuntu running there and then follow these instructions. If that isn’t an option but Docker is, try these.

If you want vector tiles then I’d (as mentioned earlier) suggest Tilemaker under WSL and then Apache + mod_mbtiles. This was intended as a “soup to nuts” guide to doing that on Linux, but all but the “obtaining a server” part of that would likely also apply to WSL. You’ll then have to fiddle around with the Windows firewall (but then as a Windows developer you’re presumably used to doing that).

Comment from rphyrin on 24 May 2025 at 13:37

Thank you for the pointer

Log in to leave a comment

OSZAR »