add tweaks of data retrieval zoom level, to make better use of the cache and be friendlier to the API in some cases
also, default-intel-detail and show-more-portals plugins fixed - the logic has been moved into IITC core, with the plugins just setting flags to change behaviour
This commit is contained in:
parent
8ce28334cc
commit
333c1a6daf
77
code/map_data_calc_tools.js
Normal file → Executable file
77
code/map_data_calc_tools.js
Normal file → Executable file
@ -26,6 +26,83 @@ window.getMapZoomTileParameters = function(zoom) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
window.getDataZoomForMapZoom = function(zoom) {
|
||||||
|
// we can fetch data at a zoom level different to the map zoom.
|
||||||
|
|
||||||
|
//NOTE: the specifics of this are tightly coupled with the above ZOOM_TO_LEVEL and ZOOM_TO_TILES_PER_EDGE arrays
|
||||||
|
|
||||||
|
// firstly, some of IITCs zoom levels, depending on base map layer, can be higher than stock. limit zoom level
|
||||||
|
if (zoom > 18) {
|
||||||
|
zoom = 18;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!window.CONFIG_ZOOM_DEFAULT_DETAIL_LEVEL) {
|
||||||
|
// some reasonable optimisations of data retreival
|
||||||
|
|
||||||
|
switch(zoom) {
|
||||||
|
case 2:
|
||||||
|
case 3:
|
||||||
|
// 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)
|
||||||
|
zoom = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (window.CONFIG_ZOOM_SHOW_MORE_PORTALS) {
|
||||||
|
if (zoom >= 15) {
|
||||||
|
//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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return zoom;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
window.lngToTile = function(lng, params) {
|
window.lngToTile = function(lng, params) {
|
||||||
return Math.floor((lng + 180) / 360 * params.tilesPerEdge);
|
return Math.floor((lng + 180) / 360 * params.tilesPerEdge);
|
||||||
}
|
}
|
||||||
|
@ -179,9 +179,12 @@ window.MapDataRequest.prototype.refresh = function() {
|
|||||||
|
|
||||||
|
|
||||||
var bounds = clampLatLngBounds(map.getBounds());
|
var bounds = clampLatLngBounds(map.getBounds());
|
||||||
var zoom = map.getZoom();
|
var mapZoom = map.getZoom();
|
||||||
|
|
||||||
|
var dataZoom = getDataZoomForMapZoom(mapZoom);
|
||||||
|
|
||||||
|
var tileParams = getMapZoomTileParameters(dataZoom);
|
||||||
|
|
||||||
var tileParams = getMapZoomTileParameters(zoom);
|
|
||||||
|
|
||||||
//DEBUG: resize the bounds so we only retrieve some data
|
//DEBUG: resize the bounds so we only retrieve some data
|
||||||
//bounds = bounds.pad(-0.4);
|
//bounds = bounds.pad(-0.4);
|
||||||
@ -203,10 +206,10 @@ window.MapDataRequest.prototype.refresh = function() {
|
|||||||
//setTimeout (function(){ map.removeLayer(debugrect2); }, 10*1000);
|
//setTimeout (function(){ map.removeLayer(debugrect2); }, 10*1000);
|
||||||
|
|
||||||
// store the parameters used for fetching the data. used to prevent unneeded refreshes after move/zoom
|
// store the parameters used for fetching the data. used to prevent unneeded refreshes after move/zoom
|
||||||
this.fetchedDataParams = { bounds: dataBounds, mapZoom: map.getZoom(), zoom: zoom };
|
this.fetchedDataParams = { bounds: dataBounds, mapZoom: mapZoom, dataZoom: dataZoom };
|
||||||
|
|
||||||
|
|
||||||
window.runHooks ('mapDataRefreshStart', {bounds: bounds, zoom: zoom, minPortalLevel: tileParams.level, tileBounds: dataBounds});
|
window.runHooks ('mapDataRefreshStart', {bounds: bounds, mapZoom: mapZoom, dataZoom: dataZoom, minPortalLevel: tileParams.level, tileBounds: dataBounds});
|
||||||
|
|
||||||
this.render.startRenderPass();
|
this.render.startRenderPass();
|
||||||
this.render.clearPortalsBelowLevel(tileParams.level);
|
this.render.clearPortalsBelowLevel(tileParams.level);
|
||||||
@ -216,7 +219,7 @@ window.MapDataRequest.prototype.refresh = function() {
|
|||||||
|
|
||||||
this.render.processGameEntities(artifact.getArtifactEntities());
|
this.render.processGameEntities(artifact.getArtifactEntities());
|
||||||
|
|
||||||
console.log('requesting data tiles at zoom '+zoom+' (L'+tileParams.level+'+ portals, '+tileParams.tilesPerEdge+' tiles per global edge), map zoom is '+map.getZoom());
|
console.log('requesting data tiles at zoom '+dataZoom+' (L'+tileParams.level+'+ portals, '+tileParams.tilesPerEdge+' tiles per global edge), map zoom is '+mapZoom);
|
||||||
|
|
||||||
|
|
||||||
this.cachedTileCount = 0;
|
this.cachedTileCount = 0;
|
||||||
@ -228,7 +231,7 @@ window.MapDataRequest.prototype.refresh = function() {
|
|||||||
var tilesToFetchDistance = {};
|
var tilesToFetchDistance = {};
|
||||||
|
|
||||||
// map center point - for fetching center tiles first
|
// map center point - for fetching center tiles first
|
||||||
var mapCenterPoint = map.project(map.getCenter(), zoom);
|
var mapCenterPoint = map.project(map.getCenter(), mapZoom);
|
||||||
|
|
||||||
// y goes from left to right
|
// y goes from left to right
|
||||||
for (var y = y1; y <= y2; y++) {
|
for (var y = y1; y <= y2; y++) {
|
||||||
@ -263,7 +266,7 @@ window.MapDataRequest.prototype.refresh = function() {
|
|||||||
var lngCenter = (lngEast+lngWest)/2;
|
var lngCenter = (lngEast+lngWest)/2;
|
||||||
var tileLatLng = L.latLng(latCenter,lngCenter);
|
var tileLatLng = L.latLng(latCenter,lngCenter);
|
||||||
|
|
||||||
var tilePoint = map.project(tileLatLng, zoom);
|
var tilePoint = map.project(tileLatLng, mapZoom);
|
||||||
|
|
||||||
var delta = mapCenterPoint.subtract(tilePoint);
|
var delta = mapCenterPoint.subtract(tilePoint);
|
||||||
var distanceSquared = delta.x*delta.x + delta.y*delta.y;
|
var distanceSquared = delta.x*delta.x + delta.y*delta.y;
|
||||||
|
@ -282,6 +282,7 @@ window.androidPermalink = function() {
|
|||||||
|
|
||||||
window.getMinPortalLevel = function() {
|
window.getMinPortalLevel = function() {
|
||||||
var z = map.getZoom();
|
var z = map.getZoom();
|
||||||
|
z = getDataZoomForMapZoom(z);
|
||||||
return getMapZoomTileParameters(z).level;
|
return getMapZoomTileParameters(z).level;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// @id iitc-plugin-default-intel-detail@jonatkins
|
// @id iitc-plugin-default-intel-detail@jonatkins
|
||||||
// @name IITC plugin: Default intel detail level
|
// @name IITC plugin: Default intel detail level
|
||||||
// @category Tweaks
|
// @category Tweaks
|
||||||
// @version 0.1.1.@@DATETIMEVERSION@@
|
// @version 0.2.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@@
|
||||||
@ -24,23 +24,9 @@ window.plugin.defaultIntelDetail = function() {};
|
|||||||
|
|
||||||
window.plugin.defaultIntelDetail.setup = function() {
|
window.plugin.defaultIntelDetail.setup = function() {
|
||||||
|
|
||||||
// var stockIntelDetail = nemesis.dashboard.zoomlevel.ZOOM_TO_LOD_;
|
// 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
|
||||||
// // save the original function - so we can chain to it for levels we don't modify
|
window.CONFIG_ZOOM_DEFAULT_DETAIL_LEVEL=true;
|
||||||
// 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);
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// @id iitc-plugin-show-more-portals@jonatkins
|
// @id iitc-plugin-show-more-portals@jonatkins
|
||||||
// @name IITC plugin: Show more portals
|
// @name IITC plugin: Show more portals
|
||||||
// @category Tweaks
|
// @category Tweaks
|
||||||
// @version 0.1.7.@@DATETIMEVERSION@@
|
// @version 0.2.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@@
|
||||||
@ -24,27 +24,9 @@ window.plugin.showMorePortals = function() {};
|
|||||||
|
|
||||||
window.plugin.showMorePortals.setup = function() {
|
window.plugin.showMorePortals.setup = function() {
|
||||||
|
|
||||||
// // save the original function - so we can chain to it for levels we don't modify
|
// NOTE: the logic required is closely tied to the IITC+stock map detail level code - so the logic is moved there now
|
||||||
// var origGetMinPortalLevelForZoom = window.getMinPortalLevelForZoom;
|
// and just enabled by this flag
|
||||||
//
|
window.CONFIG_ZOOM_SHOW_MORE_PORTALS=true;
|
||||||
// // replace the window.getMinPortalLevelForZoom function - modify behaviour when L1+ or L3+ portals are shown
|
|
||||||
//
|
|
||||||
// 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 (level == 1) level = 0;
|
|
||||||
// if (level == 3) level = 2;
|
|
||||||
//
|
|
||||||
// return level;
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user