https://github.com/trailbehind/tilelive-asmvt
Tilelive module for generating Mapbox Vector Tiles from a Postgres DB using ST_AsMVT.
https://github.com/trailbehind/tilelive-asmvt
Last synced: 2 months ago
JSON representation
Tilelive module for generating Mapbox Vector Tiles from a Postgres DB using ST_AsMVT.
- Host: GitHub
- URL: https://github.com/trailbehind/tilelive-asmvt
- Owner: trailbehind
- License: mit
- Created: 2019-11-10T22:00:18.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-06-22T17:19:36.000Z (about 3 years ago)
- Last Synced: 2025-02-11T18:51:34.413Z (over 1 year ago)
- Language: JavaScript
- Size: 20.5 KB
- Stars: 2
- Watchers: 23
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tilelive-AsMVT
Tilelive module for generating Mapbox Vector Tiles from a Postgres DB using ST_AsMVT.
Requires a postgres function that takes 3 int arguments(zoom, x, y) and returns vector tile data to exist. It is suitable for use with functions generated by the [generate-sqltomvt tool](https://github.com/openmaptiles/openmaptiles-tools/blob/master/bin/generate-sqltomvt) from the [OpenMapTiles](https://github.com/openmaptiles/) project, or other a custom function with a similar signature.
## Example function
```
CREATE OR REPLACE FUNCTION gettile(zoom integer, x integer, y integer)
RETURNS bytea AS $$
ST_AsMVT(t, 'admin', 4096, 'mvtgeometry'), '') as mvtl FROM (
SELECT ST_AsMVTGeom(geometry, ST_TileEnvelope(zoom, x, y), 4096, 4, true) AS mvtgeometry, id, name
FROM my_table WHERE geometry && ST_TileEnvelope(zoom, x, y);
$$ LANGUAGE SQL STABLE RETURNS NULL ON NULL INPUT;
```
## Example source url:
`asmvt:///?host=localhost&user=postgres&database=osm&port=15432&function=gettile`
## Query parameters:
- `user` - postgres user, defaults to `PGUSER` environment variable if not provided.
- `host` - postgres host, defaults to `PGHOST` environment variable if not provided.
- `database` - database name, defaults to `PGDATABASE` environment variable if not provided.
- `password` - postgres password, defaults to `PGPASSWORD` environment variable if not provided.
- `port` - postgres port, defaults to `PGPORT` environment variable if not provided.
- `function` - REQUIRED - name of database function that returns tile data.