vt-pbf
Serialize mapbox vector tiles to binary protobufs in javascript.
Last updated 2 years ago by anandthakker .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install vt-pbf 
SYNC missed versions from official npm registry.

vt-pbf CircleCI

Serialize Mapbox vector tiles to binary protobufs in javascript.

Usage

As far as I know, the two places you might get a JS representation of a vector tile are geojson-vt and vector-tile-js. These both use slightly different internal representations, so serializing each looks slightly different:

From vector-tile-js

var vtpbf = require('vt-pbf')
var VectorTile = require('vector-tile').VectorTile

var data = fs.readFileSync(__dirname + '/fixtures/rectangle-1.0.0.pbf')
var tile = new VectorTile(new Pbf(data))
var orig = tile.layers['geojsonLayer'].feature(0).toGeoJSON(0, 0, 1)

var buff = vtpbf(tile)
fs.writeFileSync('my-tile.pbf', buff)

From geojson-vt

var vtpbf = require('vt-pbf')
var geojsonVt = require('geojson-vt')

var orig = JSON.parse(fs.readFileSync(__dirname + '/fixtures/rectangle.geojson'))
var tileindex = geojsonVt(orig)
var tile = tileindex.getTile(1, 0, 0)

// pass in an object mapping layername -> tile object
var buff = vtpbf.fromGeojsonVt({ 'geojsonLayer': tile })
fs.writeFileSync('my-tile.pbf', buff)

Current Tags

  • 3.1.1                                ...           latest (2 years ago)

15 Versions

  • 3.1.1                                ...           2 years ago
  • 3.1.0                                ...           3 years ago
  • 3.0.1                                ...           3 years ago
  • 2.1.4                                ...           3 years ago
  • 3.0.0                                ...           3 years ago
  • 2.1.3                                ...           3 years ago
  • 2.1.2                                ...           4 years ago
  • 2.1.1                                ...           4 years ago
  • 2.1.0                                ...           4 years ago
  • 2.0.2                                ...           5 years ago
  • 2.0.1                                ...           5 years ago
  • 2.0.0                                ...           5 years ago
  • 1.0.2                                ...           5 years ago
  • 1.0.1                                ...           5 years ago
  • 1.0.0                                ...           5 years ago
Downloads
Today 88
This Week 1,076
This Month 8,491
Last Day 506
Last Week 2,615
Last Month 10,751
Dependencies (3)
Dev Dependencies (14)
Dependents (91)

Copyright 2014 - 2016 © taobao.org |