Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mapbox/tilelive-bridge
Implements the tilelive API for generating mapnik vector tiles from traditional mapnik datasources.
https://github.com/mapbox/tilelive-bridge
Last synced: 25 days ago
JSON representation
Implements the tilelive API for generating mapnik vector tiles from traditional mapnik datasources.
- Host: GitHub
- URL: https://github.com/mapbox/tilelive-bridge
- Owner: mapbox
- License: bsd-3-clause
- Created: 2013-03-15T17:32:16.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2020-12-01T02:07:43.000Z (about 4 years ago)
- Last Synced: 2024-11-04T20:05:29.528Z (about 1 month ago)
- Language: JavaScript
- Size: 8.94 MB
- Stars: 63
- Watchers: 130
- Forks: 46
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-vector-tiles - tilelive-bridge - Implements [Tilelive API](https://github.com/mapbox/tilelive.js/blob/master/API.md) for creating vector tiles from traditional Mapnik datasources in Node.js. (Parsers & Generators)
README
tilelive-bridge
---------------
Implements the tilelive API for generating mapnik vector tiles from traditional mapnik datasources.[![Build Status](https://travis-ci.com/mapbox/tilelive-bridge.svg?branch=master)](http://travis-ci.com/mapbox/tilelive-bridge)
### new Bridge(options, callback)
- *xml*: a Mapnik XML string that will be used to generate vector tiles.
- *base*: Optional, basepath for Mapnik map. Defaults to `__dirname`.## Installation
npm install @mapbox/tilelive-bridge
Though `tilelive` is not a dependency of `tilelive-bridge` you will want to
install it to actually make use of `tilelive-bridge` through a reasonable
API.## Usage
```javascript
var tilelive = require('tilelive');
require('@mapbox/tilelive-bridge').registerProtocols(tilelive);tilelive.load('bridge:///path/to/file.xml', function(err, source) {
if (err) throw err;// Interface is in XYZ/Google coordinates.
// Use `y = (1 << z) - 1 - y` to flip TMS coordinates.
source.getTile(0, 0, 0, function(err, tile, headers) {
// `err` is an error object when generation failed, otherwise null.
// `tile` contains the compressed image file as a Buffer
// `headers` is a hash with HTTP headers for the image.
});// The `.getGrid` is implemented accordingly.
});
```### Limiting tile sizes
You can set a limit to the size of vector tiles created (in bytes) by setting the `BRIDGE_MAX_VTILE_BYTES_COMPRESSED=n` environment variable. If a tile is generated and larger than the threshold, the process will return `Tile >= max allowed size` as an error.
If you'd like to get statistics about tiles above a certain byte size (before limiting with the above), you can provide the `BRIDGE_LOG_MAX_VTILE_BYTES_COMPRESSED=n` environment variable in your tilelive-driven application and this will generate a stats object on you file system named `tilelive-bridge-stats.json` which includes the average tile size, the maximum tile size, and the number of tiles greater than the threshold set with the environment variable.