Skip to content

Commit 0a1af36

Browse files
committed
Move earth radius constant to d3_geo_earthRadius.
1 parent aa2ee01 commit 0a1af36

5 files changed

Lines changed: 11 additions & 9 deletions

File tree

d3.geo.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
(function(){d3.geo = {};
22

3-
var d3_radians = Math.PI / 180;
3+
var d3_radians = Math.PI / 180,
4+
d3_geo_earthRadius = 6371; // Mean radius of Earth, in km.
45
// TODO clip input coordinates on opposite hemisphere
56
d3.geo.azimuthal = function() {
67
var mode = "orthographic", // or stereographic, gnomonic, equidistant or equalarea
@@ -624,7 +625,7 @@ d3.geo.greatCircle = function() {
624625
var source = d3_geo_greatCircleSource,
625626
target = d3_geo_greatCircleTarget,
626627
n = 100,
627-
radius = 6371; // Mean radius of Earth, in km.
628+
radius = d3_geo_earthRadius;
628629
// TODO: breakAtDateLine?
629630

630631
function greatCircle(d, i) {
@@ -713,7 +714,7 @@ function d3_geo_greatCircleTarget(d) {
713714
d3.geo.clip = function() {
714715
var origin = [0, 0],
715716
angle = 90,
716-
r = 6371 * angle / 180 * Math.PI;
717+
r = d3_geo_earthRadius * angle / 180 * Math.PI;
717718

718719
function clip(d) {
719720
var o = {source: origin, target: null},
@@ -770,7 +771,7 @@ d3.geo.clip = function() {
770771
clip.angle = function(x) {
771772
if (!arguments.length) return angle;
772773
angle = +x;
773-
r = 6371 * angle / 180 * Math.PI;
774+
r = d3_geo_earthRadius * angle / 180 * Math.PI;
774775
return clip;
775776
};
776777

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.

src/geo/clip.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
d3.geo.clip = function() {
22
var origin = [0, 0],
33
angle = 90,
4-
r = 6371 * angle / 180 * Math.PI;
4+
r = d3_geo_earthRadius * angle / 180 * Math.PI;
55

66
function clip(d) {
77
var o = {source: origin, target: null},
@@ -58,7 +58,7 @@ d3.geo.clip = function() {
5858
clip.angle = function(x) {
5959
if (!arguments.length) return angle;
6060
angle = +x;
61-
r = 6371 * angle / 180 * Math.PI;
61+
r = d3_geo_earthRadius * angle / 180 * Math.PI;
6262
return clip;
6363
};
6464

src/geo/geo.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
d3.geo = {};
22

3-
var d3_radians = Math.PI / 180;
3+
var d3_radians = Math.PI / 180,
4+
d3_geo_earthRadius = 6371; // Mean radius of Earth, in km.

src/geo/greatCircle.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ d3.geo.greatCircle = function() {
33
var source = d3_geo_greatCircleSource,
44
target = d3_geo_greatCircleTarget,
55
n = 100,
6-
radius = 6371; // Mean radius of Earth, in km.
6+
radius = d3_geo_earthRadius;
77
// TODO: breakAtDateLine?
88

99
function greatCircle(d, i) {

0 commit comments

Comments
 (0)