tilelive.js
- Tilelive is a module to help interactions between tilelive source modules.
- A tilelive source is an interface implemented by node modules that deal with reading and writing map tiles.
Awesome tilelive modules
- tilelive-vector - Implements the tilelive API for rendering mapnik vector tiles to raster images.
- tilelive-bridge - Implements the tilelive API for generating mapnik vector tiles from traditional mapnik datasources.
- tilelive-mapnik - mapnik renderer backend for tilelive.
- tilelive-s3 - Extends TileJSON for S3-specific tasks.
- tilelive-file - tilelive.js adapter for reading from the filesystem.
- tilelive-tmsource - A tilelive provider for TM2 sources.
- tilelive-cache - A caching wrapper for tilelive.js
- tilelive-overlay - Render GeoJSON features with simplestyle styles in a tilelive pipeline.
- tilelive-tmstyle - A tilelive provider for tmstyle sources.
- tilelive-http - An HTTP source for tilelive.
- node-mbtiles - A mbtiles renderer and storage backend for tilelive.
- tl - An alternate command line interface to tilelive.
- tilelive-omnivore - Implements the tilelive api for a variety of data sources.
- tilelive-xray - Tilelive vector tile visualization.
- tilelive-merge - A tilelive source that merges sources.
- tilelive-streaming - Streaming functionality for tilelive modules.
- tilelive-redis - Redis wrapping source for tilelive.
- tilelive-modules - A listing of known tilelive modules.
- tilelive-decorator - Load vector tiles from a tilelive source and decorate them with properties from redis.
- tilelive-blend - A tilelive provider that blends.
- tilelive-carto - A Carto style source for tilelive
- mongotiles - mongotiles is a tilelive backend plug-in for MongoDB GridFS.
- tilelive-rasterpbf - A tilelive source for outputting PBF-encoded rasters from PostGIS.
- tilelive-memcached - A memcached wrapping source for tilelive.
- tilelive-csvin - A streaming tilelive source for CSV inputs.
- tilelive-tms - A tilelive.js adapter for reading from a TMS service.
- tilelive-multicache - Module for adding a caching layer in front a tilelive source.
- tilelive-cardboard - Renders vector tiles from a cardboard dataset.
- tilelive-utfgrid - A tilelive provider that treats grids as tiles
- tilelive-arcgis - A tilelive.js adapter for ArcGIS tile caches.
- tilelive-mapbox - A tilelive.js source for mapbox:// URIs.
- tilelive-solid - A tilelive provider that generates solid colored tiles.
- tilelive-raster - A tilelive source for simple rasters, both local and remote.
- tilelive-null - A noop sink for tilelive.
- tilelive-noop - A no-op tilelive source.
- tilelive-csv - PBF → CSV with tilelive.
- tilelive-error - Avoid repeating error-prone initialization.
- tilelive-lambda - AWS Lambda source for tilelive.
- tilelive-cartodb - A tilelive source for CartoDB.
- cdbtiles - A tilelive backend plug-in for CouchDB.
- node-tilejson - Tile source backend for online tile sources.
- tilelive-foxgis - A tilelive plugin to serve tiles with mongodb
- tessera - A tilelive-based tile server.
Ecosytem of tilelive
Usage
Tilelive doesn't ship with any implementing modules by default. To register a module as one tilelive recognizes:
require('[implementation]').registerProtocols(tilelive);
tilelive.list(source, callback)
: Lists all tilesets in a directory.source
is a folder that is used by registered implementations to search for individual tilesets.callback
receives an error object (ornull
) and a hash hash with keys being Tilestore IDs and values being Tilestore URIs. Example:
"world-light": "mbtiles:///path/to/file/world-light.mbtiles" "mapquest": "tilejson:///path/to/file/mapquest.tilejson"
-
tilelive.findID(source, id, callback)
: Looks for a particular tileset ID in a directory.callback
receives an error object (ornull
) and the URI of the tileset. -
tilelive.load(uri, callback)
: Loads the Tilestore object associated with the specifieduri
.callback
receives an error object (ornull
) and the Tilestore object. -
tilelive.info(uri, callback)
: Loads the Tilestore object associated with the specifieduri
and retrieves its metadata in a TileJSON compliant format.callback
receives an error object (ornull
), the metadata hash and the Tilestore object. -
tilelive.all(source, callback)
: Loads metadata in a TileJSON compliant format for all tilesets in thesource
directory.callback
receives an error object (ornull
) and an array with TileJSON metadata about each tileset in that directory. -
tilelive.verify(tilejson)
: Validates a TileJSON object and returns error objects for invalid entries.
Read/write streams
Tilelive provides an implementation of node object streams for copying tiles from one source to another.
// Copy all tiles and metadata from source A to source B.
var get = tilelive.createReadStream(sourceA);
var put = tilelive.createWriteStream(sourceB);
get.pipe(put);
put.on('finish', function() {
console.log('done!');
});
See tilelive-copy
and the streams tests for example usage of copy streams.
Parallel read streams
Tilelive can split a read operation into an arbitrary number of jobs. Pass a job
parameter to options when using tilelive.createReadStream
or tilelive.deserialize
:
var readable = tilelive;
This instructs tilelive to only read tiles that would fall into job 1
of 4
. A complete read would mean four calls each with a different num
.
bin/tilelive-copy
tilelive can be used to copy data between tilestores. For a full list of options, run tilelive-copy
.
Tests
To run the tests
npm test