Home

Awesome

vtvalidate

Validate vector tiles based on the Mapbox Vector Tile Specification 2.x via vtzero.

node-cpp-skel Build Status codecov

Build & Test

git clone git@github.com:mapbox/vtvalidate.git
cd vtvalidate

# Build binaries. This looks to see if there were changes in the C++ code. This does not reinstall deps.
make

# Run tests
make test

# Cleans your current builds and removes potential cache
make clean

# Cleans everything, including the things you download from the network in order to compile (ex: npm packages).
# This is useful if you want to nuke everything and start from scratch.
# For example, it's super useful for making sure everything works for Travis, production, someone else's machine, etc
make distclean

Usage

Valid tile

var vtvalidate = require('@mapbox/vtvalidate');

...

// Pass in protocol buffer (uncompressed)
vtvalidate.isValid(buffer, function(err, result) {
  if (err) throw err;

  // returns empty string if it's a valid tile
  console.log(result); // ''
});

Invalid tile

var vtvalidate = require('@mapbox/vtvalidate');

...

// Pass in protocol buffer (uncompressed)
vtvalidate.isValid(buffer, function(err, result) {
  if (err) throw err;

  // returns string that specifies why the tile is invalid
  console.log(result); // 'Missing geometry field in feature (spec 4.2)'
});

Type of validation

vtvalidate validates tile data against vtzero:

Currently, vtvalidate does not check geometries for self-intersections, but planned in the future. If you'd like to add more extensive tile validation, check out this example.

CLI

Accepts either uncompressed or gzip/zlib compressed tiles

node bin/vtvalidate.js <path-to-vector-tile>

Will output:

Bench

Provide desired iterations and concurrency

node bench/isValid.bench.js --iterations 50 --concurrency 10