Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix NaNs in d3.geo.vanDerGrinten4.

Fixes #43.
  • Loading branch information...
commit 2c461f9e56ada994ec9f7c7985653a7b45338189 1 parent 3220650
@jasondavies jasondavies authored
View
4 geo/projection/test/van-der-grinten4-test.js
@@ -8,8 +8,10 @@ var suite = vows.describe("d3.geo.vanDerGrinten4");
suite.addBatch({
"vanDerGrinten4": {
topic: d3.geo.vanDerGrinten4,
- "doesn't generate NaN": function(vanDerGrinten4) {
+ "doesn't generate NaNs": function(vanDerGrinten4) {
assert.inDelta(vanDerGrinten4([20, 1e-7]), [532.359877, 250], 1e-6);
+ assert.inDelta(vanDerGrinten4([180.0000000000001, -90.00000000000003]), [480, 485.619449], 1e-6);
+ assert.inDelta(vanDerGrinten4([-180, -90.00000000000003]), [480, 485.619449], 1e-6);
},
"projections and inverse projections": function(vanDerGrinten4) {
assert.equalInverse(vanDerGrinten4, [ 0, 0], [480, 250]);
View
2  geo/projection/van-der-grinten4.js
@@ -14,7 +14,7 @@ function vanDerGrinten4(λ, φ) {
D = sgn(Math.abs(λ) - π / 2) * Math.sqrt1 * λ1 - 4),
D2 = D * D,
F = B_C2 * (B2 + C2 * D2 - 1) + (1 - B2) * (B2 * (B_3C * B_3C + 4 * C2) + 12 * BC * C2 + 4 * C2 * C2),
- x1 = (D * (B_C2 + C2 - 1) + 2 * Math.sqrt(F)) / (4 * B_C2 + D2);
+ x1 = (D * (B_C2 + C2 - 1) + 2 * asqrt(F)) / (4 * B_C2 + D2);
return [
sgn(λ) * π * x1 / 2,
sgn(φ) * π / 2 * asqrt(1 + D * Math.abs(x1) - x1 * x1)
Please sign in to comment.
Something went wrong with that request. Please try again.