Skip to content

Latest commit

 

History

History
63 lines (47 loc) · 2.28 KB

API-CPP.md

File metadata and controls

63 lines (47 loc) · 2.28 KB

Table of Contents

Filters

Takes optimized filter object from shaver.styleToFilters and returns c++ filters for shave.

Parameters

  • filters Object the filter object from the shaver.styleToFilters

Examples

var shaver = require('@mapbox/vtshaver');
var style = require('/path/to/style.json');
// get the filters object from `styleToFilters`
var styleFilters = shaver.styleToFilters(style);
// call the function to create filters
var filters = new shaver.Filters(styleFilters);

shave

Shave off unneeded layers and features, asynchronously

Parameters

  • buffer Buffer Vector Tile PBF
  • options Object (optional, default {})
    • options.zoom Number?
    • options.maxzoom Number?
    • options.compress Object?
      • options.compress.type String output a compressed shaved ['none'|'gzip']
  • callback Function from whence the shaven vector tile comes

Examples

var shaver = require('@mapbox/vtshaver');
var fs = require('fs');
var buffer = fs.readFileSync('/path/to/vector-tile.mvt');
var style = require('/path/to/style.json');
var filters = new shaver.Filters(shaver.styleToFilters(style));

var options = {
    filters: filters,  // required
    zoom: 14,          // required
    maxzoom: 16,       // optional
    compress: {        // optional
        type: 'none'
    }
};

shaver.shave(buffer, options, function(err, shavedTile) {
    if (err) throw err;
    console.log(shavedTile); // => vector tile buffer
});