merge d3.geo.tile changes from upstream

This commit is contained in:
Ansis Brammanis
2013-02-27 15:44:35 -05:00
parent d351f74a94
commit ce0122921b

View File

@@ -2,7 +2,8 @@ d3.geo.tile = function() {
var size = [960, 500],
scale = 256,
scaleExtent = [0, 20],
translate = [size[0] / 2, size[1] / 2];
translate = [size[0] / 2, size[1] / 2],
zoomDelta = 0;
function bound(_) {
return Math.min(scaleExtent[1], Math.max(scaleExtent[0], _));
@@ -10,7 +11,7 @@ d3.geo.tile = function() {
function tile() {
var z = Math.max(Math.log(scale) / Math.LN2 - 8, 0),
z0 = bound(z | 0),
z0 = bound(Math.round(z + zoomDelta)),
k = Math.pow(2, z - z0 + 8),
origin = [(translate[0] - scale / 2) / k, (translate[1] - scale / 2) / k],
tiles = [],
@@ -53,5 +54,11 @@ d3.geo.tile = function() {
return tile;
};
tile.zoomDelta = function(_) {
if (!arguments.length) return zoomDelta;
zoomDelta = +_;
return tile;
};
return tile;
};