<commit_before>// TODO: eliminate these includes, blegh
var settings = {},
    Map = require('./map'),
    Format = require('./format'),
    SphericalMercator = require('./sphericalmercator');

/**
 * TileLive Tile object definition
 */

/**
 * Tile constructor
 *
 * @param {String} scheme (xyz|tms|tile (tms)).
 * @param {String} mapfile base64-encoded mapfile.
 * @param {Number} z zoom level.
 * @param {Number} x latitude.
 * @param {Number} y longitude.
 * @param {String} format
 * - Tile: (png|jpg)
 * - Data Tile: (geojson)
 * - Grid Tile: (*.grid.json).
 */
function Tile(options) {
    this.map = new Map(options.mapfile, options.mapfile_dir, true, {
        width: parseInt(options.width, 10),
        height: parseInt(options.height, 10)
    });
    this.scheme = options.scheme;
    if (options.bbox) {
        this.bbox = options.bbox;
    } else if (options.xyz) {
        this.x = parseInt(options.xyz[0], 10);
        this.y = parseInt(options.xyz[1], 10);
        this.z = parseInt(options.xyz[2], 10);
        // TODO: make class fns
        this.sm = new SphericalMercator({ levels: this.z + 1 });
        this.bbox = this.sm.xyz_to_envelope(this.x, this.y, this.z,
            (['tms', 'tile'].indexOf(this.scheme) !== -1));
    }
    this.format = options.format;
    this.format_options = options.format_options || {};
    this.renderFormat = Format.select(options.format);
}

/**
 * Generate output and invoke callback function. Defers to
 * a sub function of render
 * @param {Function} callback the function to call when
 *  data is rendered.
 */
Tile.prototype.render = function(callback) {
    var that = this;
    this.map.localize(function(err) {
        if (err) {
            callback(err);
        }
        else {
            try {
                that.renderFormat(that, callback);
            } catch (err) {
                callback(err);
            }
        }
    });
};

module.exports = Tile;<commit_msg>Reformatting as docco<commit_after>// TODO: eliminate these includes, blegh
var settings = {},
    Map = require('./map'),
    Format = require('./format'),
    SphericalMercator = require('./sphericalmercator');

// # TileLive Tile object definition

// Tile constructor
//
// - @param {String} scheme (xyz|tms|tile (tms)).
// - @param {String} mapfile base64-encoded mapfile.
// - @param {Number} z zoom level.
// - @param {Number} x latitude.
// - @param {Number} y longitude.
// - @param {String} format
//   - Tile: (png|jpg)
//   - Data Tile: (geojson)
//   - Grid Tile: (*.grid.json).
function Tile(options) {
    this.map = new Map(options.mapfile, options.mapfile_dir, true, {
        width: parseInt(options.width, 10),
        height: parseInt(options.height, 10)
    });
    this.scheme = options.scheme;
    if (options.bbox) {
        this.bbox = options.bbox;
    } else if (options.xyz) {
        this.x = parseInt(options.xyz[0], 10);
        this.y = parseInt(options.xyz[1], 10);
        this.z = parseInt(options.xyz[2], 10);
        // TODO: make class fns
        this.sm = new SphericalMercator({ levels: this.z + 1 });
        this.bbox = this.sm.xyz_to_envelope(this.x, this.y, this.z,
            (['tms', 'tile'].indexOf(this.scheme) !== -1));
    }
    this.format = options.format;
    this.format_options = options.format_options || {};
    this.renderFormat = Format.select(options.format);
}

// Generate output and invoke callback function. Defers to
// a sub function of render
// - @param {Function} callback the function to call when
//  data is rendered.
Tile.prototype.render = function(callback) {
    var that = this;
    this.map.localize(function(err) {
        if (err) {
            callback(err);
        } else {
            try {
                that.renderFormat(that, callback);
            } catch (err) {
                callback(err);
            }
        }
    });
};

module.exports = Tile;
{'fraction_non_alphanumeric': 0.15493319630010277, 'fraction_numerical': 0.008735868448098663, 'mean_word_length': 2.364736387208297, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2444541', 'n_tokens_mistral': 1273, 'n_tokens_neox': 1231, 'n_words': 301}