<commit_before>var Planification = function(data,map,styles){
  this.data = data;
  this.map = map;
  this.styles = styles;
  this.__plans = {};

  var self = this;

  this.plans = function(){
    var o =[];
    for (var plan in self.__plans){
      var l={};
      for (var k in self.__plans[plan].lines()){

        // Si está el feature, es que está dibujada
        l[k] = {show: (self.__plans[plan].is_drawn(k)) ? true : false}
      }
      o.push({name:plan,
              label : self.__plans[plan].label(),
              lines:l});
    }
    return o;
  };

  this.set_plans_lines = function(plan_lines){
    if (plan_lines == 0) return;
    $.each(plan_lines,function(i,p){
      var param = p.split('.');
      var line = param[1];
      var plan = param[0].replace('_',' ');
      self.toggle(plan,line);
    })
  };

  this.toggle = function(plan,line){
    if (self.__plans[plan].is_drawn(line)){
      self.__plans[plan].undraw(line);
    } else {
      self.__plans[plan].draw(line);
    }

    var plan_lines = [];

    for (var k in self.__plans[plan].lines()){
      if (self.__plans[plan].is_drawn(k)) {
        plan_lines.push(plan.replace(' ','_')+'.'+k)
      }
    }

    return plan_lines;
  };

  this.__load_data = function(data){
    $.each(data.lines.features, function(index,line){
      var plan_name = line.properties.plan;
      var line_name = line.properties.line;

      if (!self.__plans[plan_name]) {
        self.__plans[plan_name] = new Plan(self.map,plan_name,line.properties.year,styles);
      }

      if (!self.__plans[plan_name].lines()[line_name]){
        self.__plans[plan_name].add_line(line_name,line.geometry)
      }
    });

    $.each(data.stations.features, function(index,station){
      plan_name = station.properties.plan;
      line_name = station.properties.line;
      station['feature'] = null;
      self.__plans[plan_name].add_station(line_name,station);
    });
  };

  this.__load_data(data);
};

var Plan = function(map,plan_name,year,styles){
  // Soporta por plan y por línea una sóla polilínea.

  this.__year = year;
  this.__name = plan_name;
  this.__styles = styles;
  this.__lines = {};
  this.map = map;
  var self = this;

  this.lines = function(){
    return self.__lines;
  };

  this.add_line = function(name, geometry){
    self.__lines[name] = {geometry:geometry,feature:null,stations:[]}
  };

  this.add_station = function(line,station){
    self.__lines[line].stations.push(station)
  };

  this.label = function(){
    return self.__name +' ('+self.__year+')';
  };

  this.is_drawn = function(line){
    return (self.__lines[line].feature) ? true : false;
  };

  this.__popup_content = function(line,name){
    var content ='<div class="info-window"><div>';
    if (name) content += name + ' - ';
    content += 'Línea '+ line + '</div>';
    content +='<ul>';
    content += '<li>' + self.label();
    content +='</ul></div>';
    return content;
  };

  this.__style = function(type,line){
    var style = self.__styles[type]['project'];
    if (type== 'line') {
      style = $.extend(true,{},style['default'],style[self.__name][line]);<commit_msg>plans sorted by year<commit_after>var Planification = function(data,map,styles){
  this.data = data;
  this.map = map;
  this.styles = styles;
  this.__plans = {};

  var self = this;

  this.plans = function(){
    var o =[];
    for (var plan in self.__plans){
      var l={};
      for (var k in self.__plans[plan].lines()){

        // Si está el feature, es que está dibujada
        l[k] = {show: (self.__plans[plan].is_drawn(k)) ? true : false}
      }

      var p ={name:plan,
              year: self.__plans[plan].year(),
              label: self.__plans[plan].label(),
              lines:l};
      o.push(p);
    }

    // We return the plans sorted by year
    return o.sort(function(a,b){return a.year-b.year});
  };

  this.set_plans_lines = function(plan_lines){
    if (plan_lines == 0) return;
    $.each(plan_lines,function(i,p){
      var param = p.split('.');
      var line = param[1];
      var plan = param[0].replace('_',' ');
      self.toggle(plan,line);
    })
  };

  this.toggle = function(plan,line){
    if (self.__plans[plan].is_drawn(line)){
      self.__plans[plan].undraw(line);
    } else {
      self.__plans[plan].draw(line);
    }

    var plan_lines = [];

    for (var k in self.__plans[plan].lines()){
      if (self.__plans[plan].is_drawn(k)) {
        plan_lines.push(plan.replace(' ','_')+'.'+k)
      }
    }

    return plan_lines;
  };

  this.__load_data = function(data){
    $.each(data.lines.features, function(index,line){
      var plan_name = line.properties.plan;
      var line_name = line.properties.line;

      if (!self.__plans[plan_name]) {
        self.__plans[plan_name] = new Plan(self.map,plan_name,line.properties.year,styles);
      }

      if (!self.__plans[plan_name].lines()[line_name]){
        self.__plans[plan_name].add_line(line_name,line.geometry)
      }
    });

    $.each(data.stations.features, function(index,station){
      plan_name = station.properties.plan;
      line_name = station.properties.line;
      station['feature'] = null;
      self.__plans[plan_name].add_station(line_name,station);
    });
  };

  this.__load_data(data);
};

var Plan = function(map,plan_name,year,styles){
  // Soporta por plan y por línea una sóla polilínea.

  this.__year = year;
  this.__name = plan_name;
  this.__styles = styles;
  this.__lines = {};
  this.map = map;
  var self = this;

  this.lines = function(){
    return self.__lines;
  };

  this.add_line = function(name, geometry){
    self.__lines[name] = {geometry:geometry,feature:null,stations:[]}
  };

  this.add_station = function(line,station){
    self.__lines[line].stations.push(station)
  };

  this.label = function(){
    return self.__name +' ('+self.__year+')';
  };

  this.year = function(){
    return self.__year;
  };

  this.is_drawn = function(line){
    return (self.__lines[line].feature) ? true : false;
  };

  this.__popup_content = function(line,name){
    var content ='<div class="info-window"><div>';
    if (name) content += name + ' - ';
    content += 'Línea '+ line + '</div>';
    content +='<ul>';
    content += '<li>' + self.label();
    content +='</ul></div>';
    return content;
  };

  this.__style = function(type,line){
    var style = self.__styles[type]['project'];
    if (type== 'line') {
      style = $.extend(true,{},style['default'],style[self.__name][line]);
{'fraction_non_alphanumeric': 0.1746496226705683, 'fraction_numerical': 0.0009240720776220545, 'mean_word_length': 2.893285371702638, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '1305906', 'n_tokens_mistral': 2254, 'n_tokens_neox': 2200, 'n_words': 405}