<commit_before>/**
 * @classdesc
 *
 * Module to use TMB API Transit services
 */

'use strict';

var Transit = function(http) {

    var linies = function(linia) {

        var info = function() {
            return http.get("transit/linies/" + (linia || ''));
        };

        return  {
            info: info
        }
    };

    linies.metro = function(linia) {
         var info = function() {
            return http.get("transit/linies/metro/" + (linia || ''));
         };

         var estacions = function(estacio) {
            return http.get("transit/linies/metro/" + linia + '/estacions/' + (estacio || ''));
         };

         return {
             info: info,
             estacions: estacions
         }

    };

    linies.bus = function(linia) {
        var info = function() {
            return http.get("transit/linies/bus/" + (linia || ''));
        };

        var parades = function(parada) {
            var parades = http.get("transit/linies/bus/" + linia + '/parades/' + (parada || ''));
            Object.defineProperties(parades, {
                anada: {
                    get: function() {
                        return this.then(filtraParades.bind(this, "A"));
                    }
                },
                tornada: {
                    get: function() {
                        return this.then(filtraParades.bind(this, "T"));
                    }
                }
            });
            return parades;
        };

        var filtraParades = function(sentit, parades) {
            parades.features = parades.features.filter(function(feature) {
                return feature.properties.SENTIT == sentit;
            }).sort(function(f1, f2) {
                return f1.properties.ORDRE - f2.properties.ORDRE;
            });
            parades.totalFeatures = parades.features.length;
            return parades;<commit_msg>Adds 'icona' property for estacions and parades<commit_after>/**
 * @classdesc
 *
 * Module to use TMB API Transit services
 */

'use strict';

var Transit = function(http) {

    var linies = function(linia) {

        var info = function() {
            return http.get("transit/linies/" + (linia || ''));
        };

        return  {
            info: info
        }
    };

    linies.metro = function(linia) {
        var info = function() {
            return http.get("transit/linies/metro/" + (linia || ''));
        };

        var estacions = function(estacio) {
            function icones(estacions) {
                estacions.features.forEach(function(estacio) {
                    var base = "//dl.dropboxusercontent.com/u/2368219/tmb_pictos/";
                    var p = estacio.properties;
                    p.icona = base + p.PICTO + ".png";
                });
                return estacions;
            }
            return http.get("transit/linies/metro/" + linia + '/estacions/' + (estacio || '')).then(icones);
        };

        return {
            info: info,
            estacions: estacions
        }

    };

    linies.bus = function(linia) {
        var info = function() {
            return http.get("transit/linies/bus/" + (linia || ''));
        };

        var parades = function(parada) {
            function icones(parades) {
                parades.features.forEach(function(parada) {
                    var p = parada.properties;
                    var size = "19";
                    var bg_color = p.COLOR_REC;
                    var fg_color = "FFFFFF"; // White
                    var text = p.NOM_LINIA;
                    p.icona = "http://placehold.it/" + size + "/" + bg_color + "/" + fg_color + "?text=" + text;
                });
                return parades;
            }

            var parades = http.get("transit/linies/bus/" + linia + '/parades/' + (parada || '')).then(icones);
            Object.defineProperties(parades, {
                anada: {
                    get: function() {
                        return this.then(filtraParades.bind(this, "A"));
                    }
                },
                tornada: {
                    get: function() {
                        return this.then(filtraParades.bind(this, "T"));
                    }
                }
            });
            return parades;
        };

        var filtraParades = function(sentit, parades) {
            parades.features = parades.features.filter(function(feature) {
                return feature.properties.SENTIT == sentit;
            }).sort(function(f1, f2) {
                return f1.properties.ORDRE - f2.properties.ORDRE;
            });
            parades.totalFeatures = parades.features.length;
            return parades;
{'fraction_non_alphanumeric': 0.13004674883127923, 'fraction_numerical': 0.003612409689757756, 'mean_word_length': 1.3348214285714286, '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': '1177179', 'n_tokens_mistral': 1356, 'n_tokens_neox': 1303, 'n_words': 244}