<commit_before>{% load sekizai_tags static i18n %}

<div id='map'></div>

{% addtoblock 'css' strip %}
  <link rel="stylesheet" type="text/css" href="{% static 'leaflet-0.7.3/leaflet.css' %}" />
{% endaddtoblock %}

{% addtoblock 'css' strip %}
  <link rel="stylesheet" type="text/css" href="{% static 'leaflet.fullscreen/dist/leaflet.fullscreen.css' %}" />
{% endaddtoblock %}

{% addtoblock 'js' strip %}
  <script type="text/javascript" src="{% static 'leaflet-0.7.3/leaflet.js' %}"></script>
{% endaddtoblock %}

{% addtoblock 'js' strip %}
  <script src="{% static 'leaflet.fullscreen/dist/Leaflet.fullscreen.min.js' %}"></script>
{% endaddtoblock %}

{% addtoblock 'js' %}
  <script>
    var map = L.map('map', {
      layers: [L.tileLayer('//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png')],
      minZoom: 2,
      maxZoom: 15,
      zoomControl: false,
      attributionControl: false
    });

    map.addControl(L.control.fullscreen({
      position: 'topright',
      title: {
        'false': '{% trans 'Voir en plein écran' %}',
        'true': '{% trans 'Quitter le plein écran' %}'
      }
    }));
    map.addControl(L.control.zoom({
      position: 'topright',
      zoomInTitle: '{% trans 'Zoomer' %}',
      zoomOutTitle: '{% trans 'Dézoomer' %}'
    }));

    var minValue = 1;
    var maxValue = 2;
    var minRadius = 5;
    var maxRadius = 30;

    function normalize(x, growth) {
      if (typeof growth == 'undefined') {
        growth = $('#growth-slider').slider('value');
      }
      return minRadius + Math.pow((x - minValue) / (maxValue - minValue),
                                  growth) * (maxRadius - minRadius);
    }

    function getOptions(count) {
      return {
        radius: normalize(count),
        fillColor: 'red',
        color: 'darkgrey',
        weight: 1,
        opacity: 1,
        fillOpacity: 0.7
      };
    }

    var geoJson;
    var $map = $('#map');
    var $mapControls = $map.find('.leaflet-control-container');
    $mapControls.find('[title]').data('placement', 'left');
    tooltips_create($mapControls);

    map.on('moveend', function () {
      var url = '{{ geojson_url }}' + document.location.search;
      try {
        url += '&bbox=' + map.getBounds().toBBoxString();
      } catch(err) {}
      url += '&min_places=' + $('#min-places-slider').slider('value');
      $.ajax({
        url: url
      }).done(function (data) {
        tooltips_delete($map);
        var empty = false;
        if (typeof geoJson == 'undefined') {
          empty = true;
        } else {
          map.removeLayer(geoJson);
        }
        data.forEach(function (feature) {
          maxValue = Math.max(maxValue, feature.properties.n);
        });
        geoJson = L.geoJson(data, {
          pointToLayer: function (feature, latlng) {
            return L.circleMarker(latlng, getOptions(feature.properties.n)
            ).on('add', function () {
              this._container.setAttribute('title',
                                           feature.properties.tooltip);
            }).on('click', function () {
              document.location.search = feature.properties.url;
            });
          }
        }).addTo(map);
        tooltips_create($map);
        if (empty) {
          map.fitBounds(geoJson.getBounds(), {padding: [70, 70]});
        }
      });
    }).on('fullscreenchange', function () {
      tooltips_reload($mapControls);
    });
  </script>
{% endaddtoblock %}

<div class="row">
  <div class="col-xs-3">{% trans 'Nombre de lieux minimum' %}</div>
  <div class="col-xs-9">
    <div id="min-places-slider"></div>
  </div>
</div>
<div class="row">
  <div class="col-xs-3">{% trans 'Proportion des points' %}</div>
  <div class="col-xs-9">
    <div id="growth-slider"></div>
  </div>
</div>

