Sha256: b6636f13eaeec2e5f84ebc46cb5621efa9f31ef45dd2e217cf2d15e5de07f075

Contents?: true

Size: 926 Bytes

Versions: 25

Compression:

Stored size: 926 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_geo_radians / 2)) / d3_geo_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_geo_radians)) / d3_geo_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

25 entries across 25 versions & 1 rubygems

Version Path
picky-statistics-4.5.0 lib/picky-statistics/application/javascripts/d3/src/geo/mercator.js
picky-statistics-4.4.2 lib/picky-statistics/application/javascripts/d3/src/geo/mercator.js
picky-statistics-4.4.1 lib/picky-statistics/application/javascripts/d3/src/geo/mercator.js
picky-statistics-4.4.0 lib/picky-statistics/application/javascripts/d3/src/geo/mercator.js
picky-statistics-4.3.2 lib/picky-statistics/application/javascripts/d3/src/geo/mercator.js
picky-statistics-4.3.1 lib/picky-statistics/application/javascripts/d3/src/geo/mercator.js
picky-statistics-4.3.0 lib/picky-statistics/application/javascripts/d3/src/geo/mercator.js
picky-statistics-4.2.4 lib/picky-statistics/application/javascripts/d3/src/geo/mercator.js
picky-statistics-4.2.3 lib/picky-statistics/application/javascripts/d3/src/geo/mercator.js
picky-statistics-4.2.2 lib/picky-statistics/application/javascripts/d3/src/geo/mercator.js
picky-statistics-4.2.1 lib/picky-statistics/application/javascripts/d3/src/geo/mercator.js
picky-statistics-4.2.0 lib/picky-statistics/application/javascripts/d3/src/geo/mercator.js
picky-statistics-4.1.0 lib/picky-statistics/application/javascripts/d3/src/geo/mercator.js
picky-statistics-4.0.9 lib/picky-statistics/application/javascripts/d3/src/geo/mercator.js
picky-statistics-4.0.8 lib/picky-statistics/application/javascripts/d3/src/geo/mercator.js
picky-statistics-4.0.7 lib/picky-statistics/application/javascripts/d3/src/geo/mercator.js
picky-statistics-4.0.6 lib/picky-statistics/application/javascripts/d3/src/geo/mercator.js
picky-statistics-4.0.5 lib/picky-statistics/application/javascripts/d3/src/geo/mercator.js
picky-statistics-4.0.4 lib/picky-statistics/application/javascripts/d3/src/geo/mercator.js
picky-statistics-4.0.3 lib/picky-statistics/application/javascripts/d3/src/geo/mercator.js