Skip to content

yetzt/node-vtt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

vector tile transformer

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published