vtt

0.0.3 • Public • Published

Vector Tile Transformer

Vector Tile Transformer lets you change Vector Tiles in a stream.

API

stream = vtt(function(data, fn){ /* ... */ })

A transform stream passing the unpacked vector tile data to a function for modification.

Example

const fs = require("fs");

const src = fs.createReadStream("tile-in.pbf");
const dest = fs.createWriteStream("tile-out.pbf");

const vtt = require("vtt");

src.pipe(vtt(function(layers, done){
	
	// filter layers by name
	layers = layers.filter(function(layer){
		return (layer.name !== "keepme");
	});
	
	// add a property to all features in a layer
	layers[0] = layers[0].map(function(feature){
		feature.properties.modified = true;
		return feature;
	});
	
	done(null, layers); // err, data
	
})).pipe(dest);

data

[{
	version: 2,
	name: "name",
	extent: 4096,
	features: [{
		id: 1,
		type: 1,
		properties: {
			key: "value",
		},
		geometry: (...geometry),
	}],
}]

data = vtt.unpack(buffer);

Sync convenience method to turn an uncompressed vector tile into an object

buffer = vtt.pack(data);

Sync convenience method to turn an object back into an uncompressed vector tile

License

UNLICENSE

Package Sidebar

Install

npm i vtt

Weekly Downloads

21

Version

0.0.3

License

Unlicense

Unpacked Size

10.5 kB

Total Files

4

Last publish

Collaborators

  • yetzt