tilemaker README

项目的 README,来自 github.com/systemed/tilemaker。合并为一个 markdown 文件:README.md。

tilemaker

tilemaker creates vector tiles (in Mapbox Vector Tile format) from an .osm.pbf planet extract, as typically downloaded from providers like Geofabrik. It aims to be 'stack-free': you need no database and there is only one executable to install.

Vector tiles are used by many in-browser/app renderers, and can also power server-side raster rendering. They enable on-the-fly style changes and greater interactivity, while imposing less of a storage burden. tilemaker can output them to individual files, or to .mbtiles or .pmtiles tile containers.

See an example of a vector tile map produced by tilemaker at tilemaker.org.

Continuous Integration

Getting Started

We provide a ready-to-use docker image that gets you started without having to compile tilemaker from source:

  1. Go to Geofabrik and download the monaco-latest.osm.pbf snapshot of OpenStreetMap
  2. Run tilemaker on the OpenStreetMap snapshot to generate Protomaps vector tiles (see below)
    docker run -it --rm -v $(pwd):/data ghcr.io/systemed/tilemaker:master /data/monaco-latest.osm.pbf --output /data/monaco-latest.pmtiles
  1. Check out what's in the vector tiles e.g. by using the debug viewer here

To run tilemaker with its default configuration

docker run -it --rm --pull always -v $(pwd):/data \
  ghcr.io/systemed/tilemaker:master \
  /data/monaco-latest.osm.pbf \
  --output /data/monaco-latest.pmtiles

To run tilemaker with a custom configuration using coastlines and landcover you have two options

  1. In the config.json use absolute paths such as /data/coastline/water_polygons.shp or
  2. Set the docker workdir -w /data with relative paths coastline/water_polygons.shp (see below)
docker run -it --rm --pull always -v $(pwd):/data -w /data \
  ghcr.io/systemed/tilemaker:master \
  /data/monaco-latest.osm.pbf \
  --output /data/monaco-latest.pmtiles \
  --config /data/config-coastline.json \
  --process /data/process-coastline.lua

Installing

tilemaker is written in C++14. The Makefile builds it as C++14 and the cmake build as C++17; writing MapLibre Tiles (MLT) needs a C++20 compiler. The chief dependencies are:

Other third-party code is bundled in the include/ directory.

You can then simply install with:

make
sudo make install

For detailed installation instructions for your operating system, see INSTALL.md.

Out-of-the-box setup

tilemaker comes with configuration files compatible with the popular OpenMapTiles schema, and a demonstration map server. You'll run tilemaker to make vector tiles from your .osm.pbf source data. To create the tiles, run this from the tilemaker directory:

tilemaker /path/to/your/input.osm.pbf /path/to/your/output.mbtiles

tilemaker keeps everything in RAM by default. To process large areas without running out of memory, tell it to use temporary storage on SSD:

tilemaker /path/to/your/input.osm.pbf /path/to/your/output.mbtiles --store /path/to/your/ssd

Then, to serve your tiles using the demonstration server:

cd server
tilemaker-server /path/to/your/output.mbtiles

You can now navigate to http://localhost:8080/ and see your map!

Coastline and Landcover

To include sea tiles and small-scale landcover, run

./get-coastline.sh
./get-landcover.sh

This will download coastline and landcover data; you will need around 2GB disk space.

Have a look at the coastline and landcover example in the resources/ directory.

Your own configuration

Vector tiles contain (generally thematic) 'layers'. For example, your tiles might contain river, cycleway and railway layers. It's up to you what OSM data goes into each layer. You configure this in tilemaker with two files:

You can read more about these in CONFIGURATION.md.

The JSON configuration and Lua processing files are specified with --config and --process respectively. Defaults are config.json and process.lua in the current directory. If there is no config.json and process.lua in the current directory, and you do not specify --config and --process, an error will result.

Read about tilemaker's runtime options in RUNNING.md.

You might also find these resources helpful:

Why tilemaker?

You might use tilemaker if:

But don't use tilemaker if:

Contributing

Bug reports, suggestions and (especially!) pull requests are very welcome on the Github issue tracker. Please check the tracker to see if your issue is already known, and be nice. For questions, please use IRC (irc.oftc.net or https://irc.osm.org, channel #osm-dev) and https://community.osm.org.

Formatting: braces and indents as shown, hard tabs (4sp). (Yes, I know.) Please be conservative about adding dependencies or increasing the memory requirement.

The Makefile does not currently pick up changes to header files (.h). If you change these, you may need to run make clean before building with make and sudo make install.

tilemaker is maintained by Richard Fairhurst and supported by many contributors. We particularly celebrate the invaluable contributions of Wouter van Kleunen, who passed away in 2022.

Copyright tilemaker contributors, 2015-2025.

The tilemaker code is licensed as FTWPL; you may do anything you like with this code and there is no warranty.

Licenses of third-party libraries:

tilemaker (systemed/tilemaker)

正在搜索数据库…

这是什么?tilemaker 是一个命令行工具,无需数据库,就能把 OpenStreetMap 的 .osm.pbf 数据提取文件转换为 Mapbox Vector Tiles。
这是库还是独立工具?它是独立工具:运行一个可执行文件并输入数据文件,就能得到瓦片输出,无需搭建数据库或服务器环境。
我要怎么把它跑起来?最快的方式是使用现成的 Docker 镜像。否则运行 make 和 sudo make install,各操作系统的具体步骤请参阅 INSTALL.md。然后对你的 .osm.pbf 文件运行 tilemaker,即可生成 .mbtiles 文件。
我需要先装什么?需要支持 C++14 的编译器、Boost(1.66 或更高版本)、Lua 5.1 或 LuaJIT、sqlite3、shapelib 和 rapidjson。Docker 镜像无需这些依赖,而输出 MapLibre Tiles 需要 C++20 编译器。
处理大范围区域时有什么要注意的吗?tilemaker 默认把所有数据保存在内存中,因此处理大范围区域时,请使用 --store 参数将数据存放在 SSD 上,以免内存耗尽。
我应该用它来代替托管瓦片吗?如果你想自己构建瓦片,又不想与第三方签订合同,就可以用它。如果你希望由别人托管瓦片,或需要持续获取最新的 OSM 数据更新,就不必用它。
我能做离线使用的瓦片吗?可以,README 中把现成的离线瓦片列为选择 tilemaker 的理由之一。
我可以免费使用吗?可以。tilemaker 的代码采用 FTWPL 许可证,你可以对其做任何用途,且不提供任何担保。内置的第三方库则有各自的宽松许可证。
输出文件是什么样的,我能在哪里用它们?输出可以是单个文件,也可以是 .mbtiles 或 .pmtiles 容器。瓦片可以在浏览器和应用中渲染,也可以在服务器端渲染为栅格图像。
为什么要自己构建,而不是用依赖数据库的一套方案?它的目标是“免栈”:无需数据库,只需安装一个可执行文件。
我怎样控制哪些地图要素会出现在瓦片里?你需要编写一个 JSON 配置文件,列出图层和缩放级别,再配合一个 Lua 脚本,根据 OSM 对象的标签把它们分配到相应图层。
我能预览生成的瓦片吗?可以。仓库中的 server/ 目录内含一个演示用地图服务器(tilemaker-server),可以用来提供你生成的输出文件。
作者
systemed
大小
42.9 MB
星标
1.9K
时长
11年
提交 · 90 天