专属域名
文档搜索
轩辕助手
Run助手
邀请有礼
返回顶部
快速返回页面顶部
收起
收起工具栏
轩辕镜像 官方专业版
轩辕镜像
专业版
轩辕镜像 官方专业版
轩辕镜像
专业版
首页个人中心搜索镜像

交易
充值流量我的订单
工具
提交工单镜像收录一键安装
Npm 源Pip 源Homebrew 源
帮助
常见问题轩辕镜像免费版
其他
关于我们网站地图
热门搜索:
martin

urbica/martin

自动构建
urbica

Martin is a blazing fast and lightweight PostGIS Mapbox Vector Tiles server written in Rust.

5 次收藏下载次数: 0状态:自动构建维护者:urbica仓库类型:镜像最近更新:3 年前
轩辕镜像,不浪费每一次拉取。点击查看
镜像简介
标签下载
镜像标签列表与下载命令
轩辕镜像,不浪费每一次拉取。点击查看

Martin

https://github.com/urbica/martin/workflows/CI/badge.svg](https://github.com/urbica/martin/actions) !https://github.com/urbica/martin/workflows/Security%20audit/badge.svg

Martin is a https://github.com/postgis/postgis https://github.com/mapbox/vector-tile-spec server suitable for large databases. Martin is written in https://github.com/rust-lang/rust using https://github.com/actix/actix-web web framework.

!https://raw.githubusercontent.com/urbica/martin/master/logo.png

  • Requirements
  • Installation
  • Usage
  • API
  • Using with Mapbox GL JS
  • Using with Leaflet
  • Using with deck.gl
  • Table Sources
    • Table Sources List
    • Table Source TileJSON
    • Table Source Tiles
  • Composite Sources
    • Composite Source TileJSON
    • Composite Source Tiles
  • Function Sources
    • Function Sources List
    • Function Source TileJSON
    • Function Source Tiles
  • Command-line Interface
  • Environment Variables
  • Configuration File
  • Using with Docker
  • Using with Docker Compose
  • Using with Nginx
  • Building from Source
  • Debugging
  • Development

Requirements

Martin requires PostGIS >= 2.4.0.

Installation

You can download martin from https://github.com/urbica/martin/releases.

PlatformDownloads (latest)
Linuxhttps://github.com/urbica/martin/releases/latest/download/martin-Linux-x86_64.tar.gz
macOShttps://github.com/urbica/martin/releases/latest/download/martin-Darwin-x86_64.tar.gz
Windowshttps://github.com/urbica/martin/releases/latest/download/martin-Windows-x86_64.zip

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

shell
brew tap urbica/tap
brew install martin

You can also use https://hub.docker.com/r/urbica/martin

shell
docker run -p 3000:3000 -e DATABASE_URL=postgres://postgres@localhost/db urbica/martin

Usage

Martin requires a database connection string. It can be passed as a command-line argument or as a DATABASE_URL environment variable.

shell
martin postgres://postgres@localhost/db

Martin provides https://github.com/mapbox/tilejson-spec endpoint for each geospatial-enabled table in your database.

API

MethodURLDescription
GET/index.jsonTable Sources List
GET/{schema_name}.{table_name}.jsonTable Source TileJSON
GET/{schema_name}.{table_name}/{z}/{x}/{y}.pbfTable Source Tiles
GET/{schema_name1}.{table_name1},...,{schema_nameN}.{table_nameN}.jsonComposite Source TileJSON
GET/{schema_name1}.{table_name1},...,{schema_nameN}.{table_nameN}/{z}/{x}/{y}.pbfComposite Source Tiles
GET/rpc/index.jsonFunction Sources List
GET/rpc/{schema_name}.{function_name}.jsonFunction Source TileJSON
GET/rpc/{schema_name}.{function_name}/{z}/{x}/{y}.pbfFunction Source Tiles
GET/healthzMartin server health check: returns 200 OK

Using with Mapbox GL JS

https://github.com/mapbox/mapbox-gl-js is a JavaScript library for interactive, customizable vector maps on the web. It takes map styles that conform to the Mapbox Style Specification, applies them to vector tiles that conform to the https://github.com/mapbox/vector-tile-spec, and renders them using WebGL.

