Giter Site home page Giter Site logo

wikimedia / tilelive-bridge Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kartotherian/tilelive-bridge

0.0 2.0 0.0 8.49 MB

Implements the tilelive API for generating mapnik vector tiles from traditional mapnik datasources.

License: BSD 3-Clause "New" or "Revised" License

JavaScript 93.83% Batchfile 6.17%

tilelive-bridge's Introduction

tilelive-bridge

Implements the tilelive API for generating mapnik vector tiles from traditional mapnik datasources.

Build Status Coverage Status Build status

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 @kartotherian/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

var tilelive = require('tilelive');
require('@kartotherian/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.

tilelive-bridge's People

Contributors

adamwight avatar adrianrego avatar ajashton avatar camillacaros avatar flippmoke avatar ingalls avatar jfirebaugh avatar lsimkins avatar mapsam avatar morganherlocker avatar nyurik avatar rclark avatar sbma44 avatar springmeyer avatar thesocialdev avatar tmcw avatar wilhelmberg avatar yhahn 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.