<commit_before>
/*
 * L.MarkerClusterGroup extends L.FeatureGroup by clustering the markers contained within
 */

L.MarkerClusterGroup = L.FeatureGroup.extend({

	options: {
		//distanceToCluster: 10, //Any points closer than this will probably get put in to a cluster
		maxClusterRadius: 60, //A cluster will cover at most this many pixels from its center
		iconCreateFunction: function (childCount) {
			var c = ' marker-cluster-';
			if (childCount < 10) {
				c += 'small';
			} else if (childCount < 100) {
				c += 'medium';
			} else {
				c += 'large';
			}

			return new L.DivIcon({ html: '<div><span>' + childCount + '</span></div>', className: 'marker-cluster' + c, iconSize: new L.Point(40, 40) });
		}
	},

	initialize: function (options) {
		L.Util.setOptions(this, options);

		L.FeatureGroup.prototype.initialize.call(this, []);

		this._needsClustering = [];

		this._markersAndClustersAtZoom = {};
	},


	_sqDist: function (p1, p2) {
		var dx = p2.x - p1.x,
			dy = p2.y - p1.y;
		return dx * dx + dy * dy;
	},

	_zoomEnd: function () {
		this._animationStart();

		this._mergeSplitClusters();

		this._zoom = this._map._zoom;
	},

	_moveEnd: function () {
		if (this._inZoomAnimation) {
			return;
		}

		var l, i,
		    layers = this._layers,
		    bounds = this._getExpandedVisibleBounds(),
		    highestLevel = this._markersAndClustersAtZoom[this._highestZoom],
		    depth = this._zoom - this._highestZoom,
		    highestLevelClusters = highestLevel.clusters,
		    highestLevelUnclustered = highestLevel.unclustered;

		//Remove visible layers that are no longer visible
		for (i in layers) {
			l = layers[i];
			if (!bounds.contains(l.getLatLng())) {
				L.FeatureGroup.prototype.removeLayer.call(this, l);
			}
		}

		//Re-Check everyone for being in the viewport
		//Do the clusters (and their child unclustered ones) recursively for performance
		for (i = 0; i < highestLevelClusters.length; i++) {
			l = highestLevelClusters[i];
			if (bounds.intersects(l._bounds)) {
				l._recursivelyAddChildrenToMap(null, depth, bounds);
			}
		}

		//Do the markers at this level too
		for (i = 0; i < highestLevelUnclustered.length; i++) {
			l = highestLevelUnclustered[i];
			if (bounds.contains(l.getLatLng())) {
				L.FeatureGroup.prototype.addLayer.call(this, l);
			}
		}
	},

	_generateInitialClusters: function () {
		var res = this._cluster([], [], this._needsClustering, this._map.getZoom());

		this._markersAndClustersAtZoom[this._map._zoom] = res;
		//Remember the highest zoom level we've seen and the current zoom level
		this._highestZoom = this._zoom = this._map._zoom;

		//Make things appear on the map
		for (var i = 0; i < res.clusters.length; i++) {
			//TODO: Bounds
			res.clusters[i]._addToMap();
		}
		for (var j = 0; j < res.unclustered.length; j++) {
			//TODO: Bounds
			L.FeatureGroup.prototype.addLayer.call(this, res.unclustered[j]);
		}
	},

	//Merge and split any existing clusters that are too big or small
	_mergeSplitClusters: function () {
		var map = this._map,
			newState,
		    depth = Math.abs(this._map._zoom - this._zoom);

		if (this._zoom < this._map._zoom) { //Zoom in, split
			var startingClusters = this._markersAndClustersAtZoom[this._zoom].clusters,
			    startingUnclustered = this._markersAndClustersAtZoom[this._zoom].unclustered;

			while (this._zoom < this._map._zoom) { //Split each intermediate layer if required
				var currentClusters = this._markersAndClustersAtZoom[this._zoom].clusters;

				this._zoom++;

				newState = this._markersAndClustersAtZoom[this._zoom];

				if (!newState) { //If we don't have clusters for the new level, calculate them
					newState = { 'clusters': [], 'unclustered': [] };

					for (var i = 0; i < currentClusters.length; i++) {
						var newClusters;
						if (currentClusters[i]._childClusters.length > 0) {

							//Child clusters should always be 0 as we haven't calculated clusters for this level
							throw 'something is wrong, childClusters length should be 0: ' + currentClusters[i]._childClusters.length;
						} else {<commit_msg>Formatting<commit_after>
/*
 * L.MarkerClusterGroup extends L.FeatureGroup by clustering the markers contained within
 */

L.MarkerClusterGroup = L.FeatureGroup.extend({

	options: {
		//distanceToCluster: 10, //Any points closer than this will probably get put in to a cluster
		maxClusterRadius: 60, //A cluster will cover at most this many pixels from its center
		iconCreateFunction: function (childCount) {
			var c = ' marker-cluster-';
			if (childCount < 10) {
				c += 'small';
			} else if (childCount < 100) {
				c += 'medium';
			} else {
				c += 'large';
			}

			return new L.DivIcon({ html: '<div><span>' + childCount + '</span></div>', className: 'marker-cluster' + c, iconSize: new L.Point(40, 40) });
		}
	},

	initialize: function (options) {
		L.Util.setOptions(this, options);

		L.FeatureGroup.prototype.initialize.call(this, []);

		this._needsClustering = [];

		this._markersAndClustersAtZoom = {};
	},


	_sqDist: function (p1, p2) {
		var dx = p2.x - p1.x,
			dy = p2.y - p1.y;
		return dx * dx + dy * dy;
	},

	_zoomEnd: function () {
		this._animationStart();

		this._mergeSplitClusters();

		this._zoom = this._map._zoom;
	},

	_moveEnd: function () {
		if (this._inZoomAnimation) {
			return;
		}

		var l, i,
		    layers = this._layers,
		    bounds = this._getExpandedVisibleBounds(),
		    highestLevel = this._markersAndClustersAtZoom[this._highestZoom],
		    depth = this._zoom - this._highestZoom,
		    highestLevelClusters = highestLevel.clusters,
		    highestLevelUnclustered = highestLevel.unclustered;

		//Remove visible layers that are no longer visible
		for (i in layers) {
			l = layers[i];
			if (!bounds.contains(l.getLatLng())) {
				L.FeatureGroup.prototype.removeLayer.call(this, l);
			}
		}

		//Re-Check everyone for being in the viewport
		//Do the clusters (and their child unclustered ones) recursively for performance
		for (i = 0; i < highestLevelClusters.length; i++) {
			l = highestLevelClusters[i];
			if (bounds.intersects(l._bounds)) {
				l._recursivelyAddChildrenToMap(null, depth, bounds);
			}
		}

		//Do the markers at this level too
		for (i = 0; i < highestLevelUnclustered.length; i++) {
			l = highestLevelUnclustered[i];
			if (bounds.contains(l.getLatLng())) {
				L.FeatureGroup.prototype.addLayer.call(this, l);
			}
		}
	},

	_generateInitialClusters: function () {
		var res = this._cluster([], [], this._needsClustering, this._map.getZoom());

		this._markersAndClustersAtZoom[this._map._zoom] = res;
		//Remember the highest zoom level we've seen and the current zoom level
		this._highestZoom = this._zoom = this._map._zoom;

		//Make things appear on the map
		for (var i = 0; i < res.clusters.length; i++) {
			//TODO: Bounds
			res.clusters[i]._addToMap();
		}
		for (var j = 0; j < res.unclustered.length; j++) {
			//TODO: Bounds
			L.FeatureGroup.prototype.addLayer.call(this, res.unclustered[j]);
		}
	},

	//Merge and split any existing clusters that are too big or small
	_mergeSplitClusters: function () {
		var map = this._map,
		    newState,
		    depth = Math.abs(this._map._zoom - this._zoom);

		if (this._zoom < this._map._zoom) { //Zoom in, split
			var startingClusters = this._markersAndClustersAtZoom[this._zoom].clusters,
			    startingUnclustered = this._markersAndClustersAtZoom[this._zoom].unclustered;

			while (this._zoom < this._map._zoom) { //Split each intermediate layer if required
				var currentClusters = this._markersAndClustersAtZoom[this._zoom].clusters;

				this._zoom++;

				newState = this._markersAndClustersAtZoom[this._zoom];

				if (!newState) { //If we don't have clusters for the new level, calculate them
					newState = { 'clusters': [], 'unclustered': [] };

					for (var i = 0; i < currentClusters.length; i++) {
						var newClusters;
						if (currentClusters[i]._childClusters.length > 0) {

							//Child clusters should always be 0 as we haven't calculated clusters for this level
							throw 'something is wrong, childClusters length should be 0: ' + currentClusters[i]._childClusters.length;
						} else {
{'fraction_non_alphanumeric': 0.13044548363278366, 'fraction_numerical': 0.006645335958651243, 'mean_word_length': 3.359978540772532, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 13, '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': '7288280', 'n_tokens_mistral': 3082, 'n_tokens_neox': 2617, 'n_words': 692}