You can add a layer to the map and specify martin TileJSON endpoint as a vector source URL. You should also specify a source-layer property. For Table Sources it is {schema_name}.{table_name} by default.

js
map.addLayer({
  id: "public.points",
  type: "circle",
  source: {
    type: "vector",
    url: "http://localhost:3000/public.points.json",
  },
  "source-layer": "public.points",
  paint: {
    'circle-color': 'red',
  },
});

You can also combine multiple tables into one source with Composite Sources. Each Table Source in Composite Source can be accessed with its {schema_name}.{table_name} as a source-layer property.

js
map.addSource("points", {
  type: "vector",
  url: `http://0.0.0.0:3000/public.points1,public.points2.json`,
});

map.addLayer({
  id: "red_points",
  type: "circle",
  source: "points",
  "source-layer": "public.points1",
  paint: {
    "circle-color": "red",
  },
});

map.addLayer({
  id: "blue_points",
  type: "circle",
  source: "points",
  "source-layer": "public.points2",
  paint: {
    "circle-color": "blue",
  },
});

Using with Leaflet

https://github.com/Leaflet/Leaflet is the leading open-source JavaScript library for mobile-friendly interactive maps.

You can add vector tiles using https://github.com/Leaflet/Leaflet.VectorGrid plugin. You must initialize a https://leaflet.github.io/Leaflet.VectorGrid/vectorgrid-api-docs.html#vectorgrid-protobuf with a URL template, just like in L.TileLayers. The difference is that you should define the styling for all the features.

js
L.vectorGrid
  .protobuf('http://localhost:3000/public.points/{z}/{x}/{y}.pbf', {
    vectorTileLayerStyles: {
      'public.points': {
        color: 'red',
        fill: true,
      },
    },
  })
  .addTo(map);

Using with deck.gl

deck.gl is a WebGL-powered framework for visual exploratory data analysis of large datasets.

You can add vector tiles using MVTLayer. MVTLayer data property defines the remote data for the MVT layer. It can be

  • String: Either a URL template or a https://github.com/mapbox/tilejson-spec URL.
  • Array: an array of URL templates. It allows to balance the requests across different tile endpoints. For example, if you define an array with 4 urls and 16 tiles need to be loaded, each endpoint is responsible to server 16/4 tiles.
  • JSON: A valid https://github.com/mapbox/tilejson-spec/tree/master/2.2.0.
js
const pointsLayer = new MVTLayer({
  data: 'http://localhost:3000/public.points.json', // 'http://localhost:3000/public.table_source/{z}/{x}/{y}.pbf'
  pointRadiusUnits: 'pixels',
  getRadius: 5,
  getFillColor: [230, 0, 0]
});

const deckgl = new DeckGL({
  container: 'map',
  mapStyle: 'https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json',
  initialViewState: {
    latitude: 0,
    longitude: 0,
    zoom: 1
  },
  layers: [pointsLayer]
});

Table Sources

Table Source is a database table which can be used to query https://github.com/mapbox/vector-tile-spec. When started, martin will go through all spatial tables in the database and build a list of table sources. A table should have at least one geometry column with non-zero SRID. All other table columns will be represented as properties of a vector tile feature.

Table Sources List

Table Sources list endpoint is available at /index.json

shell
curl localhost:3000/index.json

Note: if in watch mode, this will rescan database for table sources.

Table Source TileJSON

Table Source https://github.com/mapbox/tilejson-spec endpoint is available at /{schema_name}.{table_name}.json.

For example, points table in public schema will be available at /public.points.json

shell
curl localhost:3000/public.points.json

Table Source Tiles

Table Source tiles endpoint is available at /{schema_name}.{table_name}/{z}/{x}/{y}.pbf

For example, points table in public schema will be available at /public.points/{z}/{x}/{y}.pbf

shell
curl localhost:3000/public.points/0/0/0.pbf

Composite Sources

Composite Sources allows combining multiple Table Sources into one. Composite Source consists of multiple Table Sources separated by comma {schema_name1}.{table_name1},...,{schema_nameN}.{table_nameN}

Each Table Source in Composite Source can be accessed with its {schema_name}.{table_name} as a source-layer property.

