diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml new file mode 100644 index 0000000..c633be7 --- /dev/null +++ b/.github/workflows/node.js.yml @@ -0,0 +1,33 @@ +# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions + +name: Node.js CI + +on: + push: + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Use Node.js + uses: actions/setup-node@v1 + with: + node-version: 12.x + - run: npm ci + env: + NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} + - run: npm run extract + - name: configure git and deploy + env: + NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} + run: | + git config --global user.name "nakuruwater+githubci" + git config --global user.email "nakuruwater+githubci@users.noreply.github.com" + git remote set-url origin https://x-access-token:${NODE_AUTH_TOKEN}@github.com/nakuruwater/vt.git + npm run deploy + diff --git a/README.md b/README.md index 91962ef..23fdbd5 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ # vt-boilerplate -![](https://github.com/narwassco/vt/workflows/Node.js%20CI/badge.svg) -![GitHub](https://img.shields.io/github/license/watergis/vt-boilerplate) +![](https://github.com/nakuruwater/vt/workflows/Node.js%20CI/badge.svg) +![GitHub](https://img.shields.io/github/license/nakuruwater/vt) ![Docker Cloud Automated build](https://img.shields.io/docker/cloud/automated/narwassco/vt) ![Docker Image Size (latest by date)](https://img.shields.io/docker/image-size/narwassco/vt) -This is a template to manage vectortiles for water services providers in Github pages. You can create your own `vt` repository by using this template repository. +This is a template to manage vectortiles for Nakuru Water in Github pages. You can create your own `vt` repository by using this template repository. Please also refer to [watergis/awesome-vector-tiles](https://github.com/watergis/awesome-vector-tiles). There is some instruction guide how to use tools and host your vectortiles in Github pages as open data. @@ -137,8 +137,8 @@ jobs: This source code under the repository is licensed by `MIT license`. You can use it freely for your purposes. -However, these data under [data](./data) and `gh-pages` branch are owned and maintained by `{your organization name}` in Kenya. It is under a [Creative Commons Attribution 4.0 International -License](http://creativecommons.org/licenses/by/4.0/), which is different from main repository. You can use this data freely, but please mention our credit `©{your organization name}` on attribution of your web application. +However, these data under [data](./data) and `gh-pages` branch are owned and maintained by `Nakuru Water and Sanitation Services Company (NAWASSCO)` in Kenya. It is under a [Creative Commons Attribution 4.0 International +License](http://creativecommons.org/licenses/by/4.0/), which is different from main repository. You can use this data freely, but please mention our credit `©NARWASSCO,Ltd.` on attribution of your web application. --- Copyright (c) 2020 Jin IGARASHI \ No newline at end of file diff --git a/config-extract.js b/config-extract.js index 6af2065..176d5c2 100644 --- a/config-extract.js +++ b/config-extract.js @@ -2,5 +2,5 @@ module.exports = { ghpages:{ tiles: __dirname + '/public/tiles' }, - mbtiles: __dirname + '/data/data.mbtiles', + mbtiles: __dirname + '/data/nakuru.mbtiles', } \ No newline at end of file diff --git a/config-search.js b/config-search.js index 9b0aa19..f70d7dd 100644 --- a/config-search.js +++ b/config-search.js @@ -6,12 +6,12 @@ module.exports = { password:process.env.db_password, host:process.env.db_host, post:process.env.db_port, - database:'{your database name}', + database:'nawassco_restored_13_11_2019', }, layers : [ { - name: 'meter', - geojsonFileName: __dirname + '/public/meter.geojson', + name: 'accounts', + geojsonFileName: __dirname + '/public/accounts.geojson', select:` SELECT row_to_json(featurecollection) AS json FROM ( SELECT @@ -20,26 +20,17 @@ module.exports = { FROM ( SELECT 'Feature' AS type, - ST_AsGeoJSON(ST_TRANSFORM(x.geom,4326))::json AS geometry, + ST_AsGeoJSON(ST_SetSRID(geom,4326))::json AS geometry, row_to_json(( SELECT p FROM ( SELECT - x.meterid as fid, - CASE WHEN x.connno=-1 THEN NULL ELSE LPAD(CAST(x.connno as text), 4, '0') || x.zonecd END as connno, - x.serialno, - b.name as customer, - c.name as village + gid as fid, + accountno, + serino as serialno ) AS p )) AS properties - FROM meter x - INNER JOIN metertype a - ON x.metertypeid = a.metertypeid - LEFT JOIN customer b - ON x.zonecd = b.zonecd - AND x.connno = b.connno - LEFT JOIN village c - on b.villageid = c.villageid - WHERE NOT ST_IsEmpty(x.geom) AND x.metertypeid = 1 + FROM accounts + WHERE NOT ST_IsEmpty(geom) ) AS feature ) AS featurecollection ` diff --git a/config.js b/config.js index ca04f95..5fa1585 100644 --- a/config.js +++ b/config.js @@ -6,10 +6,10 @@ module.exports = { password:process.env.db_password, host:process.env.db_host, post:process.env.db_port, - database:'{your database name}', + database:'nawassco_restored_13_11_2019', }, - mbtiles: __dirname + '/data/data.mbtiles', - minzoom: 10, + mbtiles: __dirname + '/data/nakuru.mbtiles', + minzoom: 8, maxzoom: 16, layers : [ { @@ -23,7 +23,7 @@ module.exports = { FROM ( SELECT 'Feature' AS type, - ST_AsGeoJSON(ST_TRANSFORM(ST_MakeValid(x.geom),4326))::json AS geometry, + ST_AsGeoJSON(ST_SetSRID(ST_MakeValid(geom),4326))::json AS geometry, row_to_json(( SELECT t FROM ( SELECT @@ -34,29 +34,27 @@ module.exports = { row_to_json(( SELECT p FROM ( SELECT - x.pipeid as fid, - a.name as pipetype, - x.pipesize, - b.name as material, - x.constructiondate, - x.insertdate, - x.updatedate, - x."Town" + gid as fid, + purpose, + size, + material_1 as material, + class as pipe_class, + instal_yr as installation_year, + contractor, + imp_status, + remarks, + status_ as status ) AS p )) AS properties - FROM pipenet x - INNER JOIN pipetype a - ON x.pipetypeid = a.pipetypeid - INNER JOIN material b - ON x.materialid = b.materialid - WHERE NOT ST_IsEmpty(x.geom) + FROM pipeline + WHERE NOT ST_IsEmpty(geom) ) AS feature ) AS featurecollection ` }, { - name: 'meter', - geojsonFileName: __dirname + '/meter.geojson', + name: 'accounts', + geojsonFileName: __dirname + '/accounts.geojson', select:` SELECT row_to_json(featurecollection) AS json FROM ( SELECT @@ -65,7 +63,421 @@ module.exports = { FROM ( SELECT 'Feature' AS type, - ST_AsGeoJSON(ST_TRANSFORM(x.geom,4326))::json AS geometry, + ST_AsGeoJSON(ST_SetSRID(geom,4326))::json AS geometry, + row_to_json(( + SELECT t FROM ( + SELECT + 16 as maxzoom, + 15 as minzoom + ) AS t + )) AS tippecanoe, + row_to_json(( + SELECT p FROM ( + SELECT + gid as fid, + accountno, + unit, + serinostat as serial_no_status, + serino as serial_no, + size, + mtrbrd, + status, + install, + remarks_an + ) AS p + )) AS properties + FROM accounts + WHERE NOT ST_IsEmpty(geom) + ) AS feature + ) AS featurecollection + ` + }, + { + name: 'toilets', + geojsonFileName: __dirname + '/toilets.geojson', + select:` + SELECT row_to_json(featurecollection) AS json FROM ( + SELECT + 'FeatureCollection' AS type, + array_to_json(array_agg(feature)) AS features + FROM ( + SELECT + 'Feature' AS type, + ST_AsGeoJSON(ST_SetSRID(geom,4326))::json AS geometry, + row_to_json(( + SELECT t FROM ( + SELECT + 16 as maxzoom, + 15 as minzoom + ) AS t + )) AS tippecanoe, + row_to_json(( + SELECT p FROM ( + SELECT + gid as fid, + type, + connection, + toilets, + project + ) AS p + )) AS properties + FROM toilets + WHERE NOT ST_IsEmpty(geom) + ) AS feature + ) AS featurecollection + ` + }, + { + name: 'public_toilet', + geojsonFileName: __dirname + '/public_toilet.geojson', + select:` + SELECT row_to_json(featurecollection) AS json FROM ( + SELECT + 'FeatureCollection' AS type, + array_to_json(array_agg(feature)) AS features + FROM ( + SELECT + 'Feature' AS type, + ST_AsGeoJSON(ST_SetSRID(geom,4326))::json AS geometry, + row_to_json(( + SELECT t FROM ( + SELECT + 16 as maxzoom, + 12 as minzoom + ) AS t + )) AS tippecanoe, + row_to_json(( + SELECT p FROM ( + SELECT + gid as fid, + name, + operatedby + ) AS p + )) AS properties + FROM public_toilet + WHERE NOT ST_IsEmpty(geom) + ) AS feature + ) AS featurecollection + ` + }, + { + name: 'bulkmeter', + geojsonFileName: __dirname + '/nawassco_blkmtr.geojson', + select:` + SELECT row_to_json(featurecollection) AS json FROM ( + SELECT + 'FeatureCollection' AS type, + array_to_json(array_agg(feature)) AS features + FROM ( + SELECT + 'Feature' AS type, + ST_AsGeoJSON(ST_SetSRID(geom,4326))::json AS geometry, + row_to_json(( + SELECT t FROM ( + SELECT + 16 as maxzoom, + 12 as minzoom + ) AS t + )) AS tippecanoe, + row_to_json(( + SELECT p FROM ( + SELECT + gid as fid, + size, + type, + dma, + install_yr as installation_year, + status, + zone, + location, + meter_type, + metered, + util_name, + serial_no, + material, + route + ) AS p + )) AS properties + FROM nawassco_blkmtr + WHERE NOT ST_IsEmpty(geom) + ) AS feature + ) AS featurecollection + ` + }, + { + name: 'man_holes', + geojsonFileName: __dirname + '/man_holes.geojson', + select:` + SELECT row_to_json(featurecollection) AS json FROM ( + SELECT + 'FeatureCollection' AS type, + array_to_json(array_agg(feature)) AS features + FROM ( + SELECT + 'Feature' AS type, + ST_AsGeoJSON(ST_SetSRID(geom,4326))::json AS geometry, + row_to_json(( + SELECT t FROM ( + SELECT + 16 as maxzoom, + 14 as minzoom + ) AS t + )) AS tippecanoe, + row_to_json(( + SELECT p FROM ( + SELECT + gid as fid, + name, + cmt, + manhole__2, + manhole_10, + mh_materia, + cover_mate, + featuremat, + owner, + year, + covershape, + covermate, + cover_shap, + depth_in_1, + year_of_co, + depth_ft_, + pipe_inch_, + pipemat, + yearconstr, + feature__2, + cover_ma_1, + cover_sh_1, + depth, + year_of__1, + mh_id, + typeshape, + pic_id, + mh_shape, + mh_cover + ) AS p + )) AS properties + FROM man_holes + WHERE NOT ST_IsEmpty(geom) + ) AS feature + ) AS featurecollection + ` + }, + { + name: 'boreholes', + geojsonFileName: __dirname + '/boreholes.geojson', + select:` + SELECT row_to_json(featurecollection) AS json FROM ( + SELECT + 'FeatureCollection' AS type, + array_to_json(array_agg(feature)) AS features + FROM ( + SELECT + 'Feature' AS type, + ST_AsGeoJSON(ST_SetSRID(geom,4326))::json AS geometry, + row_to_json(( + SELECT t FROM ( + SELECT + 16 as maxzoom, + 12 as minzoom + ) AS t + )) AS tippecanoe, + row_to_json(( + SELECT p FROM ( + SELECT + gid as fid, + location, + "borehole n" as no_borehole, + status, + ownership, + "yield (m3/" as yield_m3, + "power sour" as power_sour, + "year drill" as year_drill, + "target are" as target, + "pumping ho" as pumping_ho, + depth, + pmp_outlet, + pump_sz, + pmp_typ, + m_serial, + p_serial, + p_make, + m_make, + p_model, + m_model, + m_rating, + p_rating, + p_head, + m_yr_inst, + p_yr_inst, + remarks, + drop_pp_d, + "dsgncap(m3" as design_capacity_m3 + ) AS p + )) AS properties + FROM boreholes + WHERE NOT ST_IsEmpty(geom) + ) AS feature + ) AS featurecollection + ` + }, + { + name: 'pump_stations', + geojsonFileName: __dirname + '/pump_stations.geojson', + select:` + SELECT row_to_json(featurecollection) AS json FROM ( + SELECT + 'FeatureCollection' AS type, + array_to_json(array_agg(feature)) AS features + FROM ( + SELECT + 'Feature' AS type, + ST_AsGeoJSON(ST_SetSRID(geom,4326))::json AS geometry, + row_to_json(( + SELECT t FROM ( + SELECT + 16 as maxzoom, + 12 as minzoom + ) AS t + )) AS tippecanoe, + row_to_json(( + SELECT p FROM ( + SELECT + gid as fid, + name, + source + ) AS p + )) AS properties + FROM pump_stations + WHERE NOT ST_IsEmpty(geom) + ) AS feature + ) AS featurecollection + ` + }, + { + name: 'reservoirs', + geojsonFileName: __dirname + '/reservoirs.geojson', + select:` + SELECT row_to_json(featurecollection) AS json FROM ( + SELECT + 'FeatureCollection' AS type, + array_to_json(array_agg(feature)) AS features + FROM ( + SELECT + 'Feature' AS type, + ST_AsGeoJSON(ST_SetSRID(geom,4326))::json AS geometry, + row_to_json(( + SELECT t FROM ( + SELECT + 16 as maxzoom, + 12 as minzoom + ) AS t + )) AS tippecanoe, + row_to_json(( + SELECT p FROM ( + SELECT + gid as fid, + name, + type, + capacity, + "material m" as material, + installati as installation, + "areas serv" as area_serve, + "inlet pp s" as inlet_pipe, + "outlet pp" as outlet_pipe, + "height of" as height, + "ground ele" as elevation, + shape, + descriptio + ) AS p + )) AS properties + FROM reservoirs + WHERE NOT ST_IsEmpty(geom) + ) AS feature + ) AS featurecollection + ` + }, + { + name: 'waterworks', + geojsonFileName: __dirname + '/waterworks.geojson', + select:` + SELECT row_to_json(featurecollection) AS json FROM ( + SELECT + 'FeatureCollection' AS type, + array_to_json(array_agg(feature)) AS features + FROM ( + SELECT + 'Feature' AS type, + ST_AsGeoJSON(ST_SetSRID(ST_MakeValid(geom),4326))::json AS geometry, + row_to_json(( + SELECT t FROM ( + SELECT + 16 as maxzoom, + 8 as minzoom + ) AS t + )) AS tippecanoe, + row_to_json(( + SELECT p FROM ( + SELECT + gid as fid, + name, + source, + des_capcty as design_capacity, + oper_capct as operation_capacity + ) AS p + )) AS properties + FROM water_twrks + WHERE NOT ST_IsEmpty(geom) + ) AS feature + ) AS featurecollection + ` + }, + { + name: 'plots', + geojsonFileName: __dirname + '/plots.geojson', + select:` + SELECT row_to_json(featurecollection) AS json FROM ( + SELECT + 'FeatureCollection' AS type, + array_to_json(array_agg(feature)) AS features + FROM ( + SELECT + 'Feature' AS type, + ST_AsGeoJSON(ST_SetSRID(geom,4326))::json AS geometry, + row_to_json(( + SELECT t FROM ( + SELECT + 16 as maxzoom, + 15 as minzoom + ) AS t + )) AS tippecanoe, + row_to_json(( + SELECT p FROM ( + SELECT + gid as fid, + plotnr, + plot, + block + ) AS p + )) AS properties + FROM plots + WHERE NOT ST_IsEmpty(geom) + ) AS feature + ) AS featurecollection + ` + }, + { + name: 'plots_annotation', + geojsonFileName: __dirname + '/plots_annotation.geojson', + select:` + SELECT row_to_json(featurecollection) AS json FROM ( + SELECT + 'FeatureCollection' AS type, + array_to_json(array_agg(feature)) AS features + FROM ( + SELECT + 'Feature' AS type, + ST_AsGeoJSON(ST_SetSRID(ST_CENTROID(geom),4326))::json AS geometry, row_to_json(( SELECT t FROM ( SELECT @@ -75,31 +487,98 @@ module.exports = { )) AS tippecanoe, row_to_json(( SELECT p FROM ( + SELECT + gid as fid, + plotnr, + plot, + block + ) AS p + )) AS properties + FROM plots + WHERE NOT ST_IsEmpty(geom) + ) AS feature + ) AS featurecollection + ` + }, + { + name: 'zones', + geojsonFileName: __dirname + '/zones.geojson', + select:` + SELECT row_to_json(featurecollection) AS json FROM ( + SELECT + 'FeatureCollection' AS type, + array_to_json(array_agg(feature)) AS features + FROM ( + SELECT + 'Feature' AS type, + ST_AsGeoJSON(ST_SetSRID(geom,4326))::json AS geometry, + row_to_json(( + SELECT t FROM ( SELECT - x.meterid as fid, - a.name as metertype, - x.pipesize as diameter, - x.zonecd, - CASE WHEN x.connno=-1 THEN NULL ELSE LPAD(CAST(x.connno as text), 4, '0') END as connno, - x.installationdate, - b.status, - x.serialno, - b.name as customer, - c.name as village, - x.insertdate, - x.updatedate, - x.isgrantprj as isjica + 16 as maxzoom, + 8 as minzoom + ) AS t + )) AS tippecanoe, + row_to_json(( + SELECT p FROM ( + SELECT + gid, + area, + perimeter, + zone, + zn_id + ) AS p + )) AS properties + FROM zones + WHERE NOT ST_IsEmpty(geom) + ) AS feature + ) AS featurecollection + ` + }, + { + name: 'point_annotation', + geojsonFileName: __dirname + '/point_annotation.geojson', + select:` + WITH annotations AS( + SELECT + gid as masterid, + name, + 'waterworks' as layer, + ST_CENTROID(geom) as geom + FROM water_twrks + UNION ALL + SELECT + gid as masterid, + zone, + 'zones' as layer, + ST_CENTROID(geom) as geom + FROM zones + ) + SELECT row_to_json(featurecollection) AS json FROM ( + SELECT + 'FeatureCollection' AS type, + array_to_json(array_agg(feature)) AS features + FROM ( + SELECT + 'Feature' AS type, + ST_AsGeoJSON(ST_SetSRID(geom,4326))::json AS geometry, + row_to_json(( + SELECT t FROM ( + SELECT + 16 as maxzoom, + 8 as minzoom + ) AS t + )) AS tippecanoe, + row_to_json(( + SELECT p FROM ( + SELECT + masterid, + name, + layer ) AS p )) AS properties - FROM meter x - INNER JOIN metertype a - ON x.metertypeid = a.metertypeid - LEFT JOIN customer b - ON x.zonecd = b.zonecd - AND x.connno = b.connno - LEFT JOIN village c - on b.villageid = c.villageid - WHERE NOT ST_IsEmpty(x.geom) AND x.metertypeid = 1 + FROM annotations + WHERE NOT ST_IsEmpty(geom) ) AS feature ) AS featurecollection ` diff --git a/package.json b/package.json index 6ea0779..a1aed44 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "vt", "version": "1.0.0", - "description": "This is to manage vectortiles for water services providers in Github pages.", + "description": "This is to manage vectortiles for Nakuru Water in Github pages.", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", @@ -12,7 +12,7 @@ }, "repository": { "type": "git", - "url": "git+https://github.com/watergis/vt-boilerplate.git" + "url": "git+https://github.com/nakuruwater/vt.git" }, "keywords": [ "tippecanoe", @@ -23,9 +23,9 @@ "author": "Jin IGARASHI", "license": "MIT", "bugs": { - "url": "https://github.com/watergis/vt-boilerplate/issues" + "url": "https://github.com/nakuruwater/vt/issues" }, - "homepage": "https://github.com/watergis/vt-boilerplate#readme", + "homepage": "https://github.com/nakuruwater/vt#readme", "dependencies": { "@watergis/mbtiles2pbf": "^0.2.1", "@watergis/postgis2mbtiles": "^0.1.4", diff --git a/public/README.md b/public/README.md index 8249230..09b1cd5 100644 --- a/public/README.md +++ b/public/README.md @@ -1,12 +1,12 @@ # Vector Tile Map -This is to provide the water supply network data through Mapbox Vector Tile format which is owned by `{your organization name}` in Kenya. +This is to provide the water supply network data through Mapbox Vector Tile format which is owned by `Nakuru Water and Sanitation Services Co., Ltd.` in Kenya. ## Usage Vector tile URL ``` -https://narwassco.github.io/vt/tiles/{z}/{x}/{y}.mvt +https://nakuruwater.github.io/vt/tiles/{z}/{x}/{y}.mvt ``` ## License @@ -24,4 +24,4 @@ License][cc-by]. --- -Copyright (c) 2020 Jin IGARASHI +Copyright (c) 2020 Nakuru Water and Sanitation Services Co., Ltd.