<commit_before>mapboxgl.accessToken = '<KEY>';
fname = 'data/tweets.geojson'

var map = new mapboxgl.Map({
    container: 'map',
    style: 'mapbox://styles/mapbox/dark-v9',
    center: [9.13734351262877, 45.137451890638886],
    zoom: 6
});

map.on('dblclick', function (e) {
    document.getElementById('info').innerHTML =
        // e.point is the x, y coordinates of the mousemove event relative
        // to the top-left corner of the map
        //JSON.stringify(e.point) + "<br>" +
        // e.lngLat is the longitude, latitude geographical position of the event
        JSON.stringify(e.lngLat);
    document.getElementById("lat").value = JSON.parse(JSON.stringify(e.lngLat)).lat;
    document.getElementById("lon").value = JSON.parse(JSON.stringify(e.lngLat)).lng;

});

function showCircle(){
    var lat = document.getElementById("lat").value;
    var lon = document.getElementById("lon").value;
    var radius = document.getElementById("radius").value;

    if(typeof(map.getSource("polygon")) == "undefined")
        map.addSource("polygon", createGeoJSONCircle([parseFloat(lon), parseFloat(lat)], parseFloat(radius)));
    else
        map.getSource("polygon").setData(createGeoJSONCircle([parseFloat(lon), parseFloat(lat)], parseFloat(radius)).data);

    map.addLayer({
        "id": "polygon",
        "type": "fill",
        "source": "polygon",
        "layout": {},
        "paint": {
            "fill-color": "blue",
            "fill-opacity": 0.6
        }
    });
}

var createGeoJSONCircle = function(center, radiusInKm, points) {
    if(!points) points = 64;

    var coords = {
        latitude: center[1],
        longitude: center[0]
    };
    var km = radiusInKm;

    var ret = [];
    var distanceX = km/(111.320*Math.cos(coords.latitude*Math.PI/180));
    var distanceY = km/110.574;

    var theta, x, y;
    for(var i=0; i<points; i++) {
        theta = (i/points)*(2*Math.PI);
        x = distanceX*Math.cos(theta);
        y = distanceY*Math.sin(theta);

        ret.push([coords.longitude+x, coords.latitude+y]);
    }
    ret.push(ret[0]);

    return {
        "type": "geojson",
        "data": {
            "type": "FeatureCollection",
            "features": [{
                "type": "Feature",
                "geometry": {
                    "type": "Polygon",
                    "coordinates": [ret]
                }
            }]
        }
    };
};

map.on('load', function(){
    window.setInterval(function(){
        map.getSource('tweets').setData(fname);
    }, 5000);

    map.addSource('tweets', {type: 'geojson', data: fname});
    map.addLayer({
        'id': 'tweets',
        'type': 'symbol',
        'source' :'tweets',
        'layout': {
            'icon-image': 'marker-15'
        }
        });
});



// When a click event occurs near a place, open a popup at the location of
// the feature, with description HTML from its properties.
map.on('click', function (e) {
    if(map.popup){
        map.popup._closeButton.click()
    }
    var features = map.queryRenderedFeatures(e.point, { layers: ['tweets']});

    if (!features.length) {
        return;
    }

    feature = undefined;
    for (var i = features.length - 1; i >= 0; i--) {
        if (features[i].properties !== undefined){
            feature = features[i];
            break;
        }
    }

    // var feature = features[features.length - 1];

    // Populate the popup and set its coordinates
    // based on the feature found.
    map.popup = new mapboxgl.Popup()
        .setLngLat(e.lngLat)
        .setHTML('<div class="popup-title"><center><h4>' + feature.properties.userName+ '</h4></ center></div><div>' + feature.properties.textMessage + '</div>')
        .addTo(map);
});

// Use the same approach as above to indicate that the symbols are clickable
// by changing the cursor style to 'pointer'.
map.on('mousemove', function (e) {
    var features = map.queryRenderedFeatures(e.point, { layers: ['tweets']});
    map.getCanvas().style.cursor = (features.length) ? 'pointer' : '';

});<commit_msg>reimport tweets and make them clickable<commit_after>mapboxgl.accessToken = '<KEY>';
fname = 'data/tweets.geojson'

