kekscom / osmbuildings

OSM Buildings Classic 2.5D
http://osmbuildings.org
BSD 2-Clause "Simplified" License
505 stars 140 forks source link

Issue with Brpowsers, especially Chrome, Blocking Json Tile Requests #74

Closed MarkCupitt closed 9 years ago

MarkCupitt commented 9 years ago

Chrome allows 6 connctions to one source, whereas Firefox allows 15.

This is causing blocking on tile requests of up to 10 seconds, triggering a Synchronous like behavior for tile requests

This situation also presents an issue in libraries like Openlayers, etc. They are resolved by allowing 4 urls to be used to to request tiles, eg: http://a.tiles.someserver.net, http://b.tiles.someserver.net and so on

I propose to modify BLDGS.js to allow an array of 4 urls to be specified,

The following lines of code use the baseURL string to specify the location of the tile server

I propose that the syntax be changed to call a function that rotates through an array or urls that can be used, with a static variable to keep track of the last index used and returns the next url, restarting at the first index when the array end is reached

This proposed modification will significantly speed up tile requests

function BLDGS(options) { options = options || {}; baseURL += (options.key || 'anonymous'); maxCacheSize = options.cacheSize || 1024*1024; // 1MB }

proto.getTile = function(x, y, zoom, callback) { var url = baseURL +'/tile/'+ zoom +'/'+ x +'/'+ y +'.json?nocache=yes'; return xhr(url, callback); };

proto.getFeature = function(id, callback) { var url = baseURL +'/feature/'+ id +'.json'; return xhr(url, callback); };

proto.getBBox = function(bbox, callback) { var url = baseURL +'/bbox.json?bbox='+ [bbox.n.toFixed(5),bbox.e.toFixed(5),bbox.s.toFixed(5),bbox.w.toFixed(5)].join(','); return xhr(url, callback); };

kekscom commented 9 years ago

Full ack. The BLDGS provider has it alredy, but not completely integrated with OSM Buildings. See https://github.com/OSMBuildings/bldgs-provider/blob/master/src/BLDGS.js#L16

PS: core OSM Buildings code will move to https://github.com/OSMBuildings/ soon.

kekscom commented 9 years ago

implemented by a3b57a7