Composite Source TileJSON

Composite Source https://github.com/mapbox/tilejson-spec endpoint is available at /{schema_name1}.{table_name1},...,{schema_nameN}.{table_nameN}.json.

For example, composite source for points and lines tables in public schema will be available at /public.points,public.lines.json

shell
curl localhost:3000/public.points,public.lines.json

Composite Source Tiles

Composite Source tiles endpoint is available at /{schema_name1}.{table_name1},...,{schema_nameN}.{table_nameN}/{z}/{x}/{y}.pbf

For example, composite source for points and lines tables in public schema will be available at /public.points,public.lines/{z}/{x}/{y}.pbf

shell
curl localhost:3000/public.points,public.lines/0/0/0.pbf

Function Sources

Function Source is a database function which can be used to query https://github.com/mapbox/vector-tile-spec. When started, martin will look for the functions with a suitable signature. A function that takes z integer, x integer, y integer, and query_params json and returns bytea, can be used as a Function Source.

ArgumentTypeDescription
zintegerTile zoom parameter
xintegerTile x parameter
yintegerTile y parameter
query_paramsjsonQuery string parameters

Hint: You may want to use https://github.com/mapbox/postgis-vt-util#tilebbox function to generate bounding-box geometry of the area covered by a tile.

For example, if you have a table public.table_source in WGS84 (4326 SRID), then you can use this function as a Function Source:

sql
CREATE OR REPLACE FUNCTION public.function_source(z integer, x integer, y integer, query_params json) RETURNS bytea AS $
DECLARE
  mvt bytea;
BEGIN
  SELECT INTO mvt ST_AsMVT(tile, 'public.function_source', 4096, 'geom') FROM (
    SELECT
      ST_AsMVTGeom(ST_Transform(geom, 3857), TileBBox(z, x, y, 3857), 4096, 64, true) AS geom
    FROM public.table_source
    WHERE geom && TileBBox(z, x, y, 4326)
  ) as tile WHERE geom IS NOT NULL;

  RETURN mvt;
END
$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE;

The query_params argument is a JSON representation of the tile request query params. For example, if user requested a tile with urlencoded params:

shell
curl \
  --data-urlencode 'arrayParam=[1, 2, 3]' \
  --data-urlencode 'numberParam=42' \
  --data-urlencode 'stringParam=value' \
  --data-urlencode 'booleanParam=true' \
  --data-urlencode 'objectParam={"answer" : 42}' \
  --get localhost:3000/rpc/public.function_source/0/0/0.pbf

then query_params will be parsed as:

json
{
  "arrayParam": [1, 2, 3],
  "numberParam": 42,
  "stringParam": "value",
  "booleanParam": true,
  "objectParam": { "answer": 42 }
}

You can access this params using json operators:

sql
...WHERE answer = (query_params->'objectParam'->>'answer')::int;

Function Sources List

Function Sources list endpoint is available at /rpc/index.json

shell
curl localhost:3000/rpc/index.json

Note: if in watch mode, this will rescan database for function sources.

Function Source TileJSON

Function Source https://github.com/mapbox/tilejson-spec endpoint is available at /rpc/{schema_name}.{function_name}.json

For example, points function in public schema will be available at /rpc/public.points.json

shell
curl localhost:3000/rpc/public.points.json

Function Source Tiles

Function Source tiles endpoint is available at /rpc/{schema_name}.{function_name}/{z}/{x}/{y}.pbf

For example, points function in public schema will be available at /rpc/public.points/{z}/{x}/{y}.pbf

shell
curl localhost:3000/rpc/public.points/0/0/0.pbf

Command-line Interface

You can configure martin using command-line interface

shell
Usage:
  martin [options] [<connection>]
  martin -h | --help
  martin -v | --version

Options:
  -h --help                         Show this screen.
  -v --version                      Show version.
  --config=<path>                   Path to config file.
  --keep-alive=<n>                  Connection keep alive timeout [default: 75].
  --listen-addresses=<n>            The socket address to bind [default: 0.0.0.0:3000].
  --pool-size=<n>                   Maximum connections pool size [default: 20].
  --watch                           Scan for new sources on sources list requests.
  --workers=<n>                     Number of web server workers.
  --danger-accept-invalid-certs     Trust invalid certificates. This introduces significant vulnerabilities, and should only be used as a last resort.

Environment Variables

You can also configure martin using environment variables

Environment variableExampleDescription
DATABASE_URLpostgres://postgres@localhost/dbpostgres database connection
WATCH_MODEtruescan for new sources
DANGER_ACCEPT_INVALID_CERTSfalseTrust invalid certificates

Configuration File

If you don't want to expose all of your tables and functions, you can list your sources in a configuration file. To start martin with a configuration file you need to pass a path to a file with a --config argument.

shell
martin --config config.yaml

You can find an example of a configuration file https://github.com/urbica/martin/blob/master/tests/config.yaml.

yaml
# Database connection string
connection_string: "postgres://postgres@localhost/db"

# Maximum connections pool size [default: 20]
pool_size: 20

# Connection keep alive timeout [default: 75]
keep_alive: 75

# Number of web server workers
worker_processes: 8

# The socket address to bind [default: 0.0.0.0:3000]
listen_addresses: "0.0.0.0:3000"

# Enable watch mode
watch: true

# Trust invalid certificates. This introduces significant vulnerabilities, and should only be used as a last resort.
danger_accept_invalid_certs: false

# associative arrays of table sources
table_sources:
  public.table_source:
    # table source id
    id: public.table_source

    # table schema
    schema: public

    # table name
    table: table_source

    # geometry column name
    geometry_column: geom

    # geometry srid
    srid: 4326

    # tile extent in tile coordinate space
    extent: 4096

    # buffer distance in tile coordinate space to optionally clip geometries
    buffer: 64

    # boolean to control if geometries should be clipped or encoded as is
    clip_geom: true

    # geometry type
    geometry_type: GEOMETRY

    # list of columns, that should be encoded as a tile properties
    properties:
      gid: int4

# associative arrays of function sources
function_sources:
  public.function_source:
    # function source id
    id: public.function_source

    # schema name
    schema: public

    # function name
    function: function_source

Using with Docker

You can use official Docker image https://hub.docker.com/r/urbica/martin

shell
docker run \
  -p 3000:3000 \
  -e DATABASE_URL=postgres://postgres@localhost/db \
  urbica/martin

If you are running PostgreSQL instance on localhost, you have to change network settings to allow the Docker container to access the localhost network.

For Linux, add the --net=host flag to access the localhost PostgreSQL service.

shell
docker run \
  --net=host \
  -p 3000:3000 \
  -e DATABASE_URL=postgres://postgres@localhost/db \
  urbica/martin

For macOS, use host.docker.internal as hostname to access the localhost PostgreSQL service.

shell
docker run \
  -p 3000:3000 \
  -e DATABASE_URL=postgres://postgres@host.docker.internal/db \
  urbica/martin

For Windows, use docker.for.win.localhost as hostname to access the localhost PostgreSQL service.

shell
docker run \
  -p 3000:3000 \
  -e DATABASE_URL=postgres://postgres@docker.for.win.localhost/db \
  urbica/martin

Using with Docker Compose

You can use example https://raw.githubusercontent.com/urbica/martin/master/docker-compose.yml file as a reference

yml
version: "3"

services:
  martin:
    image: urbica/martin
    restart: unless-stopped
    ports:
      - 3000:3000
    environment:
      - WATCH_MODE=true
      - DATABASE_URL=postgres://postgres:password@db/db
    depends_on:
      - db

  db:
    image: postgis/postgis:13-3.1-alpine
    restart: unless-stopped
    environment:
      - POSTGRES_DB=db
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=password
    volumes:
      - ./pg_data:/var/lib/postgresql/data

First, you need to start db service

shell
docker-compose up -d db

Then, after db service is ready to accept connections, you can start martin

shell
docker-compose up -d martin

By default, martin will be available at localhost:3000

Using with Nginx

If you are running martin behind nginx proxy, you may want to rewrite request URL, to properly handle tile urls in TileJSON endpoints.