var map = new mapboxgl.Map({
    container: 'map',
    style: 'mapbox://styles/mapbox/dark-v9',
    center: [9.13734351262877, 45.137451890638886],
    zoom: 6
});

map.on('dblclick', function (e) {
    document.getElementById('current-coordinates').innerHTML =
        // e.point is the x, y coordinates of the mousemove event relative
        // to the top-left corner of the map
        //JSON.stringify(e.point) + "<br>" +
        // e.lngLat is the longitude, latitude geographical position of the event
        JSON.stringify(e.lngLat);
    document.getElementById("lat").value = JSON.parse(JSON.stringify(e.lngLat)).lat;
    document.getElementById("lon").value = JSON.parse(JSON.stringify(e.lngLat)).lng;

});

function showCircle(){
    var lat = document.getElementById("lat").value;
    var lon = document.getElementById("lon").value;
    var radius = document.getElementById("radius").value;

    if(typeof(map.getSource("polygon")) == "undefined")
        map.addSource("polygon", createGeoJSONCircle([parseFloat(lon), parseFloat(lat)], parseFloat(radius)));
    else
        map.getSource("polygon").setData(createGeoJSONCircle([parseFloat(lon), parseFloat(lat)], parseFloat(radius)).data);

    map.addLayer({
        "id": "polygon",
        "type": "fill",
        "source": "polygon",
        "layout": {},
        "paint": {
            "fill-color": "blue",
            "fill-opacity": 0.6
        }
    });
}

var createGeoJSONCircle = function(center, radiusInKm, points) {
    if(!points) points = 64;

    var coords = {
        latitude: center[1],
        longitude: center[0]
    };
    var km = radiusInKm;

    var ret = [];
    var distanceX = km/(111.320*Math.cos(coords.latitude*Math.PI/180));
    var distanceY = km/110.574;

    var theta, x, y;
    for(var i=0; i<points; i++) {
        theta = (i/points)*(2*Math.PI);
        x = distanceX*Math.cos(theta);
        y = distanceY*Math.sin(theta);

        ret.push([coords.longitude+x, coords.latitude+y]);
    }
    ret.push(ret[0]);

    return {
        "type": "geojson",
        "data": {
            "type": "FeatureCollection",
            "features": [{
                "type": "Feature",
                "geometry": {
                    "type": "Polygon",
                    "coordinates": [ret]
                }
            }]
        }
    };
};

map.on('load', function(){

    map.addSource('tweets', {type: 'geojson', data: fname});
    map.addLayer({
        'id': 'tweets',
        'type': 'symbol',
        'source' :'tweets',
        'layout': {
            'icon-image': 'marker-15'
        }
        });
        window.setInterval(function(){
        map.getSource('tweets').setData(fname);
        map._update();
    }, 5000);
});



// When a click event occurs near a place, open a popup at the location of
// the feature, with description HTML from its properties.
map.on('click', function (e) {
    if(map.popup){
        map.popup._closeButton.click()
    }
    var features = map.queryRenderedFeatures(e.point, { layers: ['tweets']});

    if (!features.length) {
        return;
    }

    feature = undefined;
    for (var i = features.length - 1; i >= 0; i--) {
        if (features[i].properties !== undefined){
            feature = features[i];
            break;
        }
    }

    // var feature = features[features.length - 1];

    // Populate the popup and set its coordinates
    // based on the feature found.
    map.popup = new mapboxgl.Popup()
        .setLngLat(e.lngLat)
        .setHTML('<div class="popup-title"><center><h4>' + feature.properties.userName+ '</h4></ center></div><div>' + feature.properties.textMessage + '</div>')
        .addTo(map);
});

// Use the same approach as above to indicate that the symbols are clickable
// by changing the cursor style to 'pointer'.
map.on('mousemove', function (e) {
    var features = map.queryRenderedFeatures(e.point, { layers: ['tweets']});
    if (features.length){
	    map.getCanvas().style.cursor = (features.length) ? 'pointer' : '';
	}
});
{'fraction_non_alphanumeric': 0.16530537608192125, 'fraction_numerical': 0.016823113495062783, 'mean_word_length': 2.447058823529412, 'pattern_counts': {'":': 30, '<': 25, '<?xml version=': 0, '>': 25, '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': '7114925', 'n_tokens_mistral': 2693, 'n_tokens_neox': 2552, 'n_words': 562}