Travis build Status Appveyor build status

t-rex is a vector tile server specialized on publishing MVT tiles from a PostGIS database.

An extensible design allows future support for more data sources (e.g. OGR), custom tile grids with other reference systems than Spherical Mercator and additional output formats like JSON.


  • Workshop “Vector Tiles”, GEOSummit Bern 7.6.16: slides


t_rex serve --dbconn postgresql://user:[email protected]/osm2vectortiles

Tiles are then served at http://localhost:6767/{layer}/{z}/{x}/{y}.pbf

A list of all detected layers is available at http://localhost:6767/

Use a tile cache:

t_rex serve --dbconn postgresql://user:[email protected]/osm2vectortiles --cache /tmp/mvtcache

Generate a configuration template:

t_rex genconfig --dbconn postgresql://user:[email protected]/osm2vectortiles

Run server with configuration file:

t_rex serve --config osm2vectortiles.cfg

Generate tiles for cache:

t_rex generate --config osm2vectortiles.cfg


Configuration file example:

viewer = true

type = "postgis"
url = "postgresql://user:[email protected]/natural_earth_vectors"

predefined = "web_mercator"

name = "osm"

name = "points"
# Select all attributes of table:
table_name = "ne_10m_populated_places"
geometry_field = "wkb_geometry"
geometry_type = "POINT"
fid_field = "id"

name = "buildings"
geometry_field = "geometry"
geometry_type = "POLYGON"
fid_field = "osm_id"
# Clip polygons with a buffer
buffer-size = 10
simplify = true
  # Queries for different zoom levels:
  sql = """
    SELECT name, type, 0 as osm_id, ST_Union(geometry) AS geometry
    FROM osm_buildings_gen0
    WHERE geometry && !bbox!
    GROUP BY name, type
    ORDER BY sum(area) DESC"""
  minzoom = 17
  maxzoom = 22
  sql = """
    SELECT name, type, osm_id, geometry
    FROM osm_buildings
    ORDER BY area DESC"""

base = "/var/cache/mvtcache"

bind = ""
port = 8080
threads = 4


Pre-built binaries are available for 64 bit Linux and Windows. Download your binary from github.com/pka/t-rex/releases and unpack it.

t_rex is an executable with very few dependencies, essentially libgcc_s.so.1 on Linux and msvcr120.dll on Windows. If msvcr120.dll is missing, install vcredist_x64.exe from here.

MBTiles creation

To create MBTiles files with vector tiles from a local cache you can use MBUtil.


mb-util --image_format=pbf /tmp/mvtcache/streets streets.mbtiles

For developers

t-rex is written in Rust.


cargo build

Run tests:

cargo test

To run DB tests you have to set an environment variable with the connection spec first. Example:

 export DBCONN=postgresql://user:[email protected]/natural_earth_vectors

Creating test database:

# Set Postgresql environment variables when needed: PGHOST, PGPORT, PGUSER, PGPASSWORD
cd src/test

Run server:

cargo run -- serve --dbconn postgresql://[email protected]%2Frun%2Fpostgresql/natural_earth_vectors

Set log level:

RUST_LOG=debug  # error, warn, info, debug, trace

Decode a vector tile:

curl --silent | gunzip -d | protoc --decode=vector_tile.Tile src/mvt/vector_tile.proto


t-rex is released under the MIT License.

Related Repositories



the t-rex runner game extracted from chromium ...



t-rex is a vector tile server specialized on publishing MVT tiles from a PostGIS database ...



A BitTorrent client in Elixir ...



Chrome Offline page "T-Rex Runner" game bot ...



更容易嵌入的 Chrome "恐龙快跑"游戏. ...

Top Contributors

pka rory


-   v0.4.0 zip tar
-   v0.3.1 zip tar
-   v0.3.0 zip tar
-   v0.2.0 zip tar
-   v0.1.0 zip tar
-   v0.1.0-pre7 zip tar
-   v0.1.0-pre6 zip tar
-   v0.1.0-pre5 zip tar
-   v0.1.0-pre4 zip tar
-   v0.1.0-pre3 zip tar
-   v0.1.0-pre2 zip tar
-   v0.1.0-pre1 zip tar