Sha256: 86e589399ff8ac807f0687e94015b1dbe20d7448b07bca28397845fa9d871ced
Contents?: true
Size: 910 Bytes
Versions: 6
Compression:
Stored size: 910 Bytes
Contents
d3.geo.mercator = function() { var scale = 500, translate = [480, 250]; function mercator(coordinates) { var x = coordinates[0] / 360, y = -(Math.log(Math.tan(Math.PI / 4 + coordinates[1] * d3_radians / 2)) / d3_radians) / 360; return [ scale * x + translate[0], scale * Math.max(-.5, Math.min(.5, y)) + translate[1] ]; } mercator.invert = function(coordinates) { var x = (coordinates[0] - translate[0]) / scale, y = (coordinates[1] - translate[1]) / scale; return [ 360 * x, 2 * Math.atan(Math.exp(-360 * y * d3_radians)) / d3_radians - 90 ]; }; mercator.scale = function(x) { if (!arguments.length) return scale; scale = +x; return mercator; }; mercator.translate = function(x) { if (!arguments.length) return translate; translate = [+x[0], +x[1]]; return mercator; }; return mercator; };
Version data entries
6 entries across 6 versions & 1 rubygems