<commit_before>/* globals window, _, VIZI, Q, THREE */
(function() {
	"use strict";

	VIZI.Grid = (function() {
		var Grid = function() {
			VIZI.Log("Inititialising grid manager");

			_.extend(this, VIZI.Mediator);

			// Reference to geo class
			this.geo = VIZI.Geo.getInstance();

			// Location of grid center
			this.pos2d = new THREE.Vector2();
			this.centerTile = [];

			// Tile size and zoom level comes from VIZI.Geo

			// Tiles per direction for high detail
			this.tilesPerDirectionHigh = 1;

			// Tiles per direction for low detail
			this.tilesPerDirectionLow = 6;

			// Calculated pixel tile size
			this.tileSize = 0;

			// Grid bounds for high detail (in TMS values)
			this.boundsHigh = {};

			// Grid bounds for high detail (lon, lat)
			this.boundsHighLonLat = {};

			// Grid bounds for low detail (in TMS values)
			this.boundsLow = {};

			// Grid bounds for low detail (lon, lat)
			this.boundsLowLonLat = {};

			// Debug grid model
			this.gridModel = new THREE.Object3D();

			this.subscribe("centerPositionChanged", this.onCenterChanged);
		};

		Grid.prototype.init = function(coords) {
			var projCoords = this.geo.projection(coords);

			this.pos2d.x = projCoords[0];
			this.pos2d.y = projCoords[1];

			this.centerTile = this.lonlat2tile(coords[0], coords[1], this.geo.tileZoom, true);

			this.boundsHigh = this.getBounds(this.tilesPerDirectionHigh);
			this.boundsLow = this.getBounds(this.tilesPerDirectionLow);

			this.boundsHighLonLat = this.getBoundsLonLat(this.boundsHigh);
			this.boundsLowLonLat = this.getBoundsLonLat(this.boundsLow);

			// Create debug model for grid
			var lonLatMin = this.tile2lonlat(Math.floor(this.centerTile[0]), Math.floor(this.centerTile[1]), this.geo.tileZoom);
			var lonLatMax = this.tile2lonlat(Math.floor(this.centerTile[0])+1, Math.floor(this.centerTile[1])+1, this.geo.tileZoom);

			// Why is this tilesize so random?
			this.tileSize = this.geo.projection(lonLatMax)[0] - this.geo.projection(lonLatMin)[0];
			
			var tileGeom = new THREE.PlaneGeometry( this.tileSize, this.tileSize, 1, 1 );
			var tileCount = [this.boundsHigh.e-this.boundsHigh.w, this.boundsHigh.s-this.boundsHigh.n];
			// Rows
			for (var i = 0; i < tileCount[0]; i++) {
				// Columns
				for (var j = 0; j < tileCount[1]; j++) {
					var tileCoords = [this.boundsHigh.w + j, this.boundsHigh.n + i];
						
					var tileMat = new THREE.MeshBasicMaterial({color: new THREE.Color(0xFFFFFF * Math.random()), transparent: true, opacity: 0.6});
					var tile = new THREE.Mesh(tileGeom, tileMat);
					var position = this.geo.projection(this.tile2lonlat(tileCoords[0], tileCoords[1], this.geo.tileZoom));

					tile.position.y = 10;
					tile.position.x = position[0] + this.tileSize / 2;
					tile.position.z = position[1] + this.tileSize / 2;
					tile.rotation.x = - 90 * Math.PI / 180;

					this.gridModel.add(tile);
				}
			}

			this.publish("addToScene", this.gridModel);

			return Q.fcall(function() {});
		};

		Grid.prototype.update = function() {
			// Store old position and bounds
			var oldPos2d = this.pos2d.clone();

			var oldBoundsHigh = {
				n: this.boundsHigh.n,
				e: this.boundsHigh.e,
				s: this.boundsHigh.s,
				w: this.boundsHigh.w
			};

			var oldBoundsLow = {
				n: this.boundsLow.n,
				e: this.boundsLow.e,
				s: this.boundsLow.s,
				w: this.boundsLow.w
			};
			// Update central position
			// Calculate bounds
		};<commit_msg>Changed grid geom plane to line<commit_after>/* globals window, _, VIZI, Q, THREE */
(function() {
	"use strict";

	VIZI.Grid = (function() {
		var Grid = function() {
			VIZI.Log("Inititialising grid manager");

			_.extend(this, VIZI.Mediator);

			// Reference to geo class
			this.geo = VIZI.Geo.getInstance();

			// Location of grid center
			this.pos2d = new THREE.Vector2();
			this.centerTile = [];

			// Tile size and zoom level comes from VIZI.Geo

			// Tiles per direction for high detail
			this.tilesPerDirectionHigh = 1;

			// Tiles per direction for low detail
			this.tilesPerDirectionLow = 3;

			// Calculated pixel tile size
			this.tileSize = 0;

			// Grid bounds for high detail (in TMS values)
			this.boundsHigh = {};

			// Grid bounds for high detail (lon, lat)
			this.boundsHighLonLat = {};

			// Grid bounds for low detail (in TMS values)
			this.boundsLow = {};

			// Grid bounds for low detail (lon, lat)
			this.boundsLowLonLat = {};

			// Debug grid model
			this.gridModel = new THREE.Object3D();

			this.subscribe("centerPositionChanged", this.onCenterChanged);
		};

		Grid.prototype.init = function(coords) {
			var projCoords = this.geo.projection(coords);

			this.pos2d.x = projCoords[0];
			this.pos2d.y = projCoords[1];

			this.centerTile = this.lonlat2tile(coords[0], coords[1], this.geo.tileZoom, true);

			this.boundsHigh = this.getBounds(this.tilesPerDirectionHigh);
			this.boundsLow = this.getBounds(this.tilesPerDirectionLow);

			this.boundsHighLonLat = this.getBoundsLonLat(this.boundsHigh);
			this.boundsLowLonLat = this.getBoundsLonLat(this.boundsLow);

			// Create debug model for grid
			var lonLatMin = this.tile2lonlat(Math.floor(this.centerTile[0]), Math.floor(this.centerTile[1]), this.geo.tileZoom);
			var lonLatMax = this.tile2lonlat(Math.floor(this.centerTile[0])+1, Math.floor(this.centerTile[1])+1, this.geo.tileZoom);

			// Why is this tilesize so random?
			this.tileSize = this.geo.projection(lonLatMax)[0] - this.geo.projection(lonLatMin)[0];
			
			var tileLineMat = new THREE.LineBasicMaterial( { color: 0xcc0000, linewidth: 6 } );
			var tileLineGeom = new THREE.Geometry();

			var vertices = tileLineGeom.vertices;
			vertices.push(new THREE.Vector3(0, 0, 0));
			vertices.push(new THREE.Vector3(this.tileSize, 0, 0));
			vertices.push(new THREE.Vector3(this.tileSize, 0, this.tileSize));
			vertices.push(new THREE.Vector3(0, 0, this.tileSize));
			vertices.push(new THREE.Vector3(0, 0, 0));

			tileLineGeom.computeLineDistances();

			var tileCount = [this.boundsHigh.e-this.boundsHigh.w, this.boundsHigh.s-this.boundsHigh.n];
			// Rows
			for (var i = 0; i < tileCount[0]; i++) {
				// Columns
				for (var j = 0; j < tileCount[1]; j++) {
					var tileCoords = [this.boundsHigh.w + j, this.boundsHigh.n + i];

					var position = this.geo.projection(this.tile2lonlat(tileCoords[0], tileCoords[1], this.geo.tileZoom));

					var tileLine = new THREE.Line(tileLineGeom, tileLineMat);
					tileLine.position.y = 1;
					tileLine.position.x = position[0];
					tileLine.position.z = position[1];

					this.gridModel.add(tileLine);
				}
			}

			this.publish("addToScene", this.gridModel);

			return Q.fcall(function() {});
		};

		Grid.prototype.update = function() {
			// Store old position and bounds
			var oldPos2d = this.pos2d.clone();

			var oldBoundsHigh = {
				n: this.boundsHigh.n,
				e: this.boundsHigh.e,
				s: this.boundsHigh.s,
				w: this.boundsHigh.w
			};

			var oldBoundsLow = {
				n: this.boundsLow.n,
				e: this.boundsLow.e,
				s: this.boundsLow.s,
				w: this.boundsLow.w
			};
			// Update central position
			// Calculate bounds
		};
{'fraction_non_alphanumeric': 0.14112162734849554, 'fraction_numerical': 0.0148326034750671, 'mean_word_length': 3.2193087008343264, 'pattern_counts': {'":': 0, '<': 7, '<?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': '188616', 'n_tokens_mistral': 2941, 'n_tokens_neox': 2436, 'n_words': 534}