Permalink
Browse files

Add d3.geo.conicEqualArea.

This is identical to d3.geo.albers, but without the U.S.-centric defaults. This
will be moved to D3 core in the v3.1.0 release.
  • Loading branch information...
mbostock committed Mar 11, 2013
1 parent 43b6494 commit 0711bdf074a7fc04b8d0617fc07cc7cccd4f3d79
Showing with 29 additions and 0 deletions.
  1. +1 −0 Makefile
  2. +28 −0 geo/projection/conic-equal-area.js
View
@@ -24,6 +24,7 @@ d3.geo.projection.js: \
geo/projection/bromley.js \
geo/projection/collignon.js \
geo/projection/conic-conformal.js \
+ geo/projection/conic-equal-area.js \
geo/projection/conic-equidistant.js \
geo/projection/craig.js \
geo/projection/craster.js \
@@ -0,0 +1,28 @@
+// @import parallel2
+
+function conicEqualArea0, φ1) {
+ var sinφ0 = Math.sin0),
+ n = (sinφ0 + Math.sin1)) / 2,
+ C = 1 + sinφ0 * (2 * n - sinφ0),
+ ρ0 = Math.sqrt(C) / n;
+
+ function conicEqualArea(λ, φ) {
+ var ρ = Math.sqrt(C - 2 * n * Math.sin(φ)) / n;
+ return [
+ ρ * Math.sin*= n),
+ ρ0 - ρ * Math.cos(λ)
+ ];
+ }
+
+ conicEqualArea.invert = function(x, y) {
+ var ρ0_y = ρ0 - y;
+ return [
+ Math.atan2(x, ρ0_y) / n,
+ Math.asin((C - (x * x + ρ0_y * ρ0_y) * n * n) / (2 * n))
+ ];
+ };
+
+ return albers;
+}
+
+(d3.geo.conicEqualArea = function() { return parallel2Projection(conicEqualArea); }).raw = conicEqualArea;

0 comments on commit 0711bdf

Please sign in to comment.