mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-23 08:39:56 +02:00
Eliminate failing tile requests in specs
This commit is contained in:
@@ -144,6 +144,8 @@ var iD = function(container) {
|
||||
}
|
||||
});
|
||||
|
||||
map.background.source(iD.Background.Bing);
|
||||
|
||||
var hash = iD.Hash().map(map);
|
||||
|
||||
if (!hash.hadHash) {
|
||||
|
||||
@@ -1,27 +1,6 @@
|
||||
iD.Background = function() {
|
||||
var template = 'http://ecn.t{t}.tiles.virtualearth.net/tiles/a{u}.jpeg?g=587&mkt=en-gb&n=z',
|
||||
tile = d3.geo.tile(),
|
||||
projection;
|
||||
|
||||
// derive the url of a 'quadkey' style tile from a coordinate object
|
||||
function tileUrl(coord) {
|
||||
var u = '';
|
||||
for (var zoom = coord[2]; zoom > 0; zoom--) {
|
||||
var byte = 0;
|
||||
var mask = 1 << (zoom - 1);
|
||||
if ((coord[0] & mask) !== 0) byte++;
|
||||
if ((coord[1] & mask) !== 0) byte += 2;
|
||||
u += byte.toString();
|
||||
}
|
||||
// distribute requests against multiple domains
|
||||
var t = coord[2] % 5;
|
||||
return template
|
||||
.replace('{t}', t)
|
||||
.replace('{u}', u)
|
||||
.replace('{x}', coord[0])
|
||||
.replace('{y}', coord[1])
|
||||
.replace('{z}', coord[2]);
|
||||
}
|
||||
var tile = d3.geo.tile(),
|
||||
projection, source;
|
||||
|
||||
// derive the tiles onscreen, remove those offscreen and position tiles
|
||||
// correctly for the currentstate of `projection`
|
||||
@@ -35,36 +14,57 @@ iD.Background = function() {
|
||||
return "scale(" + tiles.scale + ")translate(" + tiles.translate + ")";
|
||||
})
|
||||
.selectAll("image")
|
||||
.data(tiles, function(d) { return [d.join(), template].join(); });
|
||||
.data(tiles, function(d) { return d; });
|
||||
|
||||
image.exit()
|
||||
.remove();
|
||||
|
||||
image.enter().append("image")
|
||||
.attr("xlink:href", tileUrl)
|
||||
.attr("xlink:href", source)
|
||||
.attr("width", 1)
|
||||
.attr("height", 1)
|
||||
.attr("x", function(d) { return d[0]; })
|
||||
.attr("y", function(d) { return d[1]; });
|
||||
}
|
||||
|
||||
background.projection = function(p) {
|
||||
background.projection = function(_) {
|
||||
if (!arguments.length) return projection;
|
||||
projection = p;
|
||||
projection = _;
|
||||
return background;
|
||||
};
|
||||
|
||||
background.size = function(size) {
|
||||
background.size = function(_) {
|
||||
if (!arguments.length) return tile.size();
|
||||
tile.size(size);
|
||||
tile.size(_);
|
||||
return background;
|
||||
};
|
||||
|
||||
background.template = function(x) {
|
||||
if (!arguments.length) return template;
|
||||
template = x;
|
||||
background.source = function(_) {
|
||||
if (!arguments.length) return source;
|
||||
source = _;
|
||||
return background;
|
||||
};
|
||||
|
||||
return background;
|
||||
};
|
||||
|
||||
// derive the url of a 'quadkey' style tile from a coordinate object
|
||||
iD.Background.Bing = function (coord) {
|
||||
var template = 'http://ecn.t{t}.tiles.virtualearth.net/tiles/a{u}.jpeg?g=587&mkt=en-gb&n=z',
|
||||
u = '';
|
||||
for (var zoom = coord[2]; zoom > 0; zoom--) {
|
||||
var byte = 0;
|
||||
var mask = 1 << (zoom - 1);
|
||||
if ((coord[0] & mask) !== 0) byte++;
|
||||
if ((coord[1] & mask) !== 0) byte += 2;
|
||||
u += byte.toString();
|
||||
}
|
||||
// distribute requests against multiple domains
|
||||
var t = coord[2] % 5;
|
||||
return template
|
||||
.replace('{t}', t)
|
||||
.replace('{u}', u)
|
||||
.replace('{x}', coord[0])
|
||||
.replace('{y}', coord[1])
|
||||
.replace('{z}', coord[2]);
|
||||
};
|
||||
|
||||
+4
-5
@@ -1,14 +1,13 @@
|
||||
describe('Map', function() {
|
||||
var map, foo;
|
||||
var container, map;
|
||||
|
||||
beforeEach(function() {
|
||||
foo = document.body.appendChild(document.createElement('div'));
|
||||
foo.id = 'foo';
|
||||
map = iD.Map(d3.select('#foo').node());
|
||||
container = d3.select('body').append('div');
|
||||
map = iD.Map(container.node());
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
foo.parentNode.removeChild(foo);
|
||||
container.remove();
|
||||
});
|
||||
|
||||
describe('#zoom', function() {
|
||||
|
||||
Reference in New Issue
Block a user