Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from datavis-tech/d3-v4-upgrade
D3 v4 upgrade
- Loading branch information
Showing
2 changed files
with
73 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,53 @@ | ||
d3.geo.tile=function(){function t(){var t=Math.max(Math.log(n)/Math.LN2-8,0),h=Math.round(t+e),o=Math.pow(2,t-h+8),u=[(r[0]-n/2)/o,(r[1]-n/2)/o],l=[],c=d3.range(Math.max(0,Math.floor(-u[0])),Math.max(0,Math.ceil(a[0]/o-u[0]))),M=d3.range(Math.max(0,Math.floor(-u[1])),Math.max(0,Math.ceil(a[1]/o-u[1])));return M.forEach(function(t){c.forEach(function(a){l.push([a,t,h])})}),l.translate=u,l.scale=o,l}var a=[960,500],n=256,r=[a[0]/2,a[1]/2],e=0;return t.size=function(n){return arguments.length?(a=n,t):a},t.scale=function(a){return arguments.length?(n=a,t):n},t.translate=function(a){return arguments.length?(r=a,t):r},t.zoomDelta=function(a){return arguments.length?(e=+a,t):e},t}; | ||
d3.geoTile = function() { | ||
var size = [960, 500], | ||
scale = 256, | ||
translate = [size[0] / 2, size[1] / 2], | ||
zoomDelta = 0; | ||
|
||
function tile() { | ||
var z = Math.max(Math.log(scale) / Math.LN2 - 8, 0), | ||
z0 = Math.round(z + zoomDelta), | ||
k = Math.pow(2, z - z0 + 8), | ||
origin = [(translate[0] - scale / 2) / k, (translate[1] - scale / 2) / k], | ||
tiles = [], | ||
cols = d3.range(Math.max(0, Math.floor(-origin[0])), Math.max(0, Math.ceil(size[0] / k - origin[0]))), | ||
rows = d3.range(Math.max(0, Math.floor(-origin[1])), Math.max(0, Math.ceil(size[1] / k - origin[1]))); | ||
|
||
rows.forEach(function(y) { | ||
cols.forEach(function(x) { | ||
tiles.push([x, y, z0]); | ||
}); | ||
}); | ||
|
||
tiles.translate = origin; | ||
tiles.scale = k; | ||
|
||
return tiles; | ||
} | ||
|
||
tile.size = function(_) { | ||
if (!arguments.length) return size; | ||
size = _; | ||
return tile; | ||
}; | ||
|
||
tile.scale = function(_) { | ||
if (!arguments.length) return scale; | ||
scale = _; | ||
return tile; | ||
}; | ||
|
||
tile.translate = function(_) { | ||
if (!arguments.length) return translate; | ||
translate = _; | ||
return tile; | ||
}; | ||
|
||
tile.zoomDelta = function(_) { | ||
if (!arguments.length) return zoomDelta; | ||
zoomDelta = +_; | ||
return tile; | ||
}; | ||
|
||
return tile; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters