Giter VIP home page Giter VIP logo

tilelive's Introduction

tilelive.js

Build Status Coverage Status

Tilelive is designed for streaming map tiles from sources (like custom geographic data formats) to sinks (destinations, like file systems) by providing a consistent API. This repository enables the interaction between sources and sinks and is meant to be used in tandem with at least one Tilelive plugin. Tilelive plugins (modules) follow a consistent architecture (defined in API.md) and implement the logic for generating and reading map tiles from a source or putting map tiles to a destination, or both.

An example of a plugin that implements both reading (can be a source) and writing (can be a sink) is tilelive-s3.

An example use case for tilelive is creating vector tiles from a geojson file and putting them to Amazon S3. This can be accomplished by using tilelive-omnivore as the source and using tilelive-s3 as the sink. Tilelive omnivore performs special operations for generating map tiles (using mapnik), whereas tilelive-s3 is able to properly connect to Amazon S3 for putting tiles in their proper location. The Tilelive module performs all of the getting and putting within tilelive.copy.

Basic tilelive steps:

  1. Require tilelive in your script, var tilelive = require('@mapbox/tilelive')
  2. Register custom protocols via plugins, CustomTileSourcePlugin.registerProtocols(tilelive) or CustomTileSinkPlugin.registerProtocols(tilelive)
  3. Load protocols using tilelive.load, this creates read and write streams
  4. Copy from source to destination (the creating of tiles is left to the plugin) using tilelive.copy(source, sink, callback)
  5. Once tiles are copied the streams are closed

See Usage for more details on the tilelive module API.

Awesome tilelive modules

Ecosytem of tilelive

image

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 (or null) and a 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 (or null) and the URI of the tileset.

  • tilelive.load(uri, callback): Loads the Tilestore object associated with the specified uri. callback receives an error object (or null) and the Tilestore object.

  • tilelive.info(uri, callback): Loads the Tilestore object associated with the specified uri and retrieves its metadata in a TileJSON compliant format. callback receives an error object (or null), the metadata hash and the Tilestore object.

  • tilelive.all(source, callback): Loads metadata in a TileJSON compliant format for all tilesets in the source directory. callback receives an error object (or null) 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.createReadStream(src, { type: 'scanline', job: { total: 4, num: 1 } });

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

tilelive's People

Contributors

yhahn avatar kkaefer avatar rclark avatar wrynearson avatar tmcw avatar flippmoke avatar tomhughes avatar willwhite avatar dmitrig01 avatar jingsam avatar mapsam avatar nyurik avatar sbma44 avatar tcql avatar mojodna avatar anandthakker avatar gravitystorm avatar bwhtmn avatar jasonsanford avatar mick avatar robpvn avatar stepankuzmin avatar garnertb avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.