<commit_before>var path = require('path'),
    sys = require('sys'),
    MBTiles = require('../lib/tilelive/mbtiles'),
    Map = require('../lib/tilelive/map'),
    TileBatch = require('../lib/tilelive/batch'),
    assert = require('assert'),
    fs = require('fs');

var TEST_MAPFILE = 'http://tilemill-testing.s3.amazonaws.com/tilelive_test/world.mml';
var TEST_MAPFILE_64 = (new Buffer('http://tilemill-testing.s3.amazonaws.com/tilelive_test/world.mml')).toString('base64');

    /*
exports['Database setup'] = function() {
    var mb = new MBTiles(__dirname + '/tmp/creation.mbtiles');

    mb.setup(function(err) {
        assert.isUndefined(err, 'MBTiles setup threw an error');
        fs.stat(__dirname + '/tmp/creation.mbtiles', function(err, stats) {
            assert.isNull(err, 'The file was not created');
        });
    });
    mb.db.close();

    beforeExit(function() {
        fs.unlinkSync(__dirname + '/tmp/creation.mbtiles');
    });
};
    */

    /*
exports['Feature insertion'] = function() {
    var mb = new MBTiles(__dirname + '/tmp/creation.mbtiles');
    mb.setup(function(err) {
        assert.isUndefined(err, 'MBTiles setup threw an error');
        fs.stat(__dirname + '/tmp/creation.mbtiles', function(err, stats) {
            assert.isNull(err, 'The file was not created');
        });
    });

    var map = new Map(TEST_MAPFILE_64, __dirname + '/tmp', true, {
        width: 256,
        height: 256
    });

    var key_name = 'ISO3';
    map.localize(function(err) {
        map.mapnik_map_acquire(function(err, map) {
            var features = map.features(0, 0, 100);
            features.forEach(function(feature) {
                var k = feature[key_name];
                var v = JSON.stringify(feature);
                console.log(v);
            });
        });
    });

    mb.db.close();

    beforeExit(function() {
        // fs.unlinkSync(__dirname + '/tmp/creation.mbtiles');
    });
};
    */

exports['Tile Batch'] = function(beforeExit) {
    var batch = new TileBatch({
        filepath: __dirname + '/tmp/batch.mbtiles',
        batchsize: 100,
        bbox: [-180.0,-85,180,85],
        format: 'png',
        minzoom: 0,
        maxzoom: 1,
        mapfile: TEST_MAPFILE_64,
        mapfile_dir: __dirname + '/data/',
        interactivity: {
            key_name: 'ISO3',
            layer: 0
        },
        metadata: {
            name: 'Test batch',
            type: 'overlay',
            description: 'test',
            version: '1.1'
        }
    });

    batch.setup(function(err) {
        assert.isUndefined(err, 'Batch could be setup');
    });

    /*
    batch.fillGridData(function(err, tiles) {
        assert.isNull(err, 'The batch was not rendered.');
    });

    batch.renderChunk(function(err, tiles) {
        assert.isNull(err, 'The batch was not rendered.');
    });
    */

    batch.renderInteractionChunk(function(err, tiles) {
        assert.isNull(err, 'The batch was not rendered.');
    });

    beforeExit(function() {
        fs.stat(__dirname + '/tmp/batch.mbtiles', function(err, stats) {
            assert.isNull(err, 'The batch was not created.');
        });
        fs.unlinkSync(__dirname + '/tmp/batch.mbtiles');
    });
};<commit_msg>Trying to avoid node-sqlite pwn<commit_after>var path = require('path'),
    sys = require('sys'),
    MBTiles = require('../lib/tilelive/mbtiles'),
    Map = require('../lib/tilelive/map'),
    TileBatch = require('../lib/tilelive/batch'),
    assert = require('assert'),
    fs = require('fs');

var TEST_MAPFILE = 'http://tilemill-testing.s3.amazonaws.com/tilelive_test/world.mml';
var TEST_MAPFILE_64 = (new Buffer('http://tilemill-testing.s3.amazonaws.com/tilelive_test/world.mml')).toString('base64');

    /*
exports['Database setup'] = function() {
    var mb = new MBTiles(__dirname + '/tmp/creation.mbtiles');

    mb.setup(function(err) {
        assert.isUndefined(err, 'MBTiles setup threw an error');
        fs.stat(__dirname + '/tmp/creation.mbtiles', function(err, stats) {
            assert.isNull(err, 'The file was not created');
        });
    });
    mb.db.close();

    beforeExit(function() {
        fs.unlinkSync(__dirname + '/tmp/creation.mbtiles');
    });
};
    */

    /*
exports['Feature insertion'] = function() {
    var mb = new MBTiles(__dirname + '/tmp/creation.mbtiles');
    mb.setup(function(err) {
        assert.isUndefined(err, 'MBTiles setup threw an error');
        fs.stat(__dirname + '/tmp/creation.mbtiles', function(err, stats) {
            assert.isNull(err, 'The file was not created');
        });
    });

    var map = new Map(TEST_MAPFILE_64, __dirname + '/tmp', true, {
        width: 256,
        height: 256
    });

    var key_name = 'ISO3';
    map.localize(function(err) {
        map.mapnik_map_acquire(function(err, map) {
            var features = map.features(0, 0, 100);
            features.forEach(function(feature) {
                var k = feature[key_name];
                var v = JSON.stringify(feature);
                console.log(v);
            });
        });
    });

    mb.db.close();

    beforeExit(function() {
        // fs.unlinkSync(__dirname + '/tmp/creation.mbtiles');
    });
};
    */

exports['Tile Batch'] = function(beforeExit) {
    var batch = new TileBatch({
        filepath: __dirname + '/tmp/batch.mbtiles',
        batchsize: 100,
        bbox: [-180.0,-85,180,85],
        format: 'png',
        minzoom: 0,
        maxzoom: 1,
        mapfile: TEST_MAPFILE_64,
        mapfile_dir: __dirname + '/data/',
        interactivity: {
            key_name: 'ISO3',
            layer: 0
        },
        metadata: {
            name: '<NAME>',
            type: 'overlay',
            description: 'test',
            version: '1.1'
        }
    });

    batch.setup(function(err) {
        assert.isUndefined(err, 'Batch could be setup');
    });

    /*
    batch.fillGridData(function(err, tiles) {
        assert.isNull(err, 'The batch was not rendered.');
    });

    batch.renderChunk(function(err, tiles) {
        assert.isNull(err, 'The batch was not rendered.');
    });
    */

    batch.renderInteractionChunk(function(err, tiles) {
        assert.isNull(err, 'The batch was not rendered.');
    });
    batch.finish();

    beforeExit(function() {
        fs.stat(__dirname + '/tmp/batch.mbtiles', function(err, stats) {
            assert.isNull(err, 'The batch was not created.');
        });
        fs.unlinkSync(__dirname + '/tmp/batch.mbtiles');
    });
};
{'fraction_non_alphanumeric': 0.16161151960784315, 'fraction_numerical': 0.012867647058823529, 'mean_word_length': 2.2369856222112046, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5767494', 'n_tokens_mistral': 2123, 'n_tokens_neox': 2037, 'n_words': 390}