max-links: only count portals visible on screen against the portal limit. the recent larger data tiles for map data pull in more off-screen data, making the old test unreliable in some cases

This commit is contained in:
Jon Atkins 2014-03-23 20:55:32 +00:00
parent 95ed0ddd7b
commit 4a4346a419

View File

@ -2,7 +2,7 @@
// @id max-links@boombuler
// @name IITC plugin: Max Links
// @category Layer
// @version 0.4.2.@@DATETIMEVERSION@@
// @version 0.4.3.@@DATETIMEVERSION@@
// @updateURL @@UPDATEURL@@
// @downloadURL @@DOWNLOADURL@@
// @description [@@BUILDNAME@@-@@BUILDDATE@@] Calculate how to link the portals to create a reasonably tidy set of links/fields. Enable from the layer chooser. (Max Links is a poor name, but remains for historical reasons.)
@ -68,11 +68,6 @@ window.plugin.maxLinks.updateLayer = function() {
window.plugin.maxLinks.layer.clearLayers();
if (Object.keys(window.portals).length > window.plugin.maxLinks.MAX_PORTALS_TO_LINK) {
window.plugin.maxLinks.addErrorMarker();
return;
}
var locations = [];
var bounds = map.getBounds();
@ -81,9 +76,15 @@ window.plugin.maxLinks.updateLayer = function() {
if (bounds.contains(ll)) {
var p = map.project (portal.getLatLng(), window.plugin.maxLinks.PROJECT_ZOOM);
locations.push(p);
if (locations.length > window.plugin.maxLinks.MAX_PORTALS_TO_LINK) return false; //$.each break
}
});
if (locations.length > window.plugin.maxLinks.MAX_PORTALS_TO_LINK) {
window.plugin.maxLinks.addErrorMarker();
return;
}
var triangles = window.delaunay.triangulate(locations);
var drawnLinkCount = 0;