Skip to content

Instantly share code, notes, and snippets.

@mapsam
Created May 13, 2016 18:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mapsam/34b496529bbe9c09f3ee77b20670515a to your computer and use it in GitHub Desktop.
Save mapsam/34b496529bbe9c09f3ee77b20670515a to your computer and use it in GitHub Desktop.
report node-mapnik validty/simplicity
#!/usr/bin/env node
"use strict";
var exists = require('fs').existsSync || require('path').existsSync;
var fs = require('fs');
var usage = 'usage:';
usage += '\n mapnik-info.js <tile.mvt> z x y';
var tile = process.argv[2];
if (!tile) {
console.log(usage);
process.exit(1);
}
if (!exists(tile)) {
console.log(tile + ' does not exist');
process.exit(1);
}
var z = process.argv[3];
var x = process.argv[4];
var y = process.argv[5];
var mapnik = require('../');
mapnik.register_default_input_plugins();
var vt = new mapnik.VectorTile(parseInt(z), parseInt(x), parseInt(y));
var buffer = fs.readFileSync(tile);
vt.addData(buffer);
console.log('VALIDITY');
var val = vt.reportGeometryValiditySync();
val.forEach(function(v) {
console.log(v.message);
console.log('\n');
})
console.log('SIMPLICITY');
console.log(vt.reportGeometrySimplicitySync());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment