martin/README.md

100 lines
5.5 KiB
Markdown
Raw Normal View History

# Martin
2017-10-09 14:29:03 +03:00
[![Book](https://img.shields.io/badge/docs-Book-informational)](https://maplibre.org/martin)
[![docs.rs docs](https://docs.rs/martin/badge.svg)](https://docs.rs/martin)
[![Slack chat](https://img.shields.io/badge/Chat-on%20Slack-blueviolet)](https://slack.openstreetmap.us/)
[![GitHub](https://img.shields.io/badge/github-maplibre/martin-8da0cb?logo=github)](https://github.com/maplibre/martin)
[![crates.io version](https://img.shields.io/crates/v/martin.svg)](https://crates.io/crates/martin)
[![Security audit](https://github.com/maplibre/martin/workflows/Security%20audit/badge.svg)](https://github.com/maplibre/martin/security)
[![CI build](https://github.com/maplibre/martin/workflows/CI/badge.svg)](https://github.com/maplibre/martin/actions)
2017-10-15 14:48:23 +03:00
Martin is a tile server able to generate [vector tiles](https://github.com/mapbox/vector-tile-spec) on the fly from large [PostGIS](https://github.com/postgis/postgis) databases, or serve tiles from [PMTile](https://protomaps.com/blog/pmtiles-v3-whats-new) and [MBTile](https://github.com/mapbox/mbtiles-spec) files. Martin optimizes for speed and heavy traffic, and is written in [Rust](https://github.com/rust-lang/rust).
2023-02-17 04:46:07 +03:00
See [Martin book](https://maplibre.org/martin/) for complete documentation.
2023-02-17 04:46:07 +03:00
![Martin](https://raw.githubusercontent.com/maplibre/martin/main/logo.png)
2023-02-17 04:46:07 +03:00
## Requirements
2023-02-17 04:46:07 +03:00
When using Martin with PostgreSQL, you must install PostGIS with at least v3.0+, and v3.1+ is recommended.
2023-02-17 04:46:07 +03:00
## Installation
2023-02-17 04:46:07 +03:00
You can download martin from [GitHub releases page](https://github.com/maplibre/martin/releases).
| Platform | Downloads (latest) |
|----------|------------------------|
| Linux | [64-bit][rl-linux-tar] |
| macOS | [64-bit][rl-macos-tar] |
| Windows | [64-bit][rl-win64-zip] |
[rl-linux-tar]: https://github.com/maplibre/martin/releases/latest/download/martin-Linux-x86_64.tar.gz
[rl-macos-tar]: https://github.com/maplibre/martin/releases/latest/download/martin-Darwin-x86_64.tar.gz
[rl-win64-zip]: https://github.com/maplibre/martin/releases/latest/download/martin-Windows-x86_64.zip
If you are using macOS and [Homebrew](https://brew.sh/) you can install martin using Homebrew tap.
```shell
brew tap maplibre/martin https://github.com/maplibre/martin.git
brew install maplibre/martin/martin
2023-02-17 04:46:07 +03:00
```
You can also use [official Docker image](https://ghcr.io/maplibre/martin)
2023-02-17 04:46:07 +03:00
```shell
export PGPASSWORD=postgres # secret!
docker run \
-p 3000:3000 \
-e PGPASSWORD \
-e DATABASE_URL=postgresql://user@host:port/db \
ghcr.io/maplibre/martin
2023-02-17 04:46:07 +03:00
```
Use docker `-v` param to share configuration file or its directory with the container:
```shell
export PGPASSWORD=postgres # secret!
docker run -p 3000:3000 \
2023-02-17 04:46:07 +03:00
-e PGPASSWORD \
-e DATABASE_URL=postgresql://user@host:port/db \
-v /path/to/config/dir:/config \
ghcr.io/maplibre/martin --config /config/config.yaml
2023-02-17 04:46:07 +03:00
```
## Usage
2023-02-17 04:46:07 +03:00
### PostGIS sources
2023-02-17 04:46:07 +03:00
Martin requires at least one PostgreSQL [connection string](https://maplibre.org/martin/PostgreSQL-Connection-String.html) or a [tile source file](https://maplibre.org/martin/MBTile-and-PMTile-Sources.html) as a command-line argument. A PG connection string can also be passed via the `DATABASE_URL` environment variable.
2023-02-17 04:46:07 +03:00
```shell
martin postgresql://user:password@host:port/database
2023-02-17 04:46:07 +03:00
```
Martin provides [TileJSON](https://github.com/mapbox/tilejson-spec) endpoint for each [geospatial-enabled](https://postgis.net/docs/using_postgis_dbmanagement.html#geometry_columns) table in your database.
2023-02-17 04:46:07 +03:00
### MBTiles and PMTiles sources
2023-02-17 04:46:07 +03:00
Martin can serve any type of tiles from [PMTile](https://protomaps.com/blog/pmtiles-v3-whats-new) and [MBTile](https://github.com/mapbox/mbtiles-spec) files. To serve a file from CLI, simply put the path to the file or the directory with `*.mbtiles` or `*.pmtiles` files. For example:
```shell
martin /path/to/mbtiles/file.mbtiles
martin /path/to/directory
2023-02-17 04:46:07 +03:00
```
## API
2023-02-17 04:46:07 +03:00
When started, Martin will go through all spatial tables and functions with an appropriate signature in the database. These tables and functions will be available as the HTTP endpoints, which you can use to query Mapbox vector tiles.
2023-06-01 18:36:03 +03:00
| URL | Description |
|----------------------------------------|-----------------------------------------------------------------------------------------------------------|
| `/` | Status text, that will eventually show web UI |
| `/catalog` | [List of all sources](https://maplibre.org/martin/source-list.html) |
| `/{sourceID}` | [Source TileJSON](https://maplibre.org/martin/table-sources.html#table-source-tilejson) |
| `/{sourceID}/{z}/{x}/{y}` | [Source Tiles](https://maplibre.org/martin/table-sources.html#table-source-tiles) |
| `/{sourceID1},...,{nameN}` | [Composite Source TileJSON](https://maplibre.org/martin/composite-sources.html#composite-source-tilejson) |
| `/{sourceID1},...,{nameN}/{z}/{x}/{y}` | [Composite Source Tiles](https://maplibre.org/martin/composite-sources.html#composite-source-tiles) |
| `/health` | Martin server health check: returns 200 `OK` |
## Documentation
See [Martin book](https://maplibre.org/martin/) for complete documentation.