nginx
location ~ /tiles/(?<fwd_path>.*) {
    proxy_set_header  X-Rewrite-URL $request_uri;
    proxy_set_header  X-Forwarded-Host $host:$server_port;
    proxy_set_header  X-Forwarded-Proto $scheme; # or $http_x_forwarded_proto
    proxy_pass        http://martin:3000/$fwd_path$is_args$args;
}

Building from Source

You can clone the repository and build martin using cargo package manager.

shell
git clone git@github.com:urbica/martin.git
cd martin
cargo build --release

The binary will be available at ./target/release/martin.

shell
cd ./target/release/
./martin postgres://postgres@localhost/db

Debugging

Log levels are controlled on a per-module basis, and by default all logging is disabled except for errors. Logging is controlled via the RUST_LOG environment variable. The value of this environment variable is a comma-separated list of logging directives.

This will enable debug logging for all modules:

shell
export RUST_LOG=debug
martin postgres://postgres@localhost/db

While this will only enable verbose logging for the actix_web module and enable debug logging for the martin and tokio_postgres modules:

shell
export RUST_LOG=actix_web=info,martin=debug,tokio_postgres=debug
martin postgres://postgres@localhost/db

Development

Clone project

shell
git clone git@github.com:urbica/martin.git
cd martin

Start db service using docker-compose

shell
docker-compose up -d db

Then, after db service is ready to accept connections, you can start martin with

shell
DATABASE_URL=postgres://postgres@localhost/db cargo run

By default, martin will be available at localhost:3000

Make your changes, and check if all the tests are running

shell
DATABASE_URL=postgres://postgres@localhost/db cargo test

You can also run benchmarks with

shell
DATABASE_URL=postgres://postgres@localhost/db cargo bench

An HTML report displaying the results of the benchmark will be generated under target/criterion/report/index.html

镜像拉取方式

您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。

轩辕镜像加速拉取命令点我查看更多 martin 镜像标签

docker pull docker.xuanyuan.run/urbica/martin:<标签>

使用方法:

  • 登录认证方式
  • 免认证方式

DockerHub 原生拉取命令

docker pull urbica/martin:<标签>

更多 martin 镜像推荐

martin/docker-cleanup-volumes logo

martin/docker-cleanup-volumes

martin
Delete orphaned docker volumes
69 次收藏1000万+ 次下载
3 年前更新
maplibre/martin logo

maplibre/martin

maplibre
极速轻量的PostGIS矢量瓦片服务器
9 次收藏50万+ 次下载
3 年前更新
martinhelmich/typo3 logo

martinhelmich/typo3

martinhelmich
TYPO3内容管理系统的Docker镜像,提供简单快速的启动方式,适用于开发和测试环境,需配合独立数据库容器使用,暂不建议用于生产环境。
45 次收藏100万+ 次下载
3 个月前更新

查看更多 martin 相关镜像

轩辕镜像配置手册

探索更多轩辕镜像的使用方法,找到最适合您系统的配置方式

Docker 配置

登录仓库拉取

通过 Docker 登录认证访问私有仓库

专属域名拉取

无需登录使用专属域名

K8s Containerd

Kubernetes 集群配置 Containerd

K3s

K3s 轻量级 Kubernetes 镜像加速

Dev Containers

VS Code Dev Containers 配置

Podman

Podman 容器引擎配置

Singularity/Apptainer

HPC 科学计算容器配置

其他仓库配置

ghcr、Quay、nvcr 等镜像仓库

Harbor 镜像源配置

Harbor Proxy Repository 对接专属域名

Portainer 镜像源配置

Portainer Registries 加速拉取

Nexus 镜像源配置

Nexus3 Docker Proxy 内网缓存

系统配置

Linux

在 Linux 系统配置镜像服务

Windows/Mac

在 Docker Desktop 配置镜像

MacOS OrbStack

MacOS OrbStack 容器配置

Docker Compose

Docker Compose 项目配置

NAS 设备

群晖

Synology 群晖 NAS 配置

飞牛

飞牛 fnOS 系统配置镜像

绿联

绿联 NAS 系统配置镜像

威联通

QNAP 威联通 NAS 配置

极空间

极空间 NAS 系统配置服务

网络设备

爱快路由

爱快 iKuai 路由系统配置

宝塔面板

在宝塔面板一键配置镜像

