<commit_before>var fs = require('fs'),
    events = require('events'),
    Step = require('step'),
    Format = require('./format'),
    get = require('node-get'),
    path = require('path'),
    s64 = require('./safe64'),
    sys = require('sys'),
    localized = {},
    locked = {};

try { var mapnik = require('mapnik'); } catch (e) {
    sys.debug('tilelive.js: mapnik not found.');
}

try { var carto = require('carto'); } catch (e) {
    sys.debug('tilelive.js: carto not found.');
}

// Map constructor
//
// - `datasource` {String, Object} URL location of the datasource.
// - `options` {Object} options
//   - `base64` {Boolean} whether the `mapfile` parameter is base64 encoded.
//   - `mapfile_dir` {String} path to where data files should be cached.
//   - `width` {Number} width of the map
//   - `height` {Number} height of the map
var Map = function(datasource, options) {
    this.options = options || {};
    this.language = options.language || 'carto';
    this.options.width = options.width || 256;
    this.options.height = options.height || 256;
    this.mapfile_dir = options.mapfile_dir || '/tmp';

    if (options.base64) {
        this.datasource = s64.decode(datasource);
    } else {
        this.datasource = datasource;
    }
};

Map.__defineGetter__('mapfile_64', function() {
    return s64.decode(this.datasource);
});

// Find the mapfile on disk. If it's a URL, this will be
// the location of the downloaded Carto file. If it's a local path,
// this is the identity function.
//
// - @param {String} datasource.
// - @return {String} location.
Map.prototype.mapfilePos = function(datasource) {
    return (this.isUrl(datasource) || this.language !== 'xml') ?
        this.mapfile_dir + '/' + s64.encode(datasource) + '.xml' :
        datasource;
};

// Determine whether a string is a URL - http or https.
// 
// - @param {String} url.
// - @return {Bool}
Map.prototype.isUrl = function(url) {
    return (typeof url === 'string') && url.match(/^http/);
};

// TODO: make multi-process safe.
//
// Determine whether a datasource is localized. Local datasources
// are always localized.
Map.prototype.localized = function(set) {
    set && (localized[this.datasource] = set);<commit_msg>Remove base64-related logic from Map class.<commit_after>var fs = require('fs'),
    events = require('events'),
    Step = require('step'),
    Format = require('./format'),
    get = require('node-get'),
    path = require('path'),
    s64 = require('./safe64'),
    sys = require('sys'),
    localized = {},
    locked = {};

try { var mapnik = require('mapnik'); } catch (e) {
    sys.debug('tilelive.js: mapnik not found.');
}

try { var carto = require('carto'); } catch (e) {
    sys.debug('tilelive.js: carto not found.');
}

// Map constructor
//
// - `datasource` {String, Object} URL location of the datasource.
// - `options` {Object} options
//   - `mapfile_dir` {String} path to where data files should be cached.
//   - `width` {Number} width of the map
//   - `height` {Number} height of the map
var Map = function(datasource, options) {
    this.options = options || {};
    this.language = options.language || 'carto';
    this.options.width = options.width || 256;
    this.options.height = options.height || 256;
    this.mapfile_dir = options.mapfile_dir || '/tmp';
    this.datasource = datasource;
};

// Find the mapfile on disk. If it's a URL, this will be
// the location of the downloaded Carto file. If it's a local path,
// this is the identity function.
//
// - @param {String} datasource.
// - @return {String} location.
Map.prototype.mapfilePos = function(datasource) {
    return (this.isUrl(datasource) || this.language !== 'xml') ?
        this.mapfile_dir + '/' + s64.encode(datasource) + '.xml' :
        datasource;
};

// Determine whether a string is a URL - http or https.
// 
// - @param {String} url.
// - @return {Bool}
Map.prototype.isUrl = function(url) {
    return (typeof url === 'string') && url.match(/^http/);
};

// TODO: make multi-process safe.
//
// Determine whether a datasource is localized. Local datasources
// are always localized.
Map.prototype.localized = function(set) {
    set && (localized[this.datasource] = set);
{'fraction_non_alphanumeric': 0.1681731684110371, 'fraction_numerical': 0.009039010466222646, 'mean_word_length': 3.0393852065321805, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1832680', 'n_tokens_mistral': 1379, 'n_tokens_neox': 1314, 'n_words': 384}