From e9b05d7aa0f2c53826e60f8bb9f5479bf153a320 Mon Sep 17 00:00:00 2001 From: Jon Atkins Date: Mon, 24 Jun 2013 12:20:16 +0100 Subject: [PATCH] order requests to inprove the odds of getting missing tile data when some requests are likely to timeout, by putting uncached tile ids at the start of the request, cached (but stale) at the end --- code/map_data.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/code/map_data.js b/code/map_data.js index 73ec5662..199b9427 100644 --- a/code/map_data.js +++ b/code/map_data.js @@ -152,13 +152,24 @@ window.requestData = function() { } requestTileCount++; - tiles[bucket].push(generateBoundsParams( + + var boundsParam = generateBoundsParams( tile_id, latSouth, lngWest, latNorth, lngEast - )); + ); + + // when the server is returning 'timeout' errors for some tiles in the list, it's always the tiles + // at the end of the request. therefore, let's push tiles we don't have cache entries for to the front, and those we do to the back + if (getDataCache(tile_id)) { + // cache entry exists - push to back + tiles[bucket].push(boundsParam); + } else { + // no cache entry - unshift to front + tiles[bucket].unshift(boundsParam); + } debugSetTileColour(tile_id,'#00f','#000'); }