Lurker News
Hi HN,

After 9 years of running my own OpenStreetMap tile server infra for MapHub (https://news.ycombinator.com/item?id=11389989), I've open-sourced it and launched OpenFreeMap.
You can either self-host or use our public instance. Everything is open-source, including the full production setup — there’s no 'open-core' model here. Check out the repo (https://github.com/hyperknot/openfreemap). The map data comes from OpenStreetMap.
I also provide weekly full planet downloads both in Btrfs and MBTiles formats.
I aim to cover the running costs of the public instance through donations.
Looking forwards for your feedback.

Comments (234) 54 threads

Earlier comments
tobilg1 reply#
I created a similar project, https://serverlessmaps.com which lets you host PMTiles on S3 and CloudFront, with a Lambda@Edge layer where you could also do auth...

With 1TB free traffic from the CDN, and pretty small costs for S3 and Lambda@Edge, it's probably even cheaper to self-host I guess. Even lower costs would be possible by entirely using CloudFlare services (CDN, R2)...

hmaxdml1 reply#
Replace lambda by DBOS and you'll cut down the cost by 15x, at least, and save you a lot of time developing (SAML sucks)
tobilg#
That's a complete other topic. DBOS also doesn't fit in this stack. And what has SAML to do with it?
thinkingemote2 replies#
Looks great love the free tiles and no limits or API keys.

Question, why use btrfs?

sandreas#
Afaik btrfs supports incremental send / sync very efficiently, so if you just want an update it saves bandwidth
hyperknot3 replies#
So a full planet OSM extract is about 300 million binary files, in total about 90 GB. The most popular ways to store it:

- MBTiles - an SQLite file, each file is a row in a table, you need a server to serve it.
- PMTiles - a single file, optimised for serverless usage.
- Extract them into a directory, which in practice should be on a partition image. This is the approach I choose.
I tested ext4 and Btrfs and I choose Btrfs. The reason is how ext4 and Btrfs handles inodes. Btrfs handles inodes so much better compared to ext4, it doesn't allocate them at start and also allows putting tiny files right with the metadata.
Because here the average tile size is only 405 bytes, most of the tiles can actually stored with the Btrfs metadata block. From the latest run:
Btrfs data is 51.57GiB
Btrfs metadata is 84.37GiB

thinkingemote1 reply#
Do you think btfs would work well for old school pre rendered raster tiles on disk?
c0nsumer2 replies#
I apologize if this is something stupid, or answered elsewhere, but is there a good way to trim Planet down to a smaller area?

I've been making some custom map stuff for mountain bike trails and I'd really like to move to self-hosted vector tiles for all layers, but too much of what I find says to start with Planet.osm when all I really need is a State (in the US) or even a few-miles-wide area.
(My goal is to basically snapshot OSM data, generate tiles, and use that until I decide to do another snapshot down the line, so the underlying data doesn't change. And limit it to a small area because that's all I need.)
Examples of maps I've done this way, and want to improve, are: https://trailmaps.app/ramba/ and https://trailmaps.app/dte/

hyperknot#
If you know the tile numbers, you can just copy them out of the Btrfs image.
puddingvlaai#
Look into Planetiler [1] (which OP uses for tile generation). It supports downloading regions that are listed on Geofabrik [2] and converting them to mbtiles or pmtiles. Geofabrik has separate extracts for all US states, for example. If you need to extract an even smaller area from that result, GDAL has support for mbtiles so you could use gdalwarp [3] to extract a new mbtiles file out of it using bounds.

Another option is to use the extract functionality in pmtiles [4] to extract your area of interest from their daily full-planet pmtiles builds. You can then statically host that file and use that in your client with one of their client libraries.
[1] https://github.com/onthegomap/planetiler
[2] https://download.geofabrik.de/
[3] https://gdal.org/en/latest/programs/gdalwarp.html
[4] https://docs.protomaps.com/pmtiles/cli#extract

ahlCVA1 reply#
This sounds like a perfect application for EROFS[1]. While it comes from an embedded systems background, it has seen some usage in container use cases and is moving towards a general "mountable tar" application. It would also avoid the tedium you have to go through in shrink_btrfs.py because you can just generate the image out of a tree.

I wanted to give repackaging the btrfs image a shot but the download was pretty slow - I assume your server is getting HN-hugged a bit so I didn't want to make it worse and stopped the download.
[1] https://erofs.docs.kernel.org/en/latest/index.html

hyperknot1 reply#
Thanks a lot, I didn't know about it! I also liked the fact that Btrfs is probably super well tested in the Linux kernel by now.

btrfs.openfreemap.com just a public Cloudflare bucket, no idea why it might be slow.

Continue this thread — 1 reply

hyperknot1 reply#
Thank you for sharing this, I'll make a issue about both.

The Vatican situation is trickier than you'd think, as it's on country level, while Rome is on city level, and naturally you'd want to give countries a priority over cities. Like on low zooms you only want to show countries, then as it gets closer you show cities. Well, except for Vatican.

folmar#
Nearby San Marino needs similar treatment.
jnettome#
Right on time! Thank you and congratulations for your release. I was looking for gmaps and mapbox alternatives this morning and right now I'm considering this.

Load more comments