Home

Awesome

tilelive-pgquery

This tilelive module runs a PostgreSQL query created by the OpenMapTiles MVT tools, and returns the data blob from the query results.

This module can connect to more than one postgreSQL server and load-balance requests based on the number of pending queries, weighted by the maxpool param.

This module expects either a parametrized query, or the name of a PostgreSQL function with three parameters: z, x, y. The result is expected to be zero or one row, with the first column being the tile data blob. The data blob could be gzip-compressed by the server, in which case tilelive-pgquery will work faster by skipping the compression step. An optional second column may contain a hash string, i.e. the result of the MD5(tile) which will also speed up tilelive-pgquery tile retrieval. Without the hash, tilelive-pgquery will have to compute MD5 hash string itself. Tilelive-pgquery will determine the structure of the response during the startup by querying a tile specified by the testOnStartup parameter (or default tile 14/9268/3575).

Parameters

Exactly one of the following 3 parameters must be given.

Testing

Testing requires a local PostgreSQL service, even if it is empty and runs inside a docker container:

docker run -it --rm --name pg-docker -e POSTGRES_PASSWORD=openmaptiles -e POSTGRES_USER=openmaptiles -e POSTGRES_DB=openmaptiles -p 5432:5432 postgres

# For multi-host test, run another instance on a different port
docker run -it --rm --name pg-docker2 -e POSTGRES_PASSWORD=openmaptiles -e POSTGRES_USER=openmaptiles -e POSTGRES_DB=openmaptiles -p 5434:5432 postgres

Run tests in a separate shell using yarn run test