<commit_before><!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Date du bâti</title>


    <link rel="stylesheet" href="https://unpkg.com/leaflet@1.0.3/dist/leaflet.css"
    integrity="<KEY>
    crossorigin=""/>

    <style>
        html, body, #map {
            height: 100%;
            width: 100%;
        }
    </style>

</head>
<body>

   <div id="map"></div>

   <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

   <script src="https://unpkg.com/leaflet@1.0.3/dist/leaflet.js"
   integrity="<KEY>
   crossorigin=""></script>

   <script src="http://makinacorpus.github.io/Leaflet.RestoreView/leaflet.restoreview.js"></script>

   <script>
    var map = L.map('map');

    if (!map.restoreView()) {
        map.setView([47.651, 2.791], 6);
    }

    L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(map);
    var layers = []

    var loadgeoJSON = function(filepath) {
        $.getJSON(filepath, function(json) {
            layers.push(L.geoJSON(json, {
                style: function(feature) {
                    return {color: feature.properties.color};
                },
                onEachFeature: function (feature, layer) {
                   layer.bindPopup(`${feature.properties.insee} - ${feature.properties.name}<br>${feature.properties.description}`);
                }
            }).addTo(map));
        });
    };

    var onzoom = function(e) {
        for (var l in layers) map.removeLayer(l);
        layers = [];

        if (map.getZoom() <= 7) {
            // what to do?

        } else if (map.getZoom() >= 7 && map.getZoom() <= 10) {
            // get regions
        } else if (map.getZoom() >= 11) {
            for (var i = 1; i < 977; i++) {
                if (i == 96) i = 971;

                var filepath = './data/stats/' + (i < 10 ? '0' : '') + i + '.geojson';
                loadgeoJSON(filepath);
            }
        }
    };

    map.on('zoomend', onzoom);
    onzoom(null);
</script>

</body>
</html>
<commit_msg>feat(web): display one department at a time<commit_after><!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Date du bâti</title>


    <link rel="stylesheet" href="https://unpkg.com/leaflet@1.0.3/dist/leaflet.css"
    integrity="<KEY>
    crossorigin=""/>

    <style>
        html, body, #map {
            height: 100%;
            width: 100%;
        }
    </style>

</head>
<body>

   <div id="map"></div>

   <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

   <script src="https://unpkg.com/leaflet@1.0.3/dist/leaflet.js"
   integrity="sha512-A7vV8IFfih/D732iSSKi20u/ooOfj/AGehOKq0f4vLT1Zr2Y+RX7C+w8A1gaSasGtRUZpF/NZgzSAu4/Gc41Lg=="
   crossorigin=""></script>

   <script src="http://makinacorpus.github.io/Leaflet.RestoreView/leaflet.restoreview.js"></script>
   <script src="https://unpkg.com/@mapbox/leaflet-pip@latest/leaflet-pip.js"></script>


   <script>
    var map = L.map('map');

    if (!map.restoreView()) {
        map.setView([47.651, 2.791], 6);
    }

    L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(map);
    var layers = []

    $('#map').on('click', '.trigger', function() {
        alert("TODO");
    });

    var loadgeoJSON = function(filepath) {

        $.getJSON(filepath, function(json) {
            for (r in layers) {
                if (layers[r].options.filepath == filepath) {
                    console.warn("already present, skipping!");
                    return;
                }
            }
            layers.push(L.geoJSON(json, {
                filepath: filepath,

                style: function(feature) {
                    return {color: feature.properties.color};
                },
                onEachFeature: function (feature, layer) {
                    var link = `${feature.properties.insee} - ${feature.properties.name}<br>${feature.properties.description}<br><button class="trigger">Refresh</button>`
                    layer.bindPopup(link);
                }
            }).addTo(map));
        });
    };

    let france;
    $.getJSON('./data/stats/france.geojson', function(json) {
        france = L.geoJSON(json);//.addTo(map);
        onmove(null);
    });

    var onmove = function(e) {
        current = []
        for (var l in layers) current.push(layers[l].options.filepath);

        newer = []
        var results = leafletPip.pointInLayer(map.getCenter(), france);
        for (var r in results) {
            var path = './data/stats/' + results[r].feature.properties.insee.substring(0,2) + '.geojson';
            if (newer.indexOf(path)==-1) newer.push(path);
        }

        if (JSON.stringify(newer) === JSON.stringify(current)) {
            return;
        }

        for (var l in layers) map.removeLayer(layers[l]);
        layers = [];

        for (var p in newer)
            loadgeoJSON(newer[p]);
    };

    map.on('moveend', onmove);
</script>

</body>
</html>

{'fraction_non_alphanumeric': 0.17989629038691662, 'fraction_numerical': 0.01854806541683287, 'mean_word_length': 2.008398320335933, 'pattern_counts': {'":': 0, '<': 63, '<?xml version=': 0, '>': 61, 'https://': 9, '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': '1392707', 'n_tokens_mistral': 1771, 'n_tokens_neox': 1649, 'n_words': 271}