Validate vector tiles based on the Mapbox Vector Tile Specification 2.x via vtzero.
npm install && npm run test
- If the tile is valid,
vtvalidatewill return an empty string. - If the tile is invalid,
vtvalidatewill return the string output from vtzero. vtvalidatewill throw an error if there is unexpected behaviour, for example an invalid argument value passed intovtvalidate.isValid()or a corrupt compressed buffer.
var vtvalidate = require('@maplibre/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); // ''
});var vtvalidate = require('@maplibre/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)'
});vtvalidate validates tile data against vtzero:
- Tile data consistent with the Mapbox vector tile spec - Version 2. Tiles created via Mapbox vector tile spec Version 1 will be flagged invalid.
- Read tile layer(s) and feature(s)
- Decode properties
- Decode geometries
Currently, vtvalidate does not check geometries for self-intersections. If you'd like to add more extensive tile validation, check out this example.
Accepts either uncompressed or gzip/zlib compressed tiles
node bin/vtvalidate.js <path-to-vector-tile>
Will output:
- empty string if it's a valid tile
- string that specifies why the tile is invalid
Provide desired iterations and concurrency
node bench/isValid.bench.js --iterations 50 --concurrency 10