{% addtoblock 'js' %}
  <script>
    $(function() {
      $('#min-places-slider').slider({
        min: 1,
        max: {{ MAX_MIN_PLACES }},
        step: 1,
        value: {{ DEFAULT_MIN_PLACES }},
        create: function () {
          map.fire('moveend');
        },
        change: function () {
          map.fire('moveend');
        }<commit_msg>Corrige le nom du slider de niveau de détail de la map et autorise un zoom plus important.<commit_after>{% load sekizai_tags static i18n %}

<div id='map'></div>

{% addtoblock 'css' strip %}
  <link rel="stylesheet" type="text/css" href="{% static 'leaflet-0.7.3/leaflet.css' %}" />
{% endaddtoblock %}

{% addtoblock 'css' strip %}
  <link rel="stylesheet" type="text/css" href="{% static 'leaflet.fullscreen/dist/leaflet.fullscreen.css' %}" />
{% endaddtoblock %}

{% addtoblock 'js' strip %}
  <script type="text/javascript" src="{% static 'leaflet-0.7.3/leaflet.js' %}"></script>
{% endaddtoblock %}

{% addtoblock 'js' strip %}
  <script src="{% static 'leaflet.fullscreen/dist/Leaflet.fullscreen.min.js' %}"></script>
{% endaddtoblock %}

{% addtoblock 'js' %}
  <script>
    var map = L.map('map', {
      layers: [L.tileLayer('//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png')],
      minZoom: 2,
      maxZoom: 16,
      zoomControl: false,
      attributionControl: false
    });

    map.addControl(L.control.fullscreen({
      position: 'topright',
      title: {
        'false': '{% trans 'Voir en plein écran' %}',
        'true': '{% trans 'Quitter le plein écran' %}'
      }
    }));
    map.addControl(L.control.zoom({
      position: 'topright',
      zoomInTitle: '{% trans 'Zoomer' %}',
      zoomOutTitle: '{% trans 'Dézoomer' %}'
    }));

    var minValue = 1;
    var maxValue = 2;
    var minRadius = 5;
    var maxRadius = 30;

    function normalize(x, growth) {
      if (typeof growth == 'undefined') {
        growth = $('#growth-slider').slider('value');
      }
      return minRadius + Math.pow((x - minValue) / (maxValue - minValue),
                                  growth) * (maxRadius - minRadius);
    }

    function getOptions(count) {
      return {
        radius: normalize(count),
        fillColor: 'red',
        color: 'darkgrey',
        weight: 1,
        opacity: 1,
        fillOpacity: 0.7
      };
    }

    var geoJson;
    var $map = $('#map');
    var $mapControls = $map.find('.leaflet-control-container');
    $mapControls.find('[title]').data('placement', 'left');
    tooltips_create($mapControls);

    map.on('moveend', function () {
      var url = '{{ geojson_url }}' + document.location.search;
      try {
        url += '&bbox=' + map.getBounds().toBBoxString();
      } catch(err) {}
      url += '&min_places=' + $('#min-places-slider').slider('value');
      $.ajax({
        url: url
      }).done(function (data) {
        tooltips_delete($map);
        var empty = false;
        if (typeof geoJson == 'undefined') {
          empty = true;
        } else {
          map.removeLayer(geoJson);
        }
        data.forEach(function (feature) {
          maxValue = Math.max(maxValue, feature.properties.n);
        });
        geoJson = L.geoJson(data, {
          pointToLayer: function (feature, latlng) {
            return L.circleMarker(latlng, getOptions(feature.properties.n)
            ).on('add', function () {
              this._container.setAttribute('title',
                                           feature.properties.tooltip);
            }).on('click', function () {
              document.location.search = feature.properties.url;
            });
          }
        }).addTo(map);
        tooltips_create($map);
        if (empty) {
          map.fitBounds(geoJson.getBounds(), {padding: [70, 70]});
        }
      });
    }).on('fullscreenchange', function () {
      tooltips_reload($mapControls);
    });
  </script>
{% endaddtoblock %}

<div class="row">
  <div class="col-xs-3">{% trans 'Niveau de détail' %}</div>
  <div class="col-xs-9">
    <div id="min-places-slider"></div>
  </div>
</div>
<div class="row">
  <div class="col-xs-3">{% trans 'Proportion des points' %}</div>
  <div class="col-xs-9">
    <div id="growth-slider"></div>
  </div>
</div>

{% addtoblock 'js' %}
  <script>
    $(function() {
      $('#min-places-slider').slider({
        min: 1,
        max: {{ MAX_MIN_PLACES }},
        step: 1,
        value: {{ DEFAULT_MIN_PLACES }},
        create: function () {
          map.fire('moveend');
        },
        change: function () {
          map.fire('moveend');
        }
{'fraction_non_alphanumeric': 0.18274538036957044, 'fraction_numerical': 0.007199424046076314, 'mean_word_length': 2.2789142407553107, 'pattern_counts': {'":': 0, '<': 57, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4929467', 'n_tokens_mistral': 2823, 'n_tokens_neox': 2704, 'n_words': 534}