various tweaks to how IITC requests data tiles from the servers
- change TILES_PER_REQUEST to 25, instead of 10 - to match current stock intel site - modify the zoom level faking IITC does. it still makes good use of IITC's caching, but no longer switches to a zoom level with larger tiles. recent changes to tile parameters for L8 portals on the standard intel site suggests that it's nicer to the servers to request more, but smaller, tiles, than fewer but larger ones - restored the 'show less portals when zoomed out' plugin. however, this works differently now. rather than faking the zoom level for larger tiles, it now effectively applies the portal level filter used by the standard site. just as many requests as stock, but much smaller responses with fewer portals, so faster rendering
This commit is contained in:
parent
66cc162e38
commit
caff9340d3
@ -17,9 +17,36 @@ window.getMapZoomTileParameters = function(zoom) {
|
|||||||
MAX_TILES_PER_EDGE = 9000;
|
MAX_TILES_PER_EDGE = 9000;
|
||||||
ZOOM_TO_LEVEL = [8, 8, 8, 8, 7, 7, 7, 6, 6, 5, 4, 4, 3, 2, 2, 1, 1];
|
ZOOM_TO_LEVEL = [8, 8, 8, 8, 7, 7, 7, 6, 6, 5, 4, 4, 3, 2, 2, 1, 1];
|
||||||
|
|
||||||
|
// the current API allows the client to request a minimum portal level. the ZOOM_TO_LEVEL list are minimums
|
||||||
|
// however, in my view, this can return excessive numbers of portals in many cases. let's try an optional reduction
|
||||||
|
// of detail level at some zoom levels
|
||||||
|
|
||||||
|
var level = ZOOM_TO_LEVEL[zoom] || 0; // default to level 0 (all portals) if not in array
|
||||||
|
|
||||||
|
if (window.CONFIG_ZOOM_SHOW_LESS_PORTALS_ZOOMED_OUT) {
|
||||||
|
switch(level) {
|
||||||
|
case 7:
|
||||||
|
// usually L7+ portals - switch to L8 only
|
||||||
|
level = 8;
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
// usually L6+ portals - switch to L7+
|
||||||
|
level = 7;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 5:
|
||||||
|
case 4:
|
||||||
|
// level 4+ and 5+ - switch to L6+
|
||||||
|
level = 6;
|
||||||
|
break;
|
||||||
|
|
||||||
|
// no modifications for lower levels
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
level: ZOOM_TO_LEVEL[zoom] || 0, // default to level 0 (all portals) if not in array
|
level: level,
|
||||||
|
maxLevel: ZOOM_TO_LEVEL[zoom] || 0, // for reference, for log purposes, etc
|
||||||
tilesPerEdge: ZOOM_TO_TILES_PER_EDGE[zoom] || MAX_TILES_PER_EDGE,
|
tilesPerEdge: ZOOM_TO_TILES_PER_EDGE[zoom] || MAX_TILES_PER_EDGE,
|
||||||
zoom: zoom // include the zoom level, for reference
|
zoom: zoom // include the zoom level, for reference
|
||||||
};
|
};
|
||||||
@ -37,63 +64,31 @@ window.getDataZoomForMapZoom = function(zoom) {
|
|||||||
zoom = 20;
|
zoom = 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var origTileParams = getMapZoomTileParameters(zoom);
|
||||||
|
|
||||||
if (!window.CONFIG_ZOOM_DEFAULT_DETAIL_LEVEL) {
|
if (!window.CONFIG_ZOOM_DEFAULT_DETAIL_LEVEL) {
|
||||||
// some reasonable optimisations of data retreival
|
|
||||||
|
|
||||||
switch(zoom) {
|
// to improve the cacheing performance, we try and limit the number of zoom levels we retrieve data for
|
||||||
case 2:
|
// to avoid impacting server load, we keep ourselves restricted to a zoom level with the sane numbre
|
||||||
case 3:
|
// of tilesPerEdge and portal levels visible
|
||||||
// L8 portals - fall back to the furthest out view. less detail, faster retreival. cache advantages when zooming
|
|
||||||
// (note: iitc + stock both limited so zoom 0 never possible)
|
while (zoom > 1) {
|
||||||
zoom = 1;
|
var newTileParams = getMapZoomTileParameters(zoom-1);
|
||||||
break;
|
if (newTileParams.tilesPerEdge != origTileParams.tilesPerEdge || newTileParams.level != origTileParams.level) {
|
||||||
|
// switching to zoom-1 would result in a different detail level - so we abort changing things
|
||||||
case 4:
|
|
||||||
// default is L7 - but this is a crazy number of tiles. fall back to L8 (but higher detail than above)
|
|
||||||
// (the back-end does, unfortunately, rarely (never?) returns large fields with L8-only portals
|
|
||||||
zoom = 3;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 5:
|
|
||||||
case 6:
|
|
||||||
// default L7 - pull out to furthest L7 zoom
|
|
||||||
zoom = 4;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 8:
|
|
||||||
// default L6 - pull back to highest L6 zoom
|
|
||||||
zoom = 7;
|
|
||||||
break;
|
|
||||||
|
|
||||||
// L5 portals - only one zoom level
|
|
||||||
|
|
||||||
case 11:
|
|
||||||
// default L4 - pull back to lower detail L4
|
|
||||||
zoom = 10;
|
|
||||||
break;
|
|
||||||
|
|
||||||
// L3 portals - only one zoom level
|
|
||||||
|
|
||||||
case 14:
|
|
||||||
// L2 portals - pull back to furthest
|
|
||||||
zoom = 13;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 16:
|
|
||||||
// L1 portals - pull back to furthest zoom
|
|
||||||
zoom = 15;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
if (zoom >= 18) {
|
|
||||||
// all portals - pull back to furthest zoom
|
|
||||||
zoom = 17;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
} else {
|
||||||
|
// changing to zoom = zoom-1 results in identical tile parameters - so we can safely step back
|
||||||
|
// with no increase in either server load or number of requests
|
||||||
|
zoom = zoom-1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (window.CONFIG_ZOOM_SHOW_MORE_PORTALS) {
|
if (window.CONFIG_ZOOM_SHOW_MORE_PORTALS) {
|
||||||
|
// this is, in theory, slightly 'unfriendly' to the servers. in practice, this isn't the case - and it can even be nicer
|
||||||
|
// as it vastly improves cacheing in IITC and also reduces the amount of panning/zooming a user would do
|
||||||
if (zoom >= 15 && zoom <= 16) {
|
if (zoom >= 15 && zoom <= 16) {
|
||||||
//L1+ and closer zooms. the 'all portals' zoom uses the same tile size, so it's no harm to request things at that zoom level
|
//L1+ and closer zooms. the 'all portals' zoom uses the same tile size, so it's no harm to request things at that zoom level
|
||||||
zoom = 17;
|
zoom = 17;
|
||||||
|
@ -25,7 +25,7 @@ window.MapDataRequest = function() {
|
|||||||
this.MAX_REQUESTS = 5;
|
this.MAX_REQUESTS = 5;
|
||||||
|
|
||||||
// this many tiles in one request
|
// this many tiles in one request
|
||||||
this.NUM_TILES_PER_REQUEST = 10;
|
this.NUM_TILES_PER_REQUEST = 25;
|
||||||
|
|
||||||
// number of times to retry a tile after an error (including "error: TIMEOUT" now - as stock intel does)
|
// number of times to retry a tile after an error (including "error: TIMEOUT" now - as stock intel does)
|
||||||
// TODO? different retry counters for TIMEOUT vs other errors..?
|
// TODO? different retry counters for TIMEOUT vs other errors..?
|
||||||
@ -232,7 +232,15 @@ window.MapDataRequest.prototype.refresh = function() {
|
|||||||
|
|
||||||
this.render.processGameEntities(artifact.getArtifactEntities());
|
this.render.processGameEntities(artifact.getArtifactEntities());
|
||||||
|
|
||||||
console.log('requesting data tiles at zoom '+dataZoom+' (L'+tileParams.level+'+ portals, '+tileParams.tilesPerEdge+' tiles per global edge), map zoom is '+mapZoom);
|
var logMessage = 'requesting data tiles at zoom '+dataZoom;
|
||||||
|
if (tileParams.level != tileParams.maxLevel) {
|
||||||
|
logMessage += ' (L'+tileParams.level+'+ portals - could have doneug L'+tileParams.maxLevel+'+';
|
||||||
|
} else {
|
||||||
|
logMessage += ' (L'+tileParams.level+'+ portals';
|
||||||
|
}
|
||||||
|
logMessage += ', '+tileParams.tilesPerEdge+' tiles per global edge), map zoom is '+mapZoom;
|
||||||
|
|
||||||
|
console.log(logMessage);
|
||||||
|
|
||||||
|
|
||||||
this.cachedTileCount = 0;
|
this.cachedTileCount = 0;
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @id iitc-plugin-show-less-portals@jonatkins
|
// @id iitc-plugin-show-less-portals@jonatkins
|
||||||
// @name IITC plugin: Show less portals when zoomed out
|
// @name IITC plugin: Show less portals when zoomed out
|
||||||
// @category Deleted
|
// @category Tweaks
|
||||||
// @version 0.2.0.@@DATETIMEVERSION@@
|
// @version 0.3.0.@@DATETIMEVERSION@@
|
||||||
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
|
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
|
||||||
// @updateURL @@UPDATEURL@@
|
// @updateURL @@UPDATEURL@@
|
||||||
// @downloadURL @@DOWNLOADURL@@
|
// @downloadURL @@DOWNLOADURL@@
|
||||||
// @description [@@BUILDNAME@@-@@BUILDDATE@@] IITC now defaults to showing fewer portals when zoomed out, making this plugin unnecessary.
|
// @description [@@BUILDNAME@@-@@BUILDDATE@@] Vastly reduce the detail level when zoomed out to level 11 or less (L4+ portals), to significantly reduce data usage when viewing large areas.
|
||||||
// @include https://www.ingress.com/intel*
|
// @include https://www.ingress.com/intel*
|
||||||
// @include http://www.ingress.com/intel*
|
// @include http://www.ingress.com/intel*
|
||||||
// @match https://www.ingress.com/intel*
|
// @match https://www.ingress.com/intel*
|
||||||
@ -14,3 +14,24 @@
|
|||||||
// @grant none
|
// @grant none
|
||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
|
||||||
|
@@PLUGINSTART@@
|
||||||
|
|
||||||
|
// PLUGIN START ////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
// use own namespace for plugin
|
||||||
|
window.plugin.showLessPortalsZoomedOut = function() {};
|
||||||
|
|
||||||
|
window.plugin.showLessPortalsZoomedOut.setup = function() {
|
||||||
|
|
||||||
|
// NOTE: the logic required is closely tied to the IITC+stock map detail level code - so the logic is moved there now
|
||||||
|
// and just enabled by this flag
|
||||||
|
window.CONFIG_ZOOM_SHOW_LESS_PORTALS_ZOOMED_OUT=true;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
var setup = window.plugin.showLessPortalsZoomedOut.setup;
|
||||||
|
|
||||||
|
// PLUGIN END //////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@@PLUGINEND@@
|
||||||
|
Loading…
x
Reference in New Issue
Block a user