open-index/open-npm huggingface dataset:
npm package: @mapbox/tilelive-mapnik
Description: Mapnik backend for tilelive
Latest version: 1.0.0

# tilelive-mapnik

Renderer backend for [tilelive.js](http://github.com/mapbox/tilelive.js) that
uses [node-mapnik](http://github.com/mapnik/node-mapnik) to render tiles and
grids from a Mapnik XML file. `tilelive-mapnik` implements the
[Tilesource API](https://github.com/mapbox/tilelive.js/blob/master/API.md).

[![Build Status](https://secure.travis-ci.org/mapbox/tilelive-mapnik.png)](http://travis-ci.org/mapbox/tilelive-mapnik)
[![Build status](https://ci.appveyor.com/api/projects/status/6am7la0hiaei8qop)](https://ci.appveyor.com/project/Mapbox/tilelive-mapnik)

## Installation

    npm install tilelive-mapnik

Though `tilelive` is not a dependency of `tilelive-mapnik` you will want to
install it to actually make use of `tilelive-mapnik` through a reasonable
API.


## Usage

```javascript
var tilelive = require('tilelive');
require('tilelive-mapnik').registerProtocols(tilelive);

tilelive.load('mapnik:///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.
});
```

Note that grid generation will only work when there's metadata inside a
`<Parameters>` object in the Mapnik XML.

The key fields are `interactivity_layer` and `interactivity_fields`. See an
[example in the tests](https://github.com/mapbox/tilelive-mapnik/blob/4e9cbf8347eba7c3c2b7e8fd4270ea39f9cc7af5/test/data/test.xml#L6-L7). These `Parameters` are normally added by the application that creates the XML,
in this case [CartoCSS](https://github.com/mapbox/carto/blob/55fbafe0d0e8ec00515c5782a3664c15502f0437/lib/carto/renderer.js#L152-L189)
npm package: @mapbox/tilelive-memcached
Description: memcached wrapping source for tilelive
Latest version: 1.0.1

[![Build Status](https://travis-ci.org/mapbox/tilelive-memcached.png?branch=master)](https://travis-ci.org/mapbox/tilelive-memcached)

tilelive-memcached
------------------
node-tilejson wrapping source for tilelive.

    var options = {
        mode: 'readthrough', // optional, cache mode either 'readthrough' or 'race'
        client: client, // optional, instantiated memcached client
        expires: 600    // optional, object expiration time in seconds
        ttl: 300        // optional, relay mode only, numbe of seconds before an object should be re-checked.
    };
    var TileJSON = require('@mapbox/tilelive-memcached')(options, require('tilejson'));

    new TileJSON( ... )

### Cache modes

Two modes for caching are available.

- **readthrough** hits memcached first and only calls a `get` on the original source if a cache miss occurs.
- **race** always hits both memcached and the original source concurrently. The IO operation that completes fastest will handle the `get` call. After both operations are complete the cache may be updated if the original source's contents have changed.
npm package: @mapbox/tilelive-vector
Description: Vector tile => raster tile backend for tilelive
Latest version: 4.2.0

tilelive-vector
---------------
Implements the tilelive API for rendering mapnik vector tiles to raster images.

[![Build Status](https://secure.travis-ci.org/mapbox/tilelive-vector.png)](http://travis-ci.org/mapbox/tilelive-vector)
[![Coverage Status](https://coveralls.io/repos/mapbox/tilelive-vector/badge.svg?branch=master&service=github)](https://coveralls.io/github/mapbox/tilelive-vector?branch=master)

### new Vector(options, callback)

- *xml*: a Mapnik XML string that will be used to render vector tiles.
- *source*: Optional, a uri string suitable for use with `tilelive.load()`. This is fallback source that will be used if no source is found as part of the Mapnik XML parameters.
- *base*: Optional, basepath for Mapnik map. Defaults to `__dirname`.
- *format*: Optional, target output format. Defaults to `png8:m=h`.
- *scale*: Optional, Mapnik scale factor. Defaults to `1`.

### Code concepts

- *Backend z/x/y*: a request for a raster tile at, say, 3/3/3 does not always mean 3/3/3 is requested from the backend source. The z/x/y requested from the backend source is referred in code by `bz/bx/by` and generally represent the same or lower zoom level. This allows for features like *overzooming*, *maskLevel tiles*, and *scale factor adjustment*.
- *Overzooming*: if a tile beyond the `maxzoom` of the backend is requested, Vector will attempt to render the tile using the parent of the request at `maxzoom`.
- *maskLevel tiles*: to avoid requiring many duplicate or empty vector tiles to be generated at high zoom levels, the backend source can specify a `maskLevel`. If a vector tile is not initially found at some `z > maskLevel`, Vector will issue an additional request to the backend using the parent tile of of the request at `maskLevel`. This allows a lower zoom level to "backfill" high zoom levels.
- *Scale factor adjustment*: the scale argument decrements the backend zoom level such that the requested tile is the visual equivalent (when viewed on the proper dpi device) of its parent counterpart. For example, `scale: 2` decrements `bz` by 1, `scale: 4` decrements by 2, and so on.

### Backend headers

The Backend and Vector sources set the `x-vector-backend-object` header to indicate the type of backend source tile loaded. Possible values:

value | description
--- | ---
empty | backend returned no tile
fillzoom | tile from the fillzoom of the backend (backfilled from a lower zoom)
overzoom | tile from the maxzoom of the backend (overzoomed)
default | normal tile

## Bonus constructors

There are two additional constructors provided for slightly different workflows for loading vector sources.

### Vector.tm2z(uri, callback)

Load a vector source from a `uri` (filepath or HTTP url) to a [tm2](https://github.com/mapbox/tm2)-generated tm2z style package.

### Vector.xray(options, callback)

Load a vector source with autogenerated data inspection ("xray") styles. `xml` is not required -- only the `uri` to a vector source backend is necessary.
npm package: @mapbox/tiletype
Description: detect common map tile formats from a buffer
Author: Mapbox
Latest version: 0.3.1

# tiletype

[![build status](https://secure.travis-ci.org/mapbox/tiletype.png)](http://travis-ci.org/mapbox/tiletype)
[![Coverage Status](https://coveralls.io/repos/mapbox/tiletype/badge.svg?branch=coverage&service=github)](https://coveralls.io/github/mapbox/tiletype?branch=coverage)

detect common map tile formats from a buffer


### `type(buffer)`

Given a buffer of unknown data, return either a format as an extension
string or false if the type cannot be determined.

Potential options are:

* png
* pbf
* jpg
* webp


### Parameters

| parameter | type   | description |
| --------- | ------ | ----------- |
| `buffer`  | Buffer | input       |



**Returns** `String,boolean`, identifier


### `headers(buffer)`

Return headers - Content-Type and Content-Encoding -
for a response containing this kind of image.


### Parameters

| parameter | type   | description |
| --------- | ------ | ----------- |
| `buffer`  | Buffer | input       |



**Returns** `Object`, headers


### `dimensions(buffer, dimensions)`

Determine the width and height of an image contained in a buffer,
returned as a [x, y] array.


### Parameters

| parameter    | type           | description |
| ------------ | -------------- | ----------- |
| `buffer`     | Buffer         | input       |
| `dimensions` | Array\,boolean |             |


## Installation

Requires [nodejs](http://nodejs.org/).

```sh
$ npm install @mapbox/tiletype
```

## Tests

```sh
$ npm test
```