Permalink
Browse files

Add interactive Albers projection explorer.

  • Loading branch information...
1 parent 4c1fd11 commit a54574bcf99230a52acb44776a0382c623525e26 @mbostock mbostock committed Nov 3, 2010
View
@@ -1,4 +1,4 @@
-d3 = {version: "0.7.0"}; // semver
+d3 = {version: "0.8.0"}; // semver
if (!Date.now) Date.now = function() {
return +new Date();
};
@@ -1753,10 +1753,10 @@ d3.geo = {};
// http://mathworld.wolfram.com/AlbersEqual-AreaConicProjection.html
d3.geo.albers = function() {
- var origin = [-96, 23],
+ var origin = [-98, 38],
parallels = [29.5, 45.5],
scale = 1000,
- translate = [520, 510],
+ translate = [480, 250],
lng0, // d3_radians * origin[0]
n,
C,
@@ -1784,23 +1784,27 @@ d3.geo.albers = function() {
return albers;
}
- albers.origin = function(x, y) {
- origin = [+x, +y];
+ albers.origin = function(x) {
+ if (!arguments.length) return origin;
+ origin = [+x[0], +x[1]];
return reload();
};
- albers.parallels = function(x, y) {
- parallels = [+x, +y];
+ albers.parallels = function(x) {
+ if (!arguments.length) return parallels;
+ parallels = [+x[0], +x[1]];
return reload();
};
albers.scale = function(x) {
+ if (!arguments.length) return scale;
scale = +x;
return albers;
};
- albers.translate = function(x, y) {
- translate = [+x, +y];
+ albers.translate = function(x) {
+ if (!arguments.length) return translate;
+ translate = [+x[0], +x[1]];
return albers;
};
@@ -1813,21 +1817,21 @@ d3.geo.albersUsa = function() {
var lower48 = d3.geo.albers();
var alaska = d3.geo.albers()
- .origin(-160, 60)
- .parallels(55, 65)
- .scale(600)
- .translate(80, 420);
+ .origin([-160, 60])
+ .parallels([55, 65])
+ .scale([600])
+ .translate([80, 420]);
var hawaii = d3.geo.albers()
- .origin(-160, 20)
- .parallels(10, 30)
- .translate(290, 450);
+ .origin([-160, 20])
+ .parallels([10, 30])
+ .translate([290, 450]);
var puertoRico = d3.geo.albers()
- .origin(-60, 10)
- .parallels(0, 20)
- .scale(1500)
- .translate(1060, 680);
+ .origin([-60, 10])
+ .parallels([0, 20])
+ .scale([1500])
+ .translate([1060, 680]);
return function(coordinates) {
var lon = coordinates[0],
Oops, something went wrong. Retry.

0 comments on commit a54574b

Please sign in to comment.