<commit_before>var NetworkViz = (function () {

	var f = 32768;

	var nodeLookup = {};
	var nodeList = [];

	var initialized = false;
	var map, labelLayer;

	var hoveredNodes = [];
	var activeNodes = [];

	var clickHandler = false;

	function init() {
		if (!node_positions) return console.error('node_positions.js not loaded ... yet')

		initialized = true;

		var keys = Object.keys(node_positions);
		var n = node_positions[keys[0]].length;
		for (var i = 0; i < n; i++) {
			var node = {};
			keys.forEach(function (key) {
				node[key] = node_positions[key][i];
			})
			node.x += f/2;
			node.y += f/2;
			nodeLookup[node.id] = node;
			nodeList.push(node);
		}

		var projection = {
			project: function (latlng) {
				return L.point(latlng.lng/f, -latlng.lat/f);
			},
			unproject: function (point) {
				return L.latLng(-point.y*f, point.x*f);
			}
		};

		var crs = L.extend({}, L.CRS, {
			projection: projection,
			transformation: new L.Transformation(1, 0, 1, 0),
			scale: function (zoom) {
				return 256*Math.pow(2, zoom);
			}
		});

		$('#networkviz').css({height:'100%'});

		map = L.map('networkviz', {
			minZoom: 0,
			maxZoom: 7,
			zoom: 5,
			center: [-0.5*f,0.5*f],
			maxBounds: L.latLngBounds([-f,0],[0,f]),
			crs: crs,
			zoomAnimation: true,
			zoomControl:false,
			scrollWheelZoom:true
		});
		map.addControl( L.control.zoom({position: 'bottomleft'}) )


		map.on('mousemove', mousemove);
		map.on('click', mouseclick);

		var layer = L.tileLayer('http://lobbyradar.opendatacloud.de/lobbynetwork/tiles/{z}/{y}/{x}.png', {
			minZoom: 0,
			maxZoom: 7,
			maxNativeZoom: 7,
			tileSize: 256,
			zoomOffset: 0,
			// attribution: '<a href="https://events.ccc.de/congress/2013/">31C3</a> | Improve the code on <a href="https://github.com/OpenDataCity/31c3-map">GitHub</a>!',
			attribution: '',
			noWrap: true
		})
		
		layer.addTo(map);

		labelLayer = L.layerGroup();
		labelLayer.addTo(map);
	}

	function mousemove(e) {
		var point = e.latlng;

		hoveredNodes.forEach(function (node) {
			if (!node.active) hideLabel(node);
			$('#networkviz').css( 'cursor', '-webkit-grab' );

		})
		hoveredNodes = [];

		nodeList.forEach(function (node) {
			var d = Math.sqrt(sqr(node.x - point.lng) + sqr(node.y + point.lat));
			if (d < node.r) {
				hoveredNodes.push(node);
				showLabel(node);
				$('#networkviz').css( 'cursor', 'pointer' );

			};
		})
	}

	function mouseclick(e) {
		if (!clickHandler) return;

		var point = e.latlng;
		var bestNode = false;
		var bestDist = 1e10;

		nodeList.forEach(function (node) {
			var d = Math.sqrt(sqr(node.x - point.lng) + sqr(node.y + point.lat));
			if ((d < node.r) && (d < bestDist)) {
				bestDist = d;
				bestNode = node;
			};
		});

		if (bestNode) {
			console.debug();
			clickHandler(bestNode.id);
			e.originalEvent.preventDefault();
		}
	}<commit_msg>adding find node function<commit_after>var NetworkViz = (function () {

	var f = 32768;

	var nodeLookup = {};
	var nodeList = [];

	var initialized = false;
	var map, labelLayer;

	var hoveredNodes = [];
	var activeNodes = [];

	var clickHandler = false;

	function init() {
		if (!node_positions) return console.error('node_positions.js not loaded ... yet')

		initialized = true;

		var keys = Object.keys(node_positions);
		var n = node_positions[keys[0]].length;
		for (var i = 0; i < n; i++) {
			var node = {};
			keys.forEach(function (key) {
				node[key] = node_positions[key][i];
			})
			node.x += f/2;
			node.y += f/2;
			nodeLookup[node.id] = node;
			nodeList.push(node);
		}

		var projection = {
			project: function (latlng) {
				return L.point(latlng.lng/f, -latlng.lat/f);
			},
			unproject: function (point) {
				return L.latLng(-point.y*f, point.x*f);
			}
		};

		var crs = L.extend({}, L.CRS, {
			projection: projection,
			transformation: new L.Transformation(1, 0, 1, 0),
			scale: function (zoom) {
				return 256*Math.pow(2, zoom);
			}
		});

		$('#networkviz').css({height:'100%'});

		map = L.map('networkviz', {
			minZoom: 0,
			maxZoom: 7,
			zoom: 5,
			center: [-0.5*f,0.5*f],
			maxBounds: L.latLngBounds([-f,0],[0,f]),
			crs: crs,
			zoomAnimation: true,
			zoomControl:false,
			scrollWheelZoom:true
		});
		map.addControl( L.control.zoom({position: 'bottomleft'}) )


		map.on('mousemove', mousemove);
		map.on('click', mouseclick);

		var layer = L.tileLayer('http://lobbyradar.opendatacloud.de/lobbynetwork/tiles/{z}/{y}/{x}.png', {
			minZoom: 0,
			maxZoom: 7,
			maxNativeZoom: 7,
			tileSize: 256,
			zoomOffset: 0,
			// attribution: '<a href="https://events.ccc.de/congress/2013/">31C3</a> | Improve the code on <a href="https://github.com/OpenDataCity/31c3-map">GitHub</a>!',
			attribution: '',
			noWrap: true
		})
		
		layer.addTo(map);

		labelLayer = L.layerGroup();
		labelLayer.addTo(map);
	}

	function mousemove(e) {
		hoveredNodes.forEach(function (node) {
			if (!node.active) hideLabel(node);
			$('#networkviz').css( 'cursor', '-webkit-grab' );
		});

		hoveredNodes = [];

		var node = findNode(e.latlng);

		if (node) {
			hoveredNodes.push(node);
			showLabel(node);
			$('#networkviz').css( 'cursor', 'pointer' );
		}
	}

	function mouseclick(e) {
		if (!clickHandler) return;

		var point = e.latlng;
		var bestNode = false;
		var bestDist = 1e10;

		nodeList.forEach(function (node) {
			var d = Math.sqrt(sqr(node.x - point.lng) + sqr(node.y + point.lat));
			if ((d < node.r) && (d < bestDist)) {
				bestDist = d;
				bestNode = node;
			};
		});

		if (bestNode) {
			console.debug();
			clickHandler(bestNode.id);
			e.originalEvent.preventDefault();
		}
	}

	function findNode(point) {
		var bestNode = false;
		var bestDist = 1e10;

		nodeList.forEach(function (node) {
			var d = Math.sqrt(sqr(node.x - point.lng) + sqr(node.y + point.lat));
			if (d < bestDist) {
				bestDist = d;
				bestNode = node;
			};
		});

		var border = Math.pow(0.5, map.getZoom()-10);

		if (bestDist < bestNode.r + border) return bestNode;
		return false;
	}
{'fraction_non_alphanumeric': 0.18296159651182292, 'fraction_numerical': 0.01760858628207278, 'mean_word_length': 3.161898115840893, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 11, 'https://': 4, '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': '1423661', 'n_tokens_mistral': 2722, 'n_tokens_neox': 2280, 'n_words': 455}