update code to match stock site changes 2013-10-16

- new munge set
- modified map data tile ID/QK - now based on portal level rather than map zoom
This commit is contained in:
Jon Atkins 2013-10-16 03:11:19 +01:00
parent c3b6461d47
commit 1eea47ca99
3 changed files with 65 additions and 51 deletions

View File

@ -9,26 +9,33 @@
// Convertion functions courtesy of // Convertion functions courtesy of
// http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames // http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames
window.lngToTile = function(lng, zoom) {
return Math.floor((lng + 180) / 360 * Math.pow(2, (zoom>12)?zoom:(zoom+2))); window.levelToTilesPerEdge = function(level) {
var LEVEL_TO_TILES_PER_EDGE = [65536, 65536, 16384, 16384, 4096, 1536, 1024, 256, 32];
return LEVEL_TO_TILES_PER_EDGE[level];
} }
window.latToTile = function(lat, zoom) {
window.lngToTile = function(lng, level) {
return Math.floor((lng + 180) / 360 * levelToTilesPerEdge(level));
}
window.latToTile = function(lat, level) {
return Math.floor((1 - Math.log(Math.tan(lat * Math.PI / 180) + return Math.floor((1 - Math.log(Math.tan(lat * Math.PI / 180) +
1 / Math.cos(lat * Math.PI / 180)) / Math.PI) / 2 * Math.pow(2, (zoom>12)?zoom:(zoom+2))); 1 / Math.cos(lat * Math.PI / 180)) / Math.PI) / 2 * levelToTilesPerEdge(level));
} }
window.tileToLng = function(x, zoom) { window.tileToLng = function(x, level) {
return x / Math.pow(2, (zoom>12)?zoom:(zoom+2)) * 360 - 180; return x / levelToTilesPerEdge(level) * 360 - 180;
} }
window.tileToLat = function(y, zoom) { window.tileToLat = function(y, level) {
var n = Math.PI - 2 * Math.PI * y / Math.pow(2, (zoom>12)?zoom:(zoom+2)); var n = Math.PI - 2 * Math.PI * y / levelToTilesPerEdge(level);
return 180 / Math.PI * Math.atan(0.5 * (Math.exp(n) - Math.exp(-n))); return 180 / Math.PI * Math.atan(0.5 * (Math.exp(n) - Math.exp(-n)));
} }
window.pointToTileId = function(zoom, x, y) { window.pointToTileId = function(level, x, y) {
return zoom + "_" + x + "_" + y; return level + "_" + x + "_" + y;
} }
// given tile id and bounds, returns the format as required by the // given tile id and bounds, returns the format as required by the

View File

