{"id":17288773,"url":"https://github.com/stepankuzmin/tilelive-postgis","last_synced_at":"2025-04-14T00:44:29.691Z","repository":{"id":20004415,"uuid":"84836025","full_name":"stepankuzmin/tilelive-postgis","owner":"stepankuzmin","description":"Implements the tilelive API for generating vector tiles from PostGIS","archived":false,"fork":false,"pushed_at":"2023-11-29T14:02:46.000Z","size":2159,"stargazers_count":52,"open_issues_count":21,"forks_count":10,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-27T14:55:03.624Z","etag":null,"topics":["javascript","mapnik","postgis","postgresql","tilelive","vector-tiles"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stepankuzmin.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-03-13T14:28:31.000Z","updated_at":"2024-10-11T01:47:36.000Z","dependencies_parsed_at":"2024-01-12T02:14:08.729Z","dependency_job_id":null,"html_url":"https://github.com/stepankuzmin/tilelive-postgis","commit_stats":{"total_commits":109,"total_committers":7,"mean_commits":"15.571428571428571","dds":0.2844036697247706,"last_synced_commit":"bfee43422ebc5f35f8de8f9bda3fb76b86e5c76e"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stepankuzmin%2Ftilelive-postgis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stepankuzmin%2Ftilelive-postgis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stepankuzmin%2Ftilelive-postgis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stepankuzmin%2Ftilelive-postgis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stepankuzmin","download_url":"https://codeload.github.com/stepankuzmin/tilelive-postgis/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248782259,"owners_count":21160717,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","mapnik","postgis","postgresql","tilelive","vector-tiles"],"created_at":"2024-10-15T10:29:55.145Z","updated_at":"2025-04-14T00:44:29.658Z","avatar_url":"https://github.com/stepankuzmin.png","language":"JavaScript","funding_links":[],"categories":["Geospatial Library","JavaScript"],"sub_categories":["JavaScript"],"readme":"# tilelive-postgis\n\n[![npm version](https://img.shields.io/npm/v/tilelive-postgis.svg)](https://www.npmjs.com/package/tilelive-postgis)\n[![npm downloads](https://img.shields.io/npm/dt/tilelive-postgis.svg)](https://www.npmjs.com/package/tilelive-postgis)\n[![Build Status](https://travis-ci.org/stepankuzmin/tilelive-postgis.svg?branch=master)](https://travis-ci.org/stepankuzmin/tilelive-postgis)\n\nImplements the [tilelive](https://github.com/mapbox/tilelive) API for generating mapnik vector tiles from PostGIS.\n\n## Installation\n\n```shell\nnpm install @mapbox/tilelive tilelive-postgis\n```\n\n## Usage\n\n```js\nconst tilelive = require('@mapbox/tilelive');\nrequire('tilelive-postgis').registerProtocols(tilelive);\n\nconst uri = 'postgis://user:password@localhost:5432/test?table=test_table\u0026geometry_field=geometry\u0026srid=4326';\ntilelive.load(uri, (error, source) =\u003e {\n  if (error) throw error;\n\n  source.getTile(0, 0, 0, (error, tile, headers) =\u003e {\n    // `error` is an error object when generation failed, otherwise null.\n    // `tile` contains the compressed image file as a Buffer\n    // `headers` is a hash with HTTP headers for the image.\n  });\n});\n```\n\nIf PostgreSQL server running locally and accepting connections on Unix domain socket, you can connect like this:\n\n```js\nconst uri = 'postgis:///var/run/postgresql/test?table=test\u0026geometry_field=geom';\ntilelive.load(uri, (error, source) =\u003e { ... });\n```\n\nYou can also use `query` parameter to specify sub-query like this:\n\n```js\nconst query = `(select * from schemaName.tableName where st_intersects(geometry, !bbox!)) as query`;\nconst uri = `postgis://user@localhost/test?table=test_table\u0026geometry_field=geometry\u0026query=${encodeURI(query)}`;\ntilelive.load(uri, (error, source) =\u003e { ... });\n```\n\n## Parameters\n\nThe only parameter that is not mapnik specific is:\n\n| *parameter*       | *value*  | *description* | *default* |\n|:------------------|----------|---------------|----------:|\n| layerName         | string   | name of the layer in resulting tiles. | defaults to the table name for backwards compatibility.|\n\n\nActual list of parameters you can see [here](https://github.com/mapnik/mapnik/wiki/PostGIS).\n\n| *parameter*       | *value*  | *description* | *default* |\n|:------------------|----------|---------------|----------:|\n| table                 | string       | name of the table to fetch. | |\n| geometry_field        | string       | name of the geometry field, in case you have more than one in a single table. This field and the SRID will be deduced from the query in most cases, but may need to be manually specified in some cases.| |\n| geometry_table        | string       | name of the table containing the returned geometry; for determining RIDs with subselects | |\n| srid                  | integer      | srid of the table, if this is \u003e 0 then fetching data will avoid an extra database query for knowing the srid of the table | 0 |\n| extent                | string       | maxextent of the geometries | determined by querying the metadata for the table |\n| extent_from_subquery  | boolean      | evaluate the extent of the subquery, this might be a performance issue | false |\n| connect_timeout       | integer      | timeout is seconds for the connection to take place | 4 |\n| persist_connection    | boolean      | choose whether to share the same connection for subsequent queries | true |\n| row_limit             | integer      | max number of rows to return when querying data, 0 means no limit | 0 |\n| cursor_size           | integer      | if this is \u003e 0 then server cursor will be used, and will prefetch this number of features | 0 |\n| initial_size          | integer      | initial size of the stateless connection pool | 1 |\n| max_size              | integer      | max size of the stateless connection pool | 10 |\n| multiple_geometries   | boolean      | whether to use multiple different objects or a single one when dealing with multi-objects (this is mainly related to how the label are used in the map, one label for a multi-polygon or one label for each polygon of a multi-polygon)| false |\n| encoding              | string       | internal file encoding | utf-8 |\n| simplify_geometries   | boolean      | whether to automatically [reduce input vertices](http://blog.cartodb.com/post/20163722809/speeding-up-tiles-rendering). Only effective when output projection matches (or is similar to) input projection. Available from version 2.1.x up. | false |\n| max_async_connection  | integer       | max number of PostGIS queries for rendering one map in asynchronous mode. Default value (1) has no effect. | 1 |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstepankuzmin%2Ftilelive-postgis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstepankuzmin%2Ftilelive-postgis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstepankuzmin%2Ftilelive-postgis/lists"}