Blazing fast and lightweight PostGIS, MBtiles and PMtiles tile server, tile generation, and mbtiles tooling.
Go to file
Josh Lee 9f9f18163c
Add AWS Lambda support (#1127)
This adds the lambda-web crate to adapt the actix App to speak to Lambda
by way of the lambda_runtime crate.

AWS Lambda has native support for scripting languages to
execute a function directly; compiled languages must embed a runtime to
fetch incoming events from Lambda and post the responses. This detects
the environment variables to start up in Lambda mode instead of the
normal HTTP server, and is added as an optional feature.

Lambda has five (!) distinct ways of routing HTTP requests to a
function; this supports some of them. (Specifically, the most obvious
way to do this is with a Function URL, which is newest and simplest, and
perhaps with CloudFront, which speaks to the Function URL and not Lambda
directly.)

The error handling could probably be refined, I was just trying to get
this to compile.

(Supported: API Gateway HTTP API with payload format version 2.0; API
Gateway REST API; Lambda function URLs / Not supported: API Gateway HTTP
API with payload format version 1.0; Application Load Balancer)

Necessary for #1102 to be able to run the released packages directly,
and only having to configure the appropriate environment.

---------

Co-authored-by: Yuri Astrakhan <yuriastrakhan@gmail.com>
2024-02-01 18:56:40 +00:00
.cargo-husky/hooks Move some build commands to CI (#1101) 2023-12-24 23:43:58 -05:00
.github Add AWS Lambda support (#1127) 2024-02-01 18:56:40 +00:00
debian Implement tile caching (#1105) 2023-12-30 22:48:23 -05:00
demo Adapt justfiles for Docker Compose command (#1153) 2024-01-29 13:15:10 -05:00
docs Add AWS Lambda support (#1127) 2024-02-01 18:56:40 +00:00
martin Add AWS Lambda support (#1127) 2024-02-01 18:56:40 +00:00
martin-tile-utils Implement tile caching (#1105) 2023-12-30 22:48:23 -05:00
mbtiles Use ORDERBY in calc_agg_tiles_hash - SQLite v3.44 (#1156) 2024-01-27 21:48:54 -05:00
tests Add AWS Lambda support (#1127) 2024-02-01 18:56:40 +00:00
.dockerignore Add AWS Lambda support (#1127) 2024-02-01 18:56:40 +00:00
.gitignore Add AWS Lambda support (#1127) 2024-02-01 18:56:40 +00:00
Cargo.lock Add AWS Lambda support (#1127) 2024-02-01 18:56:40 +00:00
Cargo.toml Add AWS Lambda support (#1127) 2024-02-01 18:56:40 +00:00
CHANGELOG.md fix spaces 2023-10-12 16:10:24 -04:00
CODE_OF_CONDUCT.md feat: clean up readme and code of conduct (#382) 2022-08-11 07:06:12 -04:00
docker-compose.yml Implement http pmtiles (#991) 2023-12-22 06:01:50 +00:00
justfile Add AWS Lambda support (#1127) 2024-02-01 18:56:40 +00:00
LICENSE-APACHE Clean up licensing per on-boarding (#364) 2022-07-06 08:25:45 -04:00
LICENSE-MIT Clean up licensing per on-boarding (#364) 2022-07-06 08:25:45 -04:00
logo.png docs: ✏️ add notes on debugging 2019-02-04 20:22:04 +03:00
README.md doc links 2023-12-25 01:49:39 -05:00
rustfmt.toml Minor refactor and cleanup (#716) 2023-06-15 18:36:41 -04:00
SECURITY_POLICY.txt Create SECURITY_POLICY.txt (#489) 2023-02-04 19:06:17 -05:00

Martin

Book docs.rs docs GitHub crates.io version Security audit CI build

Martin is a tile server able to generate and serve vector tiles on the fly from large PostGIS databases, PMTile (local or remote), and MBTile files, allowing multiple tile sources to be dynamically combined into one. Martin optimizes for speed and heavy traffic, and is written in Rust.

Additionally, there are several tools for generating tiles in bulk from any Martin-supported sources (similar to tilelive-copy), copying tiles between MBTiles files, creating deltas (patches) and applying them, and validating MBTiles files.

See Martin book for complete documentation.

Installation

See installation instructions in the Martin book.

Prerequisites: If using Martin with PostgreSQL database, you must install PostGIS with at least v3.0+, v3.1+ recommended.

You can download martin from GitHub releases page.

Platform AMD-64 ARM-64
Linux .tar.gz (gnu)
.tar.gz (musl)
.deb
.tar.gz (musl)
macOS .tar.gz .tar.gz
Windows .zip

If you are using macOS and Homebrew you can install martin and mbtiles using Homebrew tap.

brew tap maplibre/martin
brew install martin

Running Martin Service

See running instructions in the Martin book.

Martin supports any number of PostgreSQL/PostGIS database connections with geospatial-enabled tables and tile-producing SQL functions, as well as PMTile and MBTile files as tile sources.

Martin can auto-discover tables and functions using a connection string. A PG connection string can also be passed via the DATABASE_URL environment variable.

Each tile source will have a TileJSON endpoint.

Examples

# publish all tables and functions from a single database
export DATABASE_URL="postgresql://user:password@host:port/database"
martin

# same as above, but passing connection string via CLI, together with a directory of .mbtiles/.pmtiles files
martin postgresql://user:password@host:port/database path/to/dir

# publish all discovered tables/funcs from two DBs
# and generate config file with all detected sources
martin postgres://... postgres://...  --save-config config.yaml

# use configuration file instead of auto-discovery
martin --config config.yaml

Docker Example

See Docker instructions in the Martin book.

Martin is also available as a Docker image. You could either share a configuration file from the host with the container via the -v param, or you can let Martin auto-discover all sources e.g. by passing DATABASE_URL or specifying the .mbtiles/.pmtiles files.

export PGPASSWORD=postgres  # secret!
docker run -p 3000:3000 \
           -e PGPASSWORD \
           -e DATABASE_URL=postgresql://user@host:port/db \
           -v /path/to/config/dir:/config \
           ghcr.io/maplibre/martin --config /config/config.yaml

API

See API documentation in the Martin book.

Martin data is available via the HTTP GET endpoints:

URL Description
/ Status text, that will eventually show web UI
/catalog List of all sources
/{sourceID} Source TileJSON
/{sourceID}/{z}/{x}/{y} Map Tiles
/{source1},…,{sourceN} Composite Source TileJSON
/{source1},…,{sourceN}/{z}/{x}/{y} Composite Source Tiles
/sprite/{spriteID}[@2x].{json,png} Sprites (low and high DPI, index/png)
/font/{font}/{start}-{end} Font source
/font/{font1},…,{fontN}/{start}-{end} Composite Font source
/health Martin server health check: returns 200 OK

Re-use Martin as a library

Martin can be used as a standalone server, or as a library in your own Rust application. When used as a library, you can use the following features:

  • postgres - enable PostgreSQL/PostGIS tile sources
  • pmtiles - enable PMTile tile sources
  • mbtiles - enable MBTile tile sources
  • fonts - enable font sources
  • sprites - enable sprite sources

Documentation

See Martin book for complete documentation.

License

Licensed under either of

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.