updates to the portal detail level handling

- iitc now defaults to lower detail than the standard intel site when zoomed out - it loads much faster, shows more than enough for general use, and is less likely to trigger 'excessive requests' issues
- show more portals plugin: updated for interface changes
- show-less-portals-zoomed-out: deleted (this is now the IITC default)
- new plugin: default-intel-detail - restores the original IITC behaviour on zoom to portal detail level mapping. not recommended

for #656 number 3
This commit is contained in:
Jon Atkins
2013-11-24 04:59:41 +00:00
parent 1f25428388
commit f22d185b5b
6 changed files with 74 additions and 98 deletions

View File

@ -91,7 +91,7 @@ window.MapDataRequest.prototype.mapMoveStart = function() {
window.MapDataRequest.prototype.mapMoveEnd = function() {
var bounds = clampLatLngBounds(map.getBounds());
var zoom = getPortalDataZoom();
var zoom = map.getZoom();
if (this.fetchedDataParams) {
// we have fetched (or are fetching) data...
@ -180,7 +180,7 @@ window.MapDataRequest.prototype.refresh = function() {
var bounds = clampLatLngBounds(map.getBounds());
var zoom = getPortalDataZoom();
var zoom = map.getZoom();
var minPortalLevel = getMinPortalLevelForZoom(zoom);
//DEBUG: resize the bounds so we only retrieve some data

View File

@ -67,13 +67,7 @@ window.startRefreshTimeout = function(override) {
window.requests._quickRefreshPending = false;
t = REFRESH*1000;
// new getThinnedEntitiesV4 involves a LOT more requests when zoomed out above a data level of 13
// so, to give the refresh a chance to complete (and also reduce load on niantic servers), boost the refresh interval
// in this case
// (TODO: complete rewrite of refresh+request handling. don't start timer until complete, and retry error=TIMEOUT requests)
if (getPortalDataZoom() <=12 ) t = t*4;
var adj = ZOOM_LEVEL_ADJ * (18 - getPortalDataZoom());
var adj = ZOOM_LEVEL_ADJ * (18 - map.getZoom());
if(adj > 0) t += adj*1000;
}
var next = new Date(new Date().getTime() + t).toLocaleTimeString();

View File

@ -276,41 +276,20 @@ window.androidPermalink = function() {
}
window.getPortalDataZoom = function() {
var mapZoom = map.getZoom();
// make sure we're dealing with an integer here
// (mobile: a float somehow gets through in some cases!)
var z = parseInt(mapZoom);
// limiting the maximum zoom level for data retrieval reduces the number of requests at high zoom levels
// (as all portal data is retrieved at z=17, why retrieve multiple z=18 tiles when fewer z=17 would do?)
// very effective along with the new cache code
if (z > 17) z=17;
//sanity check - should never happen
if (z < 0) z=0;
return z;
}
window.getMinPortalLevelForZoom = function(z) {
// try to use the zoom-to-level mapping from the stock intel page, if available
var ZOOM_TO_LEVEL;
try {
ZOOM_TO_LEVEL = nemesis.dashboard.zoomlevel.ZOOM_TO_LOD_;
} catch(e) {
//based on code from stock gen_dashboard.js
ZOOM_TO_LEVEL = [8, 8, 8, 8, 7, 7, 6, 6, 5, 4, 4, 3, 3, 2, 2, 1, 1];
}
// these values are from the stock intel map. however, they're too detailed for reasonable speed, and increasing
// detail at a higher zoom level shows enough detail still, AND speeds up IITC considerably
//var ZOOM_TO_LEVEL = [8, 8, 8, 8, 7, 7, 6, 6, 5, 4, 4, 3, 3, 2, 2, 1, 1];
var ZOOM_TO_LEVEL = [8, 8, 8, 8, 8, 8, 7, 7, 6, 5, 4, 4, 3, 2, 2, 1, 1];
var l = ZOOM_TO_LEVEL[z] || 0;
return l;
}
window.getMinPortalLevel = function() {
var z = getPortalDataZoom();
var z = map.getZoom();
return getMinPortalLevelForZoom(z);
}

View File

@ -0,0 +1,51 @@
// ==UserScript==
// @id iitc-plugin-default-intel-detail@jonatkins
// @name IITC plugin: Default intel detail level
// @category Tweaks
// @version 0.1.0.@@DATETIMEVERSION@@
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
// @updateURL @@UPDATEURL@@
// @downloadURL @@DOWNLOADURL@@
// @description [@@BUILDNAME@@-@@BUILDDATE@@] Use the portal level detail levels from the standard intel site. By default, IITC shows less detail when zoomed out, as this is enough for general use, is more friendly to the niantic servers, and loads much faster. This plugin restores the default zoom level to portal level mapping. Note: using this plugin causes a larger number of requests to the intel server, and at high resolutions can cause excessive requests to be made (yes: the default intel site also has this problem!), so it is not recommended except for low resolution screens.
// @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.defaultIntelDetail = function() {};
window.plugin.defaultIntelDetail.setup = function() {
var stockIntelDetail = nemesis.dashboard.zoomlevel.ZOOM_TO_LOD_;
// save the original function - so we can chain to it for levels we don't modify
var origGetMinPortalLevelForZoom = window.getMinPortalLevelForZoom;
// replace the window.getMinPortalLevelForZoom function - modify behaviour when L1+ or L3+ portals are shown
window.getMinPortalLevelForZoom = function(z) {
// for the further out zoom levels, use the stock intel site detail levels
if (z <= 11) {
return stockIntelDetail[z];
}
// for the closer zoom levels, stock intel and IITC default is the same. falling back
// in this case allows this plugin to work alongside show-more-portals
return origGetMinPortalLevelForZoom(z);
}
};
var setup = window.plugin.defaultIntelDetail.setup;
// PLUGIN END //////////////////////////////////////////////////////////
@@PLUGINEND@@

View File

@ -1,12 +1,12 @@
// ==UserScript==
// @id iitc-plugin-show-less-portals@jonatkins
// @name IITC plugin: Show less portals when zoomed out
// @category Tweaks
// @version 0.1.4.@@DATETIMEVERSION@@
// @category Deleted
// @version 0.2.0.@@DATETIMEVERSION@@
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
// @updateURL @@UPDATEURL@@
// @downloadURL @@DOWNLOADURL@@
// @description [@@BUILDNAME@@-@@BUILDDATE@@] Decrease the portal detail level used when zoomed out. This can speed up map loading, decrease the amount of data used, and solve excessive request issues. Only applies when zoomed out to show no closer than L3 portals. May stop display of the smaller links/fields.
// @description [@@BUILDNAME@@-@@BUILDDATE@@] IITC now defaults to showing fewer portals when zoomed out, making this plugin unnecessary
// @include https://www.ingress.com/intel*
// @include http://www.ingress.com/intel*
// @match https://www.ingress.com/intel*
@ -14,46 +14,3 @@
// @grant none
// ==/UserScript==
@@PLUGINSTART@@
// PLUGIN START ////////////////////////////////////////////////////////
// use own namespace for plugin
window.plugin.showLessPortals = function() {};
window.plugin.showLessPortals.setup = function() {
// save the original function - so we can chain to it for levels we don't modify
var origGetPortalDataZoom = window.getPortalDataZoom;
// replace the window.getPortalDataZoom function - modify behaviour when zoomed close
window.getPortalDataZoom = function() {
var mapZoom = map.getZoom();
// the latest intel site update, as of 2013-10-16, requests a silly number of map tiles at the larger zoom levels
// IITC matches the behaviour by default, but it makes sense to reduce the detail level sooner
// at the largest scale zooms - move back two levels
if (mapZoom <= 7) {
return Math.max(mapZoom-2,0);
}
// intermediate zoom levels - move back one
if (mapZoom <= 11) {
return Math.max(mapZoom-1,0);
}
// otherwise revert to default behaviour
return origGetPortalDataZoom();
}
};
var setup = window.plugin.showLessPortals.setup;
// PLUGIN END //////////////////////////////////////////////////////////
@@PLUGINEND@@

View File

@ -2,11 +2,11 @@
// @id iitc-plugin-show-more-portals@jonatkins
// @name IITC plugin: Show more portals
// @category Tweaks
// @version 0.1.5.@@DATETIMEVERSION@@
// @version 0.1.6.@@DATETIMEVERSION@@
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
// @updateURL @@UPDATEURL@@
// @downloadURL @@DOWNLOADURL@@
// @description [@@BUILDNAME@@-@@BUILDDATE@@] Boost the detail level of portals shown so that unclaimed portals are visible when normally L1+ portals would be shown, and L2+ are visible when normally L3+ are shown
// @description [@@BUILDNAME@@-@@BUILDDATE@@] Boost the detail level of portals shown so that unclaimed portals are visible when normally L1+ portals would be shown, and L2+ are visible when normally L3+ are shown. Recent protocol changes by Niantic means this no longer sends more requests than the standard intel site, and can mean fewer requests.
// @include https://www.ingress.com/intel*
// @include http://www.ingress.com/intel*
// @match https://www.ingress.com/intel*
@ -25,29 +25,24 @@ window.plugin.showMorePortals = function() {};
window.plugin.showMorePortals.setup = function() {
// save the original function - so we can chain to it for levels we don't modify
var origGetPortalDataZoom = window.getPortalDataZoom;
var origGetMinPortalLevelForZoom = window.getMinPortalLevelForZoom;
// replace the window.getPortalDataZoom function - modify behaviour when zoomed close
// replace the window.getMinPortalLevelForZoom function - modify behaviour when L1+ or L3+ portals are shown
window.getPortalDataZoom = function() {
var mapZoom = map.getZoom();
window.getMinPortalLevelForZoom = function(z) {
var level = origGetMinPortalLevelForZoom(z);
// as of 2013-10-16...
// the stock site uses the same tile size for both L1+ portals and all portals
// therefore, changing the L1+ zoom levels into all portals zoom level is not unfriendly to the servers
// and the same applies for L2+ and L3+ detail levels
// (in some ways it's nicer, as IITC caches better)
if (mapZoom >= 15) {
return 17;
}
// and, the same scale for L2+ and L3+ portals. again, forcing the level down isn't unfriendly to the servers
// (ditto on the caching)
if (mapZoom >= 12) {
return 13;
}
if (level == 1) level = 0;
if (level == 3) level = 2;
return origGetPortalDataZoom();
return level;
}