{"id":13597913,"url":"https://github.com/watergis/postgis2vectortiles","last_synced_at":"2025-11-01T13:30:32.611Z","repository":{"id":109406657,"uuid":"280853099","full_name":"watergis/postgis2vectortiles","owner":"watergis","description":"This is a simple tool to create Mapbox Vectortiles under particular directory from PostGIS database","archived":false,"fork":false,"pushed_at":"2023-06-22T14:42:28.000Z","size":115,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-30T05:43:06.639Z","etag":null,"topics":["mbtiles","postgis","vectortiles"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/watergis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null},"funding":{"github":["JinIgarashi"],"open_collective":"watergis","custom":["https://www.paypal.me/jinigarashi"]}},"created_at":"2020-07-19T11:39:51.000Z","updated_at":"2023-06-28T16:14:08.000Z","dependencies_parsed_at":null,"dependency_job_id":"eeed9e64-bb72-4f1d-b65b-4d759f0a6d95","html_url":"https://github.com/watergis/postgis2vectortiles","commit_stats":{"total_commits":14,"total_committers":1,"mean_commits":14.0,"dds":0.0,"last_synced_commit":"e168a68fab40c2cf23f32d30f5145f4279f8f112"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/watergis%2Fpostgis2vectortiles","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/watergis%2Fpostgis2vectortiles/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/watergis%2Fpostgis2vectortiles/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/watergis%2Fpostgis2vectortiles/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/watergis","download_url":"https://codeload.github.com/watergis/postgis2vectortiles/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239156197,"owners_count":19591077,"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":["mbtiles","postgis","vectortiles"],"created_at":"2024-08-01T17:00:43.372Z","updated_at":"2025-11-01T13:30:32.568Z","avatar_url":"https://github.com/watergis.png","language":"JavaScript","funding_links":["https://github.com/sponsors/JinIgarashi","https://opencollective.com/watergis","https://www.paypal.me/jinigarashi"],"categories":["Lincense","3. Deploy Vector Tile to gh-pages"],"sub_categories":["1. Source Code"],"readme":"# postgis2vectortiles\n![](https://github.com/watergis/postgis2vectortiles/workflows/Node.js%20Package/badge.svg)\n![GitHub](https://img.shields.io/github/license/watergis/postgis2vectortiles)\n\nThis is a simple tool to create Mapbox Vectortiles under particular directory from PostGIS database\n\n## Installation\n### tippecanoe\nThis module uses [`tippecanoe`](https://github.com/mapbox/tippecanoe) to convert geojson files to mbtiles. Please make sure to install it before running.\n\nfor MacOS\n```\n$ brew install tippecanoe\n```\n\nfor Ubuntu\n```\n$ git clone https://github.com/mapbox/tippecanoe.git\n$ cd tippecanoe\n$ make -j\n$ make install\n```\n\n### main module\n```\nnpm install @watergis/postgis2vectortiles\n```\n\n## Usage\nSee also [test.js](./test/test.js)\n```js\nconst {postgis2vectortiles} = require('@watergis/postgis2vectortiles');\nconst config = require('./config');\n\nconst pg2vt = new postgis2vectortiles(config);\npg2vt.create('./tiles', '.mvt')\n.then(res=\u003e{\n    console.log(res);\n}).catch(err=\u003e{\n    console.log(err);\n})\n```\nThis module will create vectortiles (.mvt or .pbf) under specific directory from your PostGIS database.\n\n## Configuration\n\n### Dababase Connection\nPlease put your PostGIS database settings as follow under `config.js`.\n```js\ndb: {\n    user:'postgres',\n    password:'Your password',\n    host:'localhost',\n    port:5432,\n    database:'Your database name',\n},\n```\n\n### mbtiles's Setting\n```js\nmbtiles: __dirname + '/narok.mbtiles',\n```\n\n### Layers' Setting\n```js\nlayers: [\n    //Put your layer definition here.\n    ]\n```\n\nEach layer definition should include the following information.\nThe below is just an example of Pipeline Layer.\n```js\n    name: 'pipeline', //Layer Name\n    geojsonFileName: __dirname + '/pipeline.geojson', //Temporary working file path\n    //The following SQL is the most important one which is able to extract PostGIS data as GeoJSON format.\n    select: `\n    SELECT row_to_json(featurecollection) AS json FROM (\n        SELECT\n            'FeatureCollection' AS type,\n            array_to_json(array_agg(feature)) AS features\n        FROM (\n            SELECT\n            'Feature' AS type,\n            ST_AsGeoJSON(ST_TRANSFORM(ST_MakeValid(x.geom),4326))::json AS geometry,\n            row_to_json((\n                SELECT p FROM (\n                SELECT\n                    x.pipeid as fid,\n                    a.name as pipetype,\n                    x.pipesize,\n                    b.name as material,\n                    x.constructiondate,\n                    x.insertdate,\n                    x.updatedate,\n                    x.isjica\n                ) AS p\n            )) AS properties\n            FROM pipenet x\n            INNER JOIN pipetype a\n            ON x.pipetypeid = a.pipetypeid\n            INNER JOIN material b\n            ON x.materialid = b.materialid\n            WHERE NOT ST_IsEmpty(x.geom)\n        ) AS feature\n        ) AS featurecollection\n    `\n},\n```\n\n```\ncopyright (c) 2020 Jin IGARASHI\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwatergis%2Fpostgis2vectortiles","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwatergis%2Fpostgis2vectortiles","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwatergis%2Fpostgis2vectortiles/lists"}