# vector-tiles-generator

> ## installation ``` yarn add vector-tiles-generator ```

Latest version **0.1.0** (published 2018-07-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install vector-tiles-generator
pnpm add vector-tiles-generator
yarn add vector-tiles-generator
bun add vector-tiles-generator
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2018-07-18 |
| First published | 2017-10-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 6.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Philippe Auriach |
| Maintainers | philippeauriach |

## Links

- npm: https://www.npmjs.com/package/vector-tiles-generator
- npm.io page: https://npm.io/package/vector-tiles-generator

## Dependencies (3)

- [vt-pbf](https://npm.io/package/vt-pbf.md) 3.1.1
- [geojson-vt](https://npm.io/package/geojson-vt.md) 3.1.4
- [@mapbox/sphericalmercator](https://npm.io/package/@mapbox/sphericalmercator.md) 1.1.0

## Recent versions

- 0.1.0 (latest) — 2018-07-18
- 0.0.2 — 2017-10-06
- 0.0.1 — 2017-10-04

## README

# vector-tiles-generator

## installation
```
yarn add vector-tiles-generator
```

## usage with express
```JavaScript
var VectorTileGenerator = require('vector-tiles-generator');

// initialize once your generator
var vectorTileGenerator = new VectorTileGenerator({
  pgPool: pool // you must provide your own pg-pool
});

app.get('/layer/:z/:x/:y.mvt', function(req, res) {
  var tile = {
    x: parseInt(req.params.x),
    y: parseInt(req.params.y),
    z: parseInt(req.params.z)
  };

  // nothing before zoom level 9
  if(tile.z < 9) {
    return res.status(204).send();  // 204 empty status for mapbox
  }

  return vectorTileGenerator.get({
    points: `SELECT name, ST_AsGeoJSON(ST_Transform(way, 4326)) as the_geom_geojson
              FROM planet_osm_polygon WHERE way && !bbox!`  // !bbox! will be replaced
  }, tile)
  .then(function(result) {
    if(!result || result.length === 0) {
      return res.status(204).send();  // handle empty status for mapbox
    }
    return res.send(result);
  });
});
```

---
_Source: https://npm.io/package/vector-tiles-generator · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
