<commit_before>"use strict";

var mileagifyJS = mileagifyJS || {};

/* Config JSON */
mileagifyJS.config = {
    // Unit system (METRIC or IMPERIAL) More info https://developers.google.com/maps/documentation/directions/#UnitSystems
    unit_system: "METRIC",
    // Region (avoid conflicts) More info https://developers.google.com/maps/documentation/directions/#RegionBiasing
    region: "es",
    // Average fuel consumption (l/100km, litres per 100km)
    avg_consumption: 5,
    // Cost of a litre of fuel (ie 1.4€/l or $1.4/l)
    price_fuel: 1.4
};
/* Map Module */
mileagifyJS.map = function(){
    // Map object
    var map = null;
    // Map's properties
    var options = {
      zoom: 3,
      mapTypeId: google.maps.MapTypeId.ROADMAP,
      styles: [  { featureType: "all", stylers: [ { saturation: 10 } ] }   ]
    };
    // Render a map with the @location in the @selector dom element
    var render = function(selector, location) {
        // Set the location
        options.center = new google.maps.LatLng(location[0], location[1]);
        // Create the map
        mileagifyJS.map.object = new google.maps.Map(document.getElementById(selector), options);
        // Create the directions renderer
        mileagifyJS.route.directionsDisplay = new google.maps.DirectionsRenderer();
        // Link both
        mileagifyJS.route.directionsDisplay.setMap(mileagifyJS.map.object);
    };
    // Check the coordinates
    var isValidCoords = function(latitude, longitude)
    {
        /*  
         *  - latitude coordinate in degrees, as a number between -90 and +90
         *  - longitude coordinate in degrees, as a number between -180 and +180
         *  Please check https://developers.google.com/maps/documentation/javascript/v2/reference#GLatLng for more info
         * */
        this.isNumber = function(n) 
        {
            return !isNaN(parseFloat(n)) && isFinite(n);
        }
    
        return this.isNumber(latitude) && latitude <= 90 && latitude >= -90 
                && this.isNumber(longitude) && longitude <= 180 && longitude >= -180;
    };
    // Get the position of the device by the HTML5 geolocation API
    var getLocation = function(callback)
    {
        if (navigator.geolocation) {
            navigator.geolocation.getCurrentPosition(function(position){
                callback(null, position);
            });
        } else {
            callback("Your device doesn't support geolocation", null);
        }
    };
    // Convert a text (place, street, country, ...) to a coords (lat, lng)
    var text2LatLng = function(place, callback)
    {
        var geocoder = new google.maps.Geocoder();
        geocoder.geocode({ 'address': place }, function(results, status) {
            if (status == google.maps.GeocoderStatus.OK) {
                callback(null, [results[0].geometry.location.d, results[0].geometry.location.e]);
            } else {
                callback("Geocode was not successful due: " + status, null);
            }
        });
    };
    // Module's output
    var exports = {
        object: map,
        render: render,
        isValidCoords: isValidCoords,
        text2LatLng: text2LatLng,
        getLocation: getLocation
    };
    return exports;
}();
/* Route Module */
mileagifyJS.route = function(){
    // Start point
    var from = {
        name: "",
        lat: null,
        lng: null
    };
    // End point
    var to = {
        name: "",<commit_msg>text2LatLng() response fix<commit_after>"use strict";

var mileagifyJS = mileagifyJS || {};

/* Config JSON */
mileagifyJS.config = {
    // Unit system (METRIC or IMPERIAL) More info https://developers.google.com/maps/documentation/directions/#UnitSystems
    unit_system: "METRIC",
    // Region (avoid conflicts) More info https://developers.google.com/maps/documentation/directions/#RegionBiasing
    region: "es",
    // Average fuel consumption (l/100km, litres per 100km)
    avg_consumption: 5,
    // Cost of a litre of fuel (ie 1.4€/l or $1.4/l)
    price_fuel: 1.4
};
/* Map Module */
mileagifyJS.map = function(){
    // Map object
    var map = null;
    // Map's properties
    var options = {
      zoom: 3,
      mapTypeId: google.maps.MapTypeId.ROADMAP,
      styles: [  { featureType: "all", stylers: [ { saturation: 10 } ] }   ]
    };
    // Render a map with the @location in the @selector dom element
    var render = function(selector, location) {
        // Set the location
        options.center = new google.maps.LatLng(location[0], location[1]);
        // Create the map
        mileagifyJS.map.object = new google.maps.Map(document.getElementById(selector), options);
        // Create the directions renderer
        mileagifyJS.route.directionsDisplay = new google.maps.DirectionsRenderer();
        // Link both
        mileagifyJS.route.directionsDisplay.setMap(mileagifyJS.map.object);
    };
    // Check the coordinates
    var isValidCoords = function(latitude, longitude)
    {
        /*  
         *  - latitude coordinate in degrees, as a number between -90 and +90
         *  - longitude coordinate in degrees, as a number between -180 and +180
         *  Please check https://developers.google.com/maps/documentation/javascript/v2/reference#GLatLng for more info
         * */
        this.isNumber = function(n) 
        {
            return !isNaN(parseFloat(n)) && isFinite(n);
        }
    
        return this.isNumber(latitude) && latitude <= 90 && latitude >= -90 
                && this.isNumber(longitude) && longitude <= 180 && longitude >= -180;
    };
    // Get the position of the device by the HTML5 geolocation API
    var getLocation = function(callback)
    {
        if (navigator.geolocation) {
            navigator.geolocation.getCurrentPosition(function(position){
                callback(null, position);
            });
        } else {
            callback("Your device doesn't support geolocation", null);
        }
    };
    // Convert a text (place, street, country, ...) to a coords (lat, lng)
    var text2LatLng = function(place, callback)
    {
        var geocoder = new google.maps.Geocoder();
        geocoder.geocode({ 'address': place }, function(results, status) {
            if (status == google.maps.GeocoderStatus.OK) {
                var location = results[0].geometry.location;
                var latLng = [
                    location[Object.keys(location)[0]],
                    location[Object.keys(location)[1]]
                ];
                callback(null, latLng);
            } else {
                callback("Geocode was not successful due: " + status, null);
            }
        });
    };
    // Module's output
    var exports = {
        object: map,
        render: render,
        isValidCoords: isValidCoords,
        text2LatLng: text2LatLng,
        getLocation: getLocation
    };
    return exports;
}();
/* Route Module */
mileagifyJS.route = function(){
    // Start point
    var from = {
        name: "",
        lat: null,
        lng: null
    };
    // End point
    var to = {
        name: "",
{'fraction_non_alphanumeric': 0.12060443440192063, 'fraction_numerical': 0.012992515181471544, 'mean_word_length': 2.1405764966740577, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 6, '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': '4354434', 'n_tokens_mistral': 2142, 'n_tokens_neox': 2030, 'n_words': 524}