需要其他帮助?请查看我们的 常见问题Docker 镜像访问常见问题解答 或 提交工单

镜像拉取常见问题

使用与功能问题

配置了专属域名后,docker search 为什么会报错?

docker search 限制

Docker Hub 上有的镜像,为什么在轩辕镜像网站搜不到?

站内搜不到镜像

机器不能直连外网时,怎么用 docker save / load 迁镜像?

离线 save/load

docker pull 拉插件报错(plugin v1+json)怎么办?

插件要用 plugin install

WSL 里 Docker 拉镜像特别慢,怎么排查和优化?

WSL 拉取慢

轩辕镜像安全吗?如何用 digest 校验镜像没被篡改?

安全与 digest

第一次用轩辕镜像拉 Docker 镜像,要怎么登录和配置?

新手拉取配置

轩辕镜像合规吗?轩辕镜像的合规是怎么做的?

镜像合规机制

轩辕镜像支持 docker push 上传本地镜像吗?

不支持 push

错误码与失败问题

docker pull 提示 manifest unknown 怎么办?

manifest unknown

docker pull 提示 no matching manifest 怎么办?

no matching manifest(架构)

镜像已拉取完成,却提示 invalid tar header 或 failed to register layer 怎么办?

invalid tar header(解压)

Docker pull 时 HTTPS / TLS 证书验证失败怎么办?

TLS 证书失败

Docker pull 时 DNS 解析超时或连不上仓库怎么办?

DNS 超时

docker 无法连接轩辕镜像域名怎么办?

域名连通性排查

Docker 拉取出现 410 Gone 怎么办?

410 Gone 排查

出现 402 或「流量用尽」提示怎么办?

402 与流量用尽

Docker 拉取提示 UNAUTHORIZED(401)怎么办?

401 认证失败

遇到 429 Too Many Requests(请求太频繁)怎么办?

429 限流

docker login 提示 Cannot autolaunch D-Bus,还算登录成功吗?

D-Bus 凭证提示

为什么会出现「单层超过 20GB」或 413,无法加速拉取?

413 与超大单层

账号 / 计费 / 权限

轩辕镜像免费版和专业版有什么区别?

免费版与专业版区别

轩辕镜像支持哪些 Docker 镜像仓库?

支持的镜像仓库

镜像拉取失败还会不会扣流量?

失败是否计费

麒麟 V10 / 统信 UOS 提示 KYSEC 权限不够怎么办?

KYSEC 拦截脚本

如何在轩辕镜像申请开具发票?

申请开票

怎么修改轩辕镜像的网站登录和仓库登录密码?

修改登录密码

如何注销轩辕镜像账户?要注意什么?

注销账户

配置与原理类

写了 registry-mirrors,为什么还是走官方或仍然报错?

mirrors 不生效

怎么用 docker tag 去掉镜像名里的轩辕域名前缀?

去掉域名前缀

如何拉取指定 CPU 架构的镜像(如 ARM64、AMD64)?

指定架构拉取

用轩辕镜像拉镜像时快时慢,常见原因有哪些?

拉取速度原因

为什么拉取镜像的 :latest 标签,拿到的往往不是「最新」镜像?

latest 与「最新」

查看全部问题→

用户好评

来自真实用户的反馈,见证轩辕镜像的优质服务

用户头像

oldzhang

运维工程师

Linux服务器

5

"Docker访问体验非常流畅,大镜像也能快速完成下载。"

轩辕镜像
镜像详情
...
urbica/martin
博客Docker 镜像公告与技术博客
热门查看热门 Docker 镜像推荐
安装一键安装 Docker 并配置镜像源
镜像拉取问题咨询请 提交工单。官方公众号:源码跳动。官方技术交流群:51517718。轩辕镜像所有镜像均来源于原始仓库,本站不存储、不修改、不传播任何镜像内容。
镜像拉取问题咨询请提交工单。官方公众号:源码跳动。官方技术交流群:。轩辕镜像所有镜像均来源于原始仓库,本站不存储、不修改、不传播任何镜像内容。
商务合作:点击复制邮箱
©2024-2026 源码跳动
商务合作:点击复制邮箱Copyright © 2024-2026 杭州源码跳动科技有限公司. All rights reserved.