// ==UserScript== // @id max-links@boombuler // @name IITC plugin: Max Links // @category Layer // @version 0.4.0.@@DATETIMEVERSION@@ // @updateURL @@UPDATEURL@@ // @downloadURL @@DOWNLOADURL@@ // @description [@@BUILDNAME@@-@@BUILDDATE@@] Calculates how to link the portals to create the maximum number of fields. Enable from the layer chooser. // @include https://www.ingress.com/intel* // @include http://www.ingress.com/intel* // @match https://www.ingress.com/intel* // @match http://www.ingress.com/intel* // @grant none // ==/UserScript== @@PLUGINSTART@@ // PLUGIN START //////////////////////////////////////////////////////// // use own namespace for plugin window.plugin.maxLinks = function() {}; // const values window.plugin.maxLinks.MAX_DRAWN_LINKS = 400; window.plugin.maxLinks.MAX_DRAWN_LINKS_INCREASED_LIMIT = 1000; window.plugin.maxLinks.STROKE_STYLE = { color: '#FF0000', opacity: 1, weight: 2, clickable: false, dashArray: [8,6], smoothFactor: 10, }; window.plugin.maxLinks.layer = null; window.plugin.maxLinks._updating = false; window.plugin.maxLinks._renderLimitReached = false; window.plugin.maxLinks.Point = function(x,y) { this.x=x; this.y=y; } window.plugin.maxLinks.Point.prototype.toString = function() { return this.x+","+this.y; } window.plugin.maxLinks.updateLayer = function() { if (window.plugin.maxLinks._updating || window.plugin.maxLinks.layer === null || !window.map.hasLayer(window.plugin.maxLinks.layer)) return; window.plugin.maxLinks._updating = true; window.plugin.maxLinks.layer.clearLayers(); var locations = []; $.each(window.portals, function(guid, portal) { var loc = portal.options.details.locationE6; var nloc = new window.plugin.maxLinks.Point(loc.latE6/1E6, loc.lngE6/1E6); locations.push(nloc); }); var triangles = window.delaunay.triangulate(locations); var drawnLinkCount = 0; window.plugin.maxLinks._renderLimitReached = false; var renderLimit = window.USE_INCREASED_RENDER_LIMIT ? window.plugin.maxLinks.MAX_DRAWN_LINKS_INCREASED_LIMIT : window.plugin.maxLinks.MAX_DRAWN_LINKS; var orderedPoints = function(a,b) { if(a.x renderLimit ) { window.plugin.maxLinks._renderLimitReached = true; return false; //$.each break } }); window.plugin.maxLinks._updating = false; window.renderUpdateStatus(); } window.plugin.maxLinks.setup = function() { try { console.log('Loading delaunay JS now'); } catch(e) {} @@INCLUDERAW:external/delaunay.js@@ try { console.log('done loading delaunay JS'); } catch(e) {} window.plugin.maxLinks.layer = L.layerGroup([]); window.addHook('checkRenderLimit', function(e) { if (window.map.hasLayer(window.plugin.maxLinks.layer) && window.plugin.maxLinks._renderLimitReached) e.reached = true; }); window.addHook('requestFinished', function(e) { window.plugin.maxLinks.updateLayer(); }); window.map.on('layeradd', function(e) { if (e.layer === window.plugin.maxLinks.layer) window.plugin.maxLinks.updateLayer(); }); window.map.on('zoomend moveend', window.plugin.maxLinks.updateLayer); window.addLayerGroup('Maximum Links', window.plugin.maxLinks.layer, false); } var setup = window.plugin.maxLinks.setup; // PLUGIN END ////////////////////////////////////////////////////////// @@PLUGINEND@@