map data tile tweaks. tiles are put into buckets based on a simple tile count, rather than coordinates. should help things when re-requesting failed tiles when the others are cached - and possibly is closer behaviour to the stock intel page

This commit is contained in:
Jon Atkins
2013-07-25 02:33:08 +01:00
parent 5760f9b7a8
commit e9ea00cd08

View File

@ -114,7 +114,7 @@ window.requestData = function() {
expireDataCache(); expireDataCache();
//a limit on the number of map tiles to be pulled in a single request //a limit on the number of map tiles to be pulled in a single request
var MAX_TILES_PER_BUCKET = 11; var MAX_TILES_PER_BUCKET = 18;
// the number of separate buckets. more can be created if the size exceeds MAX_TILES_PER_BUCKET // the number of separate buckets. more can be created if the size exceeds MAX_TILES_PER_BUCKET
var BUCKET_COUNT = 4; var BUCKET_COUNT = 4;
@ -136,9 +136,10 @@ window.requestData = function() {
var cachedData = { result: { map: {} } }; var cachedData = { result: { map: {} } };
var requestTileCount = 0; var requestTileCount = 0;
// walk in x-direction, starts right goes left // y goes from left to right
for (var x = x1; x <= x2; x++) { for (var y = y1; y <= y2; y++) {
for (var y = y1; y <= y2; y++) { // x goes from bottom to top(?)
for (var x = x1; x <= x2; x++) {
var tile_id = pointToTileId(z, x, y); var tile_id = pointToTileId(z, x, y);
var latNorth = tileToLat(y,z); var latNorth = tileToLat(y,z);
var latSouth = tileToLat(y+1,z); var latSouth = tileToLat(y+1,z);
@ -156,8 +157,8 @@ window.requestData = function() {
debugSetTileColour(tile_id,'#0f0','#ff0'); debugSetTileColour(tile_id,'#0f0','#ff0');
window.statusCachedMapTiles++; window.statusCachedMapTiles++;
} else { } else {
// group requests into buckets based on the tile coordinate. // group requests into buckets based on the tile count retrieved via the network.
var bucket = Math.floor(x+y*(BUCKET_COUNT/2))%BUCKET_COUNT; var bucket = requestTileCount % BUCKET_COUNT;
if (!tiles[bucket]) { if (!tiles[bucket]) {
//create empty bucket //create empty bucket