<commit_before>;var WithinLayer = (function() {
	"use strict";
	//static methods & Properties
	var list = [],
		layers = [];

	function Constructor(layer) {
		list.push(layer);
	}

	Constructor.prototype = {

	};


	Constructor.addLayer = function(layer, type) {
		layer.layerType = type;
		layers.push(layer);
	};

	Constructor.isInside = function(parentLayer, childLayer) {
		switch (parentLayer.layerType) {
			//if it's a circle
			case 'circle':
				var circleInfoLatLng = parentLayer.getLatLng(),
					radius = parentLayer.getRadius(),
					ll = childLayer.getLatLng();

				return (geolib.isPointInCircle(
					{
						latitude: circleInfoLatLng.lat,
						longitude: circleInfoLatLng.lng
					},
					{
						latitude: ll.lat,
						longitude: ll.lng
					},
					radius
				));


			//if its any other shape
			case 'rectangle':
			case 'polygon':
				var geo = L.geoJson(parentLayer.toGeoJSON());

				return leafletPip.pointInLayer(list[j].getLatLng(), geo);

		}

		return false;
	};

	Constructor.getContained = function(fnIn, fnOut) {
		var i,
			max,
			layer,
			j = 0,
			maxJ = list.length,
			contained = [];

		for (i = 0, max = layers.length; i < max; i++) {
			layer = layers[i];

            //ensure that the layer has a map, otherwise it is deleted, thus continue over it
            if (!layer._map) {
                continue;
            }

			switch (layer.layerType) {
				case 'circle':
					var circleInfoLatLng = layer.getLatLng(),
						radius = layer.getRadius(),
						ll;

					for (j = 0; j < maxJ;j++) {
						ll = list[j].getLatLng();

						if (geolib.isPointInCircle(
							{
								latitude: circleInfoLatLng.lat,
								longitude: circleInfoLatLng.lng
							},
							{
								latitude: ll.lat,
								longitude: ll.lng
							},
							radius
						)) {
							contained.push(list[j]);

                            if (fnIn) {
                                fnIn.apply(list[j]);
                            }
						} else if (fnOut) {
                            fnOut.apply(list[j]);
                        }
					}
					break;
				case 'rectangle':
				case 'polygon':
                    var geo = L.geoJson(layer.toGeoJSON()),
                        inLayer;
					for (j = 0; j < maxJ;j++) {
                        inLayer = leafletPip.pointInLayer(list[j].getLatLng(), geo)
						if (inLayer.length > 0) {
							contained.push(list[j]);

                            if (fnIn) {
                                fnIn.apply(list[j]);
                            }
						} else if (fnOut) {
                            fnOut.apply(list[j]);
                        }
					}

					break;
			}
		}

		return contained;<commit_msg>Pre-check if point is already added.<commit_after>;var WithinLayer = (function() {
	"use strict";
	//static methods & Properties
	var list = [],
		layers = [];

	function Constructor(layer) {
		list.push(layer);
	}

	Constructor.prototype = {

	};


	Constructor.addLayer = function(layer, type) {
		layer.layerType = type;
		layers.push(layer);
	};

	Constructor.isInside = function(parentLayer, childLayer) {
		var ll;
		switch (parentLayer.layerType) {
			//if it's a circle
			case 'circle':
				var circleInfoLatLng = parentLayer.getLatLng(),
					radius = parentLayer.getRadius();

				ll = childLayer.getLatLng();

				return (geolib.isPointInCircle(
					{
						latitude: circleInfoLatLng.lat,
						longitude: circleInfoLatLng.lng
					},
					{
						latitude: ll.lat,
						longitude: ll.lng
					},
					radius
				));


			//if its any other shape
			default:
				var geoLls = [],
					i = 0,
					lls = parentLayer.getLatLngs();

				for (; i < lls.length; i++) {
					ll = lls[i];
					geoLls.push({
						latitude: ll.lat,
						longitude: ll.lng
					});
				}

				ll = childLayer.getLatLng();
				return geolib.isPointInside({
					latitude: ll.lat,
					longitude: ll.lng
				}, geoLls);

		}
	};

	Constructor.getContained = function(fnIn, fnOut) {
		var i,
			max,
			layer,
			j = 0,
			maxJ = list.length,
			contained = [],
			point,
			ll;

		for (i = 0, max = layers.length; i < max; i++) {
			layer = layers[i];

            //ensure that the layer has a map, otherwise it is deleted, thus continue over it
            if (!layer._map) {
                continue;
            }

			switch (layer.layerType) {
				case 'circle':
					var circleInfoLatLng = layer.getLatLng(),
						radius = layer.getRadius();

					for (j = 0; j < maxJ;j++) {
						point = list[j];

						ll = point.getLatLng();

						if (contained.indexOf(point) > -1) {
							//it is already added
						}
						else if (geolib.isPointInCircle(
							{
								latitude: circleInfoLatLng.lat,
								longitude: circleInfoLatLng.lng
							},
							{
								latitude: ll.lat,
								longitude: ll.lng
							},
							radius
						)) {
							contained.push(point);

                            if (fnIn) {
                                fnIn.apply(point);
                            }
						} else if (fnOut) {
                            fnOut.apply(point);
                        }
					}
					break;
				default:
					var geoLls = [],
						i = 0,
						lls = layer.getLatLngs();

					for (; i < lls.length; i++) {
						ll = lls[i];
						geoLls.push({
							latitude: ll.lat,
							longitude: ll.lng
						});
					}

					for (j = 0; j < maxJ;j++) {
						point = list[j];

						ll = point.getLatLng();

						if (contained.indexOf(point) > -1) {
							//it is already added
						}
						else if (geolib.isPointInside({
							latitude: ll.lat,
							longitude: ll.lng
						}, geoLls)) {
							contained.push(point);

                            if (fnIn) {
                                fnIn.apply(point);
                            }
						} else if (fnOut) {
                            fnOut.apply(point);
                        }
					}

					break;
			}
		}

		return contained;
{'fraction_non_alphanumeric': 0.12633542479226725, 'fraction_numerical': 0.0022045107681872137, 'mean_word_length': 1.5269922879177378, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 6, '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': '1146264', 'n_tokens_mistral': 2624, 'n_tokens_neox': 1881, 'n_words': 403}