<commit_before>// Create data feature groups
var incidentData = new L.MarkerClusterGroup({
      maxClusterRadius: 70,
      polygonOptions: {
        color: '#2c3e50',
        weight: 3
      },
      animateAddingMarkers: true,
      iconCreateFunction: function(cluster){
        var data = serializeClusterData(cluster);
        return pieChart(data);
      },
    }),
    alertAreas = new L.FeatureGroup([]);

// Define popup getter function
incidentData.on('click', function(e){
  var layer = e.layer;
  layer.bindPopup(getPopup(layer)).openPopup();
});

// Initialize the map
var map = L.map('map', {
  center: [48, -100],
  minZoom: 2,
  zoom: 4,
  layers: [MapQuestOpen_OSM, stravaHM, incidentData, alertAreas],
  worldCopyJump: true,
});

// Set map view
var userMark;
map.on("locationfound", function(location) {
  if (!userMark) {
    userMark = L.userMarker(location.latlng, {smallIcon:true, circleOpts:{weight: 1, opacity: 0.3, fillOpacity: 0.05}}).addTo(map);
    userMark.setAccuracy(location.accuracy);
  }
});

if (typeof zoom !== 'undefined') {
  map.setView(L.latLng(lat, lng), zoom);
  locateUser(setView = false, watch = false);
} else {
  locateUser(setView = true, watch = false);
}

// Add geocoder control
var geocoder = L.Control.geocoder({
  position: "topleft"
}).addTo(map);
var geocodeMarker;
geocoder.markGeocode = function(result) {
  map.fitBounds(result.bbox);
  geocodeMarker && map.removeLayer(geocodeMarker); //remove old marker if it exists

  geocodeMarker = new L.Marker(result.center, {
    icon: icons["geocodeIcon"]
  })
  .bindPopup(result.name)
  .addTo(map)
  .openPopup();
};

// Add scalebar
L.control.scale({
  position: 'bottomright'
}).addTo(map);

// Add all points to map
var collisions = geojsonMarker(collisions, "collision").addTo(incidentData).getLayers(),
    nearmisses = geojsonMarker(nearmisses, "nearmiss").addTo(incidentData).getLayers(),
    hazards = geojsonMarker(hazards, "hazard").addTo(incidentData).getLayers(),
    thefts = geojsonMarker(thefts, "theft").addTo(incidentData).getLayers();
    // officials = geojsonMarker(officials, "official").addTo(incidentData).getLayers();

// Add geofence alert areas to map
addAlertAreas(geofences);

function addAlertAreas(geofences){
  L.geoJson(geofences, {
    style: function(feature) {
      return {
        color: '#3b9972',
        weight: 2,
        opacity: 0.6,
        fillOpacity: 0.1,
        pk: (feature.id ? feature.id : feature.properties.id)
      }
    }
  }).eachLayer(function(l){alertAreas.addLayer(l);});
}

// Add and remove layers individually from the clusters on checkbox change
$("#collisionCheckbox").change(function(){ this.checked ? incidentData.addLayers(collisions) : incidentData.removeLayers(collisions); });
$("#nearmissCheckbox").change(function(){ this.checked ? incidentData.addLayers(nearmisses) : incidentData.removeLayers(nearmisses); });
$("#hazardCheckbox").change(function(){ this.checked ? incidentData.addLayers(hazards) : incidentData.removeLayers(hazards); });
$("#theftCheckbox").change(function(){ this.checked ? incidentData.addLayers(thefts) : incidentData.removeLayers(thefts); });
// $("#officialCheckbox").change(function(){ this.checked ? incidentData.addLayers(officials) : incidentData.removeLayers(officials); });


// Initialize the slider<commit_msg>Don't set userMarker accuracy if accuracy is less than 500m<commit_after>// Create data feature groups
var incidentData = new L.MarkerClusterGroup({
      maxClusterRadius: 70,
      polygonOptions: {
        color: '#2c3e50',
        weight: 3
      },
      animateAddingMarkers: true,
      iconCreateFunction: function(cluster){
        var data = serializeClusterData(cluster);
        return pieChart(data);
      },
    }),
    alertAreas = L.featureGroup();

// Define popup getter function
incidentData.on('click', function(e){
  var layer = e.layer;
  layer.bindPopup(getPopup(layer)).openPopup();
});

// Initialize the map
var map = L.map('map', {
  center: [48, -100],
  minZoom: 2,
  zoom: 4,
  layers: [MapQuestOpen_OSM, stravaHM, incidentData, alertAreas],
  worldCopyJump: true,
});

// Set map view
map.on("locationfound", function(location) {
    var userMark = L.userMarker(location.latlng, {smallIcon:true, circleOpts:{weight: 1, opacity: 0.3, fillOpacity: 0.05}}).addTo(map);
    if (location.accuracy < 500){
      userMark.setAccuracy(location.accuracy);
    }
});

if (typeof zoom !== 'undefined') {
  map.setView(L.latLng(lat, lng), zoom);
  locateUser(setView = false, watch = false);
} else {
  locateUser(setView = true, watch = false);
}

// Add geocoder control
var geocoder = L.Control.geocoder({
  position: "topleft"
}).addTo(map);
var geocodeMarker;
geocoder.markGeocode = function(result) {
  map.fitBounds(result.bbox);
  geocodeMarker && map.removeLayer(geocodeMarker); //remove old marker if it exists

  geocodeMarker = new L.Marker(result.center, {
    icon: icons["geocodeIcon"]
  })
  .bindPopup(result.name)
  .addTo(map)
  .openPopup();
};

// Add scalebar
L.control.scale({
  position: 'bottomright'
}).addTo(map);

// Add all points to map
var collisions = geojsonMarker(collisions, "collision").addTo(incidentData).getLayers(),
    nearmisses = geojsonMarker(nearmisses, "nearmiss").addTo(incidentData).getLayers(),
    hazards = geojsonMarker(hazards, "hazard").addTo(incidentData).getLayers(),
    thefts = geojsonMarker(thefts, "theft").addTo(incidentData).getLayers();
    // officials = geojsonMarker(officials, "official").addTo(incidentData).getLayers();

// Add geofence alert areas to map
addAlertAreas(geofences);
function addAlertAreas(geofences){
  L.geoJson(geofences, {
    style: function(feature) {
      return {
        color: '#3b9972',
        weight: 2,
        opacity: 0.6,
        fillOpacity: 0.1,
        pk: (feature.id ? feature.id : feature.properties.id)
      }
    }
  }).eachLayer(function(l){alertAreas.addLayer(l);});
}

// Add and remove layers individually from the clusters on checkbox change
$("#collisionCheckbox").change(function(){ this.checked ? incidentData.addLayers(collisions) : incidentData.removeLayers(collisions); });
$("#nearmissCheckbox").change(function(){ this.checked ? incidentData.addLayers(nearmisses) : incidentData.removeLayers(nearmisses); });
$("#hazardCheckbox").change(function(){ this.checked ? incidentData.addLayers(hazards) : incidentData.removeLayers(hazards); });
$("#theftCheckbox").change(function(){ this.checked ? incidentData.addLayers(thefts) : incidentData.removeLayers(thefts); });
// $("#officialCheckbox").change(function(){ this.checked ? incidentData.addLayers(officials) : incidentData.removeLayers(officials); });


// Initialize the slider
{'fraction_non_alphanumeric': 0.15183636906539266, 'fraction_numerical': 0.009853687667960586, 'mean_word_length': 4.477514309076042, 'pattern_counts': {'":': 0, '<': 4, '<?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': '646731', 'n_tokens_mistral': 2300, 'n_tokens_neox': 2200, 'n_words': 427}