var mapnik = require('./lib/mapnik');
var fs = require('fs');

var vtile = new mapnik.VectorTile(6, 32, 21);
var incoming = fs.readFileSync('./6-32-21.mvt');
vtile.setData(incoming, function(err) {
    if (err) throw err;

    vtile.toGeoJSON(0, function(err, json) {
        if (err) throw err;

        json = JSON.parse(json);
        console.log('vtile.toGeoJSON properties: ');
        json.features.forEach(function(feature) {
            for (key in feature.properties)
                console.log('%s: %s', key, feature.properties[key]);
        });

        vtile.query(0.0604, 51.6376, { tolerance: 1e5 }, function(err, features) {
            if (err) throw err;

            console.log('vtile.query properties: ');
            features.forEach(function(feature) {
                var attr = feature.attributes();
                for (key in attr)
                    console.log('%s: %s', key, attr[key]);
            });
        });
    });
});
