<commit_before>(function(){

  "use strict";

	$('.parks').click( toggleParksLayer );

	// $('.districts-toggles li').on( 'click', function(){
	// 	$this = $(this);
	// 	var districtNum = parseInt($this.data('district'));
	// 	var districtIndex = districtNum - 1;
	// 	if (districtLayer){ map.removeLayer(districtLayer); };
	// 	addSingleDistrictLayer(districtIndex);
	// });

	var grayscale = L.tileLayer.provider('CartoDB.Positron');
		// terrain = L.tileLayer.provider('Stamen.Terrain');
		// blackAndWhite = 'OpenStreetMap.BlackAndWhite'
		// 'Thunderforest.Transport'
		// 'OpenMapSurfer.Roads'
		// 'OpenMapSurfer.Grayscale'
		// 'Stamen.Toner'
		// 'Esri.WorldGrayCanvas'
		// 'CartoDB.DarkMatter'

  var greenColors = [
    'rgb(255,255,229)',
    'rgb(247,252,185)',
    'rgb(217,240,163)',
    'rgb(173,221,142)',
    'rgb(120,198,121)',
    'rgb(65,171,93)',
    'rgb(35,132,67)',
    'rgb(0,104,55)',
    'rgb(0,69,41)'];

  var greyColors = ['rgb(255,255,255)','rgb(240,240,240)','rgb(217,217,217)','rgb(189,189,189)','rgb(150,150,150)','rgb(115,115,115)','rgb(82,82,82)','rgb(37,37,37)','rgb(0,0,0)'];

	var map = L.map('main-map', {
		center: [30.26618, -97.74467], //Austin!
		zoom: 12,
		scrollWheelZoom: false,
		layers: [grayscale] //include more options in array like terrain
	});

	var baseMaps = {
	    "Grayscale": grayscale
	    // "Terrain": terrain, //removing other tiles now for simplicity
	};

	var districtLines = L.geoJson( districts, {
		weight: 1,
		opacity: 1,
		color: '#666',
		fillOpacity: 0
	}).addTo(map)


  // Heatmap layer and Ring Colors
	var heatmap = L.geoJson( parkAccessRing, {
		style: function style(feature){
			return {
				fillColor: getRingColor(feature.properties.distance_l),
				weight: 0,
				opacity: 0,
				fillOpacity: 0.5
			};
		}
	}).addTo(map)

	function getRingColor(d) {
		return d === "> 1 mile" ? '#FF8080' :
		 			 d === "1 mile" 	? '#FFB380' :
					 d === "1/2 mile" ? '#FFE680' :
					 d === "1/4 mile" ? '#E5F57F' :
					 d === "500'" 		? '#BBE47F' :
					 d === "100'" 		? '#9BD37F' :
					 										'#FF8080';
	}

	function getParkColor(d) {
    // LOGIC: return cemeteries as gray, OSM Parks as green5,
    // undeveloped parks as brown, all others as green.
    return d.properties.PARK_TYPE === "Cemetery" ? greyColors[5]  :
           d.id                                  ? greenColors[5] :
           d.properties.am_plus_fac_sum > 0      ? '#56DD54' : "#9f7048";
	}

	function onEachFeature(feature, layer) {
		var parkName 	   = feature.properties.PARK_NAME,
  			parkAcres 	 = feature.properties.PARK_ACRES.toFixed(2),
  			parkType 		 = feature.properties.PARK_TYPE,
  			parkStatus	 = feature.properties.DEVELOPMEN,
        parkAmen     = feature.properties.amenities_count,
        parkFac      = feature.properties.facilities_count,
        parkTrails   = feature.properties.trails_count,
  			popupContent = "<p><span class='park-title'>" + parkName + "</span> \
  											<br>" + parkAcres + " Acres \
  											<br>Park Type: " + parkType +
  											"<br>Status: " + parkStatus +
  											"<br>" + parkAmen + " Amenities, " + parkFac + " Facilities, " + parkTrails + " Trails</p>";

	    if (feature.properties) {
	        layer.bindPopup( popupContent );
	    }
	}


  // create Array of parks by "PARK_TYPE"
  var parksByType = _.groupBy(parks.features, function(n){
    return n.properties.PARK_TYPE
  });

  var cemeteries        = parksByType["Cemetery"],
      districtParks     = parksByType["District"],
      golfCourses       = parksByType["Golf Course"],
      greenbelts        = parksByType["Greenbelt"],
      metroParks        = parksByType["Metropolitan"],
      naturePreserves   = parksByType["Nature Preserve"],
      neighborhoodParks = parksByType["Neighborhood"],
      plantingStrips    = parksByType["Planting Strips/Triangles"],
      pocketParks       = parksByType["Pocket"],
      schoolParks       = parksByType["School"],
      specialParks      = parksByType["Special"];

  var drawLayer = function(layer, popup){
    return L.geoJson(layer, {
      style: function style(feature){
        return {
          fillColor: getParkColor(feature),
          weight: 1,
          opacity: 0.7,
          color: '#44A048',
          fillOpacity: 0.7
        };
      },
      onEachFeature: popup
    }).addTo(map);
  }

  var cemeteryLayer     = drawLayer(cemeteries, onEachFeature),
      districtParkLayer = drawLayer(districtParks, onEachFeature),
      golfLayer         = drawLayer(golfCourses, onEachFeature),
      greenbeltLayer    = drawLayer(greenbelts, onEachFeature),
      metroParkLayer    = drawLayer(metroParks, onEachFeature),
      naturePresLayer   = drawLayer(naturePreserves, onEachFeature),
      neighborhoodLayer = drawLayer(neighborhoodParks, onEachFeature),
      plantingLayer     = drawLayer(plantingStrips, onEachFeature),
      pocketLayer       = drawLayer(pocketParks, onEachFeature),
      schoolLayer       = drawLayer(schoolParks, onEachFeature),
      specialLayer      = drawLayer(specialParks, onEachFeature),
      osmParksLayer     = drawLayer(osmParks, onEachOSMPark);

  function onEachOSMPark(feature, layer){
    	var parkName     = feature.properties.name || 'Unnamed Park',
          popupContent = "<p><span class='park-title'>"+parkName+"</span> \
                          <br>Park Type: Non-PARD Facility</p>";

      if (feature.properties) {
          layer.bindPopup( popupContent );
      }
  }

	var parksOn = true;
	function toggleParksLayer(){
		if (parksOn === true){
			map.removeLayer(parkLayer);
		} else {
			map.addLayer(parkLayer);
		}
		parksOn = !parksOn;
	}


	var overlayMaps = {
		// "Parks": parkLayer,
    "Non-PARD Parks": osmParksLayer,
    "Cemeteries": cemeteryLayer,
    "Golf Course": golfLayer,
    "School Parks": schoolLayer,
    "Heatmap": heatmap
	};

	L.control.layers(baseMaps, overlayMaps, {collapsed: true, autoZIndex: true}).addTo(map);

	function isInArray(value, array) {
	  return array.indexOf(value) > -1;
	}

	// adding district shapefiles to Map
	var districtLayer;
	function addSingleDistrictLayer(districtNum){
		districtLayer = L.geoJson(districts.features[districtNum], {
			style: function style(feature) {
				return {
					fillColor: "transparent",
					weight: 3,
					opacity: 1,
					color: '#666',
					dashArray: '',
				};
			}
		}).addTo(map);
    districtLayer.bringToBack();
		map.fitBounds(districtLayer.getBounds());
	}

	// Loading Data with D3
	var distDemoData,
		  parkAcreageData,
		  censusData;

	queue()
	  .defer(d3.json, "data/district-demographics.json")
	  .defer(d3.json, "data/park-acreage-data.json")
	  .defer(d3.json, "data/census-tract.json")
	  .await(analyze);

	function analyze(error, demographics, parks, census) {
	  if(error) { console.log(error); }

	  distDemoData 		  = demographics;
	  parkAcreageData 	= parks;
	  censusData 		    = census;

	}

	// d3.json("data/district-demographics.json", function(data) {
	// 	distDemoData = data;
	// 	console.log(distDemoData[0]);
	// });

	// d3.json("data/district-park-acreage.json", function(data) {
	// 	parkAcreageData = data;<commit_msg>We are using this heavy file right now<commit_after>(function(){

  "use strict";

	$('.parks').click( toggleParksLayer );

	// $('.districts-toggles li').on( 'click', function(){
	// 	$this = $(this);
	// 	var districtNum = parseInt($this.data('district'));
	// 	var districtIndex = districtNum - 1;
	// 	if (districtLayer){ map.removeLayer(districtLayer); };
	// 	addSingleDistrictLayer(districtIndex);
	// });

	var grayscale = L.tileLayer.provider('CartoDB.Positron');
		// terrain = L.tileLayer.provider('Stamen.Terrain');
		// blackAndWhite = 'OpenStreetMap.BlackAndWhite'
		// 'Thunderforest.Transport'
		// 'OpenMapSurfer.Roads'
		// 'OpenMapSurfer.Grayscale'
		// 'Stamen.Toner'
		// 'Esri.WorldGrayCanvas'
		// 'CartoDB.DarkMatter'

  var greenColors = [
    'rgb(255,255,229)',
    'rgb(247,252,185)',
    'rgb(217,240,163)',
    'rgb(173,221,142)',
    'rgb(120,198,121)',
    'rgb(65,171,93)',
    'rgb(35,132,67)',
    'rgb(0,104,55)',
    'rgb(0,69,41)'];

  var greyColors = ['rgb(255,255,255)','rgb(240,240,240)','rgb(217,217,217)','rgb(189,189,189)','rgb(150,150,150)','rgb(115,115,115)','rgb(82,82,82)','rgb(37,37,37)','rgb(0,0,0)'];

	var map = L.map('main-map', {
		center: [30.26618, -97.74467], //Austin!
		zoom: 12,
		scrollWheelZoom: false,
		layers: [grayscale] //include more options in array like terrain
	});

	var baseMaps = {
	    "Grayscale": grayscale
	    // "Terrain": terrain, //removing other tiles now for simplicity
	};

	var districtLines = L.geoJson( districts, {
		weight: 1,
		opacity: 1,
		color: '#666',
		fillOpacity: 0
	}).addTo(map)


  // Heatmap layer and Ring Colors
	var heatmap = L.geoJson( parkAccessRing, {
		style: function style(feature){
			return {
				fillColor: getRingColor(feature.properties.distance_l),
				weight: 0,
				opacity: 0,
				fillOpacity: 0.5
			};
		}
	}).addTo(map)

	function getRingColor(d) {
		return d === "> 1 mile" ? '#FF8080' :
		 			 d === "1 mile" 	? '#FFB380' :
					 d === "1/2 mile" ? '#FFE680' :
					 d === "1/4 mile" ? '#E5F57F' :
					 d === "500'" 		? '#BBE47F' :
					 d === "100'" 		? '#9BD37F' :
					 										'#FF8080';
	}

	function getParkColor(d) {
    // LOGIC: return cemeteries as gray, OSM Parks as green5,
    // undeveloped parks as brown, all others as green.
    return d.properties.PARK_TYPE === "Cemetery" ? greyColors[5]  :
           d.id                                  ? greenColors[5] :
           d.properties.am_plus_fac_sum > 0      ? '#56DD54' : "#9f7048";
	}

	function onEachFeature(feature, layer) {
		var parkName 	   = feature.properties.PARK_NAME,
  			parkAcres 	 = feature.properties.PARK_ACRES.toFixed(2),
  			parkType 		 = feature.properties.PARK_TYPE,
  			parkStatus	 = feature.properties.DEVELOPMEN,
        parkAmen     = feature.properties.amenities_count,
        parkFac      = feature.properties.facilities_count,
        parkTrails   = feature.properties.trails_count,
  			popupContent = "<p><span class='park-title'>" + parkName + "</span> \
  											<br>" + parkAcres + " Acres \
  											<br>Park Type: " + parkType +
  											"<br>Status: " + parkStatus +
  											"<br>" + parkAmen + " Amenities, " + parkFac + " Facilities, " + parkTrails + " Trails</p>";

	    if (feature.properties) {
	        layer.bindPopup( popupContent );
	    }
	}


  // create Array of parks by "PARK_TYPE"
  var parksByType = _.groupBy(parks.features, function(n){
    return n.properties.PARK_TYPE
  });

  var cemeteries        = parksByType["Cemetery"],
      districtParks     = parksByType["District"],
      golfCourses       = parksByType["Golf Course"],
      greenbelts        = parksByType["Greenbelt"],
      metroParks        = parksByType["Metropolitan"],
      naturePreserves   = parksByType["Nature Preserve"],
      neighborhoodParks = parksByType["Neighborhood"],
      plantingStrips    = parksByType["Planting Strips/Triangles"],
      pocketParks       = parksByType["Pocket"],
      schoolParks       = parksByType["School"],
      specialParks      = parksByType["Special"];

  var drawLayer = function(layer, popup){
    return L.geoJson(layer, {
      style: function style(feature){
        return {
          fillColor: getParkColor(feature),
          weight: 1,
          opacity: 0.7,
          color: '#44A048',
          fillOpacity: 0.7
        };
      },
      onEachFeature: popup
    }).addTo(map);
  }

  var cemeteryLayer     = drawLayer(cemeteries, onEachFeature),
      districtParkLayer = drawLayer(districtParks, onEachFeature),
      golfLayer         = drawLayer(golfCourses, onEachFeature),
      greenbeltLayer    = drawLayer(greenbelts, onEachFeature),
      metroParkLayer    = drawLayer(metroParks, onEachFeature),
      naturePresLayer   = drawLayer(naturePreserves, onEachFeature),
      neighborhoodLayer = drawLayer(neighborhoodParks, onEachFeature),
      plantingLayer     = drawLayer(plantingStrips, onEachFeature),
      pocketLayer       = drawLayer(pocketParks, onEachFeature),
      schoolLayer       = drawLayer(schoolParks, onEachFeature),
      specialLayer      = drawLayer(specialParks, onEachFeature),
      osmParksLayer     = drawLayer(osmParks, onEachOSMPark);

  function onEachOSMPark(feature, layer){
    	var parkName     = feature.properties.name || 'Unnamed Park',
          popupContent = "<p><span class='park-title'>"+parkName+"</span> \
                          <br>Park Type: Non-PARD Facility</p>";

      if (feature.properties) {
          layer.bindPopup( popupContent );
      }
  }

	var parksOn = true;
	function toggleParksLayer(){
		if (parksOn === true){
			map.removeLayer(parkLayer);
		} else {
			map.addLayer(parkLayer);
		}
		parksOn = !parksOn;
	}


	var overlayMaps = {
		// "Parks": parkLayer,
    "Non-PARD Parks": osmParksLayer,
    "Cemeteries": cemeteryLayer,
    "Golf Course": golfLayer,
    "School Parks": schoolLayer,
    "Heatmap": heatmap
	};

	L.control.layers(baseMaps, overlayMaps, {collapsed: true, autoZIndex: true}).addTo(map);

	function isInArray(value, array) {
	  return array.indexOf(value) > -1;
	}

	// adding district shapefiles to Map
	var districtLayer;
	function addSingleDistrictLayer(districtNum){
		districtLayer = L.geoJson(districts.features[districtNum], {
			style: function style(feature) {
				return {
					fillColor: "transparent",
					weight: 3,
					opacity: 1,
					color: '#666',
					dashArray: '',
				};
			}
		}).addTo(map);
    districtLayer.bringToBack();
		map.fitBounds(districtLayer.getBounds());
	}

	// Loading Data with D3
	var distDemoData,
		  parkAcreageData,
		  censusData;

	queue()
	  .defer(d3.json, "data/district-demographics.json")
	  .defer(d3.json, "data/park-acreage-data.json")
	  // .defer(d3.json, "data/census-tract.json")
	  .await(analyze);

	function analyze(error, demographics, parks, census) {
	  if(error) { console.log(error); }

	  distDemoData 		  = demographics;
	  parkAcreageData 	= parks;
	  // censusData 		    = census;

	}

	// d3.json("data/district-demographics.json", function(data) {
	// 	distDemoData = data;
	// 	console.log(distDemoData[0]);
	// });

	// d3.json("data/district-park-acreage.json", function(data) {
	// 	parkAcreageData = data;
{'fraction_non_alphanumeric': 0.14989890538938855, 'fraction_numerical': 0.03304747960677683, 'mean_word_length': 2.925561029009305, 'pattern_counts': {'":': 16, '<': 29, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6130156', 'n_tokens_mistral': 5724, 'n_tokens_neox': 4875, 'n_words': 880}