@ -187,21 +187,21 @@ window.MapDataRequest.prototype.refresh = function() {
//var debugrect = L.rectangle(bounds,{color: 'red', fill: false, weight: 4, opacity: 0.8}).addTo(map); //var debugrect = L.rectangle(bounds,{color: 'red', fill: false, weight: 4, opacity: 0.8}).addTo(map);
//setTimeout (function(){ map.removeLayer(debugrect); }, 10*1000); //setTimeout (function(){ map.removeLayer(debugrect); }, 10*1000);
var x1 = lngToTile(bounds.getWest(), zoom); var x1 = lngToTile(bounds.getWest(), minPortalLevel);
var x2 = lngToTile(bounds.getEast(), zoom); var x2 = lngToTile(bounds.getEast(), minPortalLevel);
var y1 = latToTile(bounds.getNorth(), zoom); var y1 = latToTile(bounds.getNorth(), minPortalLevel);
var y2 = latToTile(bounds.getSouth(), zoom); var y2 = latToTile(bounds.getSouth(), minPortalLevel);
// calculate the full bounds for the data - including the part of the tiles off the screen edge // calculate the full bounds for the data - including the part of the tiles off the screen edge
var dataBounds = L.latLngBounds([ var dataBounds = L.latLngBounds([
[tileToLat(y2+1,zoom), tileToLng(x1,zoom)], [tileToLat(y2+1,minPortalLevel), tileToLng(x1,minPortalLevel)],
[tileToLat(y1,zoom), tileToLng(x2+1,zoom)] [tileToLat(y1,minPortalLevel), tileToLng(x2+1,minPortalLevel)]
]); ]);
//var debugrect2 = L.rectangle(dataBounds,{color: 'magenta', fill: false, weight: 4, opacity: 0.8}).addTo(map); //var debugrect2 = L.rectangle(dataBounds,{color: 'magenta', fill: false, weight: 4, opacity: 0.8}).addTo(map);
//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, zoom: zoom }; this.fetchedDataParams = { bounds: dataBounds, zoom: zoom, minPortalLevel: minPortalLevel };
window.runHooks ('mapDataRefreshStart', {bounds: bounds, zoom: zoom, tileBounds: dataBounds}); window.runHooks ('mapDataRefreshStart', {bounds: bounds, zoom: zoom, tileBounds: dataBounds});
@ -228,11 +228,11 @@ window.MapDataRequest.prototype.refresh = function() {
for (var y = y1; y <= y2; y++) { for (var y = y1; y <= y2; y++) {
// x goes from bottom to top(?) // x goes from bottom to top(?)
for (var x = x1; x <= x2; x++) { for (var x = x1; x <= x2; x++) {
var tile_id = pointToTileId(zoom, x, y); var tile_id = pointToTileId(minPortalLevel, x, y);
var latNorth = tileToLat(y,zoom); var latNorth = tileToLat(y,minPortalLevel);
var latSouth = tileToLat(y+1,zoom); var latSouth = tileToLat(y+1,minPortalLevel);
var lngWest = tileToLng(x,zoom); var lngWest = tileToLng(x,minPortalLevel);
var lngEast = tileToLng(x+1,zoom); var lngEast = tileToLng(x+1,minPortalLevel);
this.debugTiles.create(tile_id,[[latSouth,lngWest],[latNorth,lngEast]]); this.debugTiles.create(tile_id,[[latSouth,lngWest],[latNorth,lngEast]]);

View File

@ -165,6 +165,39 @@ window.requestParameterMunges = [
inviteeEmailAddress: 'orc9ufg7rp7g1y9j', inviteeEmailAddress: 'orc9ufg7rp7g1y9j',
}, },
// set 5 - second update of 2013-10-16
{
'dashboard.getGameScore': '3b48kl956b33brrl', // GET_GAME_SCORE
'dashboard.getPaginatedPlextsV2': 'h785pmet6wrx6xoa', // GET_PAGINATED_PLEXTS
'dashboard.getThinnedEntitiesV4': '4gux7b0n3euu7e8y', // GET_THINNED_ENTITIES
'dashboard.getPlayersByGuids': 'nqm1kocgzspecpzv', // LOOKUP_PLAYERS
'dashboard.redeemReward': 'g618n6peb74u2ae9', // REDEEM_REWARD
'dashboard.sendInviteEmail': 'bsl4280bm39bkl3a', // SEND_INVITE_EMAIL
'dashboard.sendPlext': 'jym2hbw15i6uru7g', // SEND_PLEXT
method: 'g9cmy5g6vpxpmcxz',
version: 'blq7574e6kkg0fig', //guessed parameter name - only seen munged
version_parameter: '465c62b22b3bc9ecae01e08b30703752186a1dc9', // passed as the value to the above parameter
boundsParamsList: '45k478vh10jt1ik7',
id: '3eh1ynwxjy8c8rd5',
minLatE6: 'krpywcgq1voq71z3',
minLngE6: 'yo6lte88zvoneqi6',
maxLatE6: 'dncli54tfafmtk6y',
maxLngE6: '76pq437r7vm3osx9',
timestampMs: '2zlgpsg1x6i9720s',
qk: 'pzejivoj28p6kkry',
desiredNumItems: 'u3uxpkqd4pn37ydn',
minTimestampMs: 'msw5gcxhuuk46rb2',
maxTimestampMs: 'bps0ekgdzakdfvr0',
chatTab: 'pm4fm8bjvotjm30h', //guessed parameter name - only seen munged
ascendingTimestampOrder: '7qp8gv50ogelh7cs',
message: 'y599irwyfs45adp4',
latE6: '19ko11fmx32sjfqk',
lngE6: 'i8yjq6v2mjhze29d',
guids: 'szebfshb9f3uo2h9',
inviteeEmailAddress: 'qq4t7lhqphq7wqvh',
},
]; ];
window.activeRequestMungeSet = undefined; window.activeRequestMungeSet = undefined;
@ -393,35 +426,9 @@ window.getPortalDataZoom = function() {
window.getMinPortalLevelForZoom = function(z) { window.getMinPortalLevelForZoom = function(z) {
//based on code from stock gen_dashboard.js //based on code from stock gen_dashboard.js
switch(z) { var ZOOM_TO_LEVEL = [8, 8, 8, 8, 7, 7, 6, 6, 5, 4, 4, 3, 3, 2, 2, 1, 1];
case 0: var l = ZOOM_TO_LEVEL[z] || 0;
case 1: return l;
case 2:
case 3:
return 8;
case 4:
case 5:
return 7;
case 6:
case 7:
return 6;
case 8:
return 5;
case 9:
case 10:
return 4;
case 11:
case 12:
return 3;
case 13:
case 14:
return 2;
case 15:
case 16:
return 1;
default:
return 0
}
} }