Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add Hatano asymmetrical equal-area projection.

  • Loading branch information...
commit 75eb1acffd806554697f7269ad87522662c60e0d 1 parent 4c9b677
@jasondavies jasondavies authored
Showing with 41 additions and 0 deletions.
  1. +16 −0 geo/projection/projection-test.js
  2. +25 −0 geo/projection/projection.js
View
16 geo/projection/projection-test.js
@@ -43,6 +43,22 @@ suite.addBatch({
}
}
},
+ "d3.geo.hatano": {
+ topic: function() {
+ return d3.geo.hatano();
+ },
+ "projections and inverse projections": function(hatano) {
+ assertEqualInverse(hatano, [ 0, 0], [480, 250]);
+ assertEqualInverse(hatano, [ 0, -90], [480, 441.538303]);
+ assertEqualInverse(hatano, [ 0, 90], [480, 53.383198]);
+ assertEqualInverse(hatano, [ 0, -45], [480, 379.209449]);
+ assertEqualInverse(hatano, [ 0, 45], [480, 119.704758]);
+ assertEqualInverse(hatano, [-180, 0], [ 79.446936, 250]);
+ assertEqualInverse(hatano, [ 180, 0], [880.553063, 250]);
+ assertEqualInverse(hatano, [-179, 15], [87.7505160, 204.093101]);
+ assertEqualInverse(hatano, [ 1, 1], [482.225143, 246.920082]);
+ }
+ },
"d3.geo.larrivee": {
topic: function() {
return d3.geo.larrivee();
View
25 geo/projection/projection.js
@@ -334,6 +334,30 @@
return sinusoidal.invert(x, y);
};
+ function hatano(λ, φ) {
+ var c = Math.sin(φ) *< 0 ? 2.43763 : 2.67595);
+ for (var i = 0, δ; i < 20; i++) {
+ φ -= δ =+ Math.sin(φ) - c) / (1 + Math.cos(φ));
+ if (Math.abs(δ) < ε) break;
+ }
+ return [
+ .85 * λ * Math.cos*= .5),
+ Math.sin(φ) *< 0 ? 1.93052 : 1.75859)
+ ];
+ }
+
+ hatano.invert = function(x, y) {
+ var θ = Math.abs= y * (y < 0 ? .51799515156538134803 : .56863737426006061674)) > 1 - ε
+ ? θ > 0 ? π / 2 : -π / 2
+ : Math.asin(θ);
+ return [
+ 1.17647058823529411764 * x / Math.cos(θ),
+ Math.abs= ((θ += θ) + Math.sin(θ)) * (y < 0 ? .41023453108141924738 : .37369906014686373063)) > 1 - ε
+ ? θ > 0 ? π / 2 : -π / 2
+ : Math.asin(θ)
+ ];
+ };
+
function august(λ, φ) {
var tanφ = Math.tan(φ / 2),
k = 1 - tanφ * tanφ,
@@ -885,6 +909,7 @@
d3.geo.guyou = function() { return projection(guyou); };
d3.geo.hammer = function() { return projection(hammer); };
d3.geo.homolosine = function() { return projection(homolosine); };
+ d3.geo.hatano = function() { return projection(hatano); };
d3.geo.kavrayskiy7 = function() { return projection(kavrayskiy7); };
d3.geo.lagrange = lagrangeProjection;
d3.geo.larrivee = function() { return projection(larrivee); };
Please sign in to comment.
Something went wrong with that request. Please try again.