Skip to content

Commit cb8afe7

Browse files
committed
Fix azimuthal projections of origin point.
1 parent 90cd1bc commit cb8afe7

6 files changed

Lines changed: 54 additions & 14 deletions

File tree

d3.geo.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ d3.geo.azimuthal = function() {
2424
c,
2525
k = mode === "stereographic" ? 1 / (1 + cc)
2626
: mode === "gnomonic" ? 1 / cc
27-
: mode === "equidistant" ? (c = Math.acos(cc), c / Math.sin(c))
27+
: mode === "equidistant" ? (c = Math.acos(cc), c ? c / Math.sin(c) : 0)
2828
: mode === "equalarea" ? Math.sqrt(2 / (1 + cc))
2929
: 1,
3030
x = k * cy1 * sx1,
@@ -48,7 +48,7 @@ d3.geo.azimuthal = function() {
4848
cc = Math.cos(c);
4949
return [
5050
(x0 + Math.atan2(x * sc, p * cy0 * cc + y * sy0 * sc)) / d3_radians,
51-
Math.asin(cc * sy0 - (y * sc * cy0) / p) / d3_radians
51+
Math.asin(cc * sy0 - (p ? (y * sc * cy0) / p : 0)) / d3_radians
5252
];
5353
};
5454

d3.geo.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/azimuthal/azimuthal.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ <h3>Azimuthal Projection</h3>
9191
$("#mode").change(function() {
9292
var mode = $(this).val();
9393
xy.mode(mode);
94-
path.clip(mode === "gnomonic" ? clip : circle);
94+
//path.clip(mode === "gnomonic" ? clip : circle);
9595
refresh(500);
9696
});
9797

examples/azimuthal/azimuthal.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
var xy = d3.geo.azimuthal().scale(240).mode("stereographic"),
22
clip = d3.geo.clip().angle(89),
33
circle = d3.geo.greatCircle().precision(10).coordinates(clip),
4-
path = d3.geo.path().projection(xy).clip(circle),
4+
path = d3.geo.path().projection(xy),//.clip(circle),
55
svg = d3.select("body").append("svg:svg");
66

77
d3.json("../data/world-countries.json", function(collection) {

src/geo/azimuthal.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ d3.geo.azimuthal = function() {
2020
c,
2121
k = mode === "stereographic" ? 1 / (1 + cc)
2222
: mode === "gnomonic" ? 1 / cc
23-
: mode === "equidistant" ? (c = Math.acos(cc), c / Math.sin(c))
23+
: mode === "equidistant" ? (c = Math.acos(cc), c ? c / Math.sin(c) : 0)
2424
: mode === "equalarea" ? Math.sqrt(2 / (1 + cc))
2525
: 1,
2626
x = k * cy1 * sx1,
@@ -44,7 +44,7 @@ d3.geo.azimuthal = function() {
4444
cc = Math.cos(c);
4545
return [
4646
(x0 + Math.atan2(x * sc, p * cy0 * cc + y * sy0 * sc)) / d3_radians,
47-
Math.asin(cc * sy0 - (y * sc * cy0) / p) / d3_radians
47+
Math.asin(cc * sy0 - (p ? (y * sc * cy0) / p : 0)) / d3_radians
4848
];
4949
};
5050

0 commit comments

Comments
 (0)