Skip to content

Commit dcf6b26

Browse files
committed
Merge branch 'master' into rotation
2 parents 9323c23 + a3bb93a commit dcf6b26

14 files changed

Lines changed: 116 additions & 62 deletions

File tree

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ d3.geo.js: \
198198
src/geo/equirectangular.js \
199199
src/geo/gnomonic.js \
200200
src/geo/graticule.js \
201+
src/geo/haversin.js \
201202
src/geo/interpolate.js \
202203
src/geo/greatArc.js \
203204
src/geo/mercator.js \

component.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"name": "d3",
3-
"version": "3.0.6",
3+
"version": "3.0.8",
44
"main": "./d3.js"
55
}

d3.js

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
d3 = function() {
22
var π = Math.PI, ε = 1e-6, d3 = {
3-
version: "3.0.6"
3+
version: "3.0.8"
44
}, d3_radians = π / 180, d3_degrees = 180 / π, d3_document = document, d3_window = window;
55
function d3_target(d) {
66
return d.target;
@@ -124,7 +124,7 @@ d3 = function() {
124124
function d3_rebind(target, source, method) {
125125
return function() {
126126
var value = method.apply(source, arguments);
127-
return arguments.length ? target : value;
127+
return value === source ? target : value;
128128
};
129129
}
130130
d3.ascending = function(a, b) {
@@ -5794,9 +5794,15 @@ d3 = function() {
57945794
function d3_geo_clipPolygon(segments, interpolate, listener) {
57955795
var subject = [], clip = [];
57965796
segments.forEach(function(segment) {
5797-
var n = segment.length;
5798-
if (n <= 1) return;
5799-
var p0 = segment[0], p1 = segment[n - 1], a = {
5797+
if ((n = segment.length) <= 1) return;
5798+
var n, p0 = segment[0], p1 = segment[n - 1];
5799+
if (d3_geo_sphericalEqual(p0, p1)) {
5800+
listener.lineStart();
5801+
for (var i = 0; i < n; ++i) listener.point((p0 = segment[i])[0], p0[1]);
5802+
listener.lineEnd();
5803+
return;
5804+
}
5805+
var a = {
58005806
point: p0,
58015807
points: segment,
58025808
other: null,
@@ -6130,15 +6136,20 @@ d3 = function() {
61306136
});
61316137
};
61326138
}
6139+
function d3_geo_haversin(x) {
6140+
return (x = Math.sin(x / 2)) * x;
6141+
}
61336142
d3.geo.interpolate = function(source, target) {
61346143
return d3_geo_interpolate(source[0] * d3_radians, source[1] * d3_radians, target[0] * d3_radians, target[1] * d3_radians);
61356144
};
61366145
function d3_geo_interpolate(x0, y0, x1, y1) {
6137-
var cy0 = Math.cos(y0), sy0 = Math.sin(y0), cy1 = Math.cos(y1), sy1 = Math.sin(y1), kx0 = cy0 * Math.cos(x0), ky0 = cy0 * Math.sin(x0), kx1 = cy1 * Math.cos(x1), ky1 = cy1 * Math.sin(x1), d = Math.acos(Math.max(-1, Math.min(1, sy0 * sy1 + cy0 * cy1 * Math.cos(x1 - x0)))), k = 1 / Math.sin(d);
6138-
function interpolate(t) {
6146+
var cy0 = Math.cos(y0), sy0 = Math.sin(y0), cy1 = Math.cos(y1), sy1 = Math.sin(y1), kx0 = cy0 * Math.cos(x0), ky0 = cy0 * Math.sin(x0), kx1 = cy1 * Math.cos(x1), ky1 = cy1 * Math.sin(x1), d = 2 * Math.asin(Math.sqrt(d3_geo_haversin(y1 - y0) + cy0 * cy1 * d3_geo_haversin(x1 - x0))), k = 1 / Math.sin(d);
6147+
var interpolate = d ? function(t) {
61396148
var B = Math.sin(t *= d) * k, A = Math.sin(d - t) * k, x = A * kx0 + B * kx1, y = A * ky0 + B * ky1, z = A * sy0 + B * sy1;
6140-
return [ Math.atan2(y, x) / d3_radians, Math.atan2(z, Math.sqrt(x * x + y * y)) / d3_radians ];
6141-
}
6149+
return [ Math.atan2(y, x) * d3_degrees, Math.atan2(z, Math.sqrt(x * x + y * y)) * d3_degrees ];
6150+
} : function() {
6151+
return [ x0 * d3_degrees, y0 * d3_degrees ];
6152+
};
61426153
interpolate.distance = d;
61436154
return interpolate;
61446155
}
@@ -7517,7 +7528,7 @@ d3 = function() {
75177528
return format;
75187529
};
75197530
var d3_time_formatIso = d3.time.format.utc("%Y-%m-%dT%H:%M:%S.%LZ");
7520-
d3.time.format.iso = Date.prototype.toISOString ? d3_time_formatIsoNative : d3_time_formatIso;
7531+
d3.time.format.iso = Date.prototype.toISOString && +new Date("2000-01-01T00:00:00.000Z") ? d3_time_formatIsoNative : d3_time_formatIso;
75217532
function d3_time_formatIsoNative(date) {
75227533
return date.toISOString();
75237534
}

d3.min.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "d3",
3-
"version": "3.0.6",
3+
"version": "3.0.8",
44
"description": "A small, free JavaScript library for manipulating documents based on data.",
55
"keywords": [
66
"dom",
@@ -28,11 +28,11 @@
2828
}
2929
},
3030
"dependencies": {
31-
"jsdom": "0.3.4"
31+
"jsdom": "0.3.x"
3232
},
3333
"devDependencies": {
34-
"uglify-js": "2.2.3",
35-
"vows": "0.7.0"
34+
"uglify-js": "2.2.x",
35+
"vows": "0.7.x"
3636
},
3737
"scripts": {
3838
"test": "./node_modules/vows/bin/vows"

src/core/core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var π = Math.PI,
22
ε = 1e-6,
3-
d3 = {version: "3.0.6"}, // semver
3+
d3 = {version: "3.0.8"}, // semver
44
d3_radians = π / 180,
55
d3_degrees = 180 / π,
66
d3_document = document,

src/core/rebind.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ d3.rebind = function(target, source) {
1111
function d3_rebind(target, source, method) {
1212
return function() {
1313
var value = method.apply(source, arguments);
14-
return arguments.length ? target : value;
14+
return value === source ? target : value;
1515
};
1616
}

src/geo/clip.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,21 @@ function d3_geo_clipPolygon(segments, interpolate, listener) {
115115
clip = [];
116116

117117
segments.forEach(function(segment) {
118-
var n = segment.length;
119-
if (n <= 1) return;
120-
var p0 = segment[0],
121-
p1 = segment[n - 1],
122-
a = {point: p0, points: segment, other: null, visited: false, entry: true, subject: true},
118+
if ((n = segment.length) <= 1) return;
119+
var n, p0 = segment[0], p1 = segment[n - 1];
120+
121+
// If the first and last points of a segment are coincident, then treat as
122+
// a closed ring.
123+
// TODO if all rings are closed, then the winding order of the exterior
124+
// ring should be checked.
125+
if (d3_geo_sphericalEqual(p0, p1)) {
126+
listener.lineStart();
127+
for (var i = 0; i < n; ++i) listener.point((p0 = segment[i])[0], p0[1]);
128+
listener.lineEnd();
129+
return;
130+
}
131+
132+
var a = {point: p0, points: segment, other: null, visited: false, entry: true, subject: true},
123133
b = {point: p0, points: [p0], other: a, visited: false, entry: false, subject: false};
124134
a.other = b;
125135
subject.push(a);

src/geo/haversin.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
function d3_geo_haversin(x) {
2+
return (x = Math.sin(x / 2)) * x;
3+
}

src/geo/interpolate.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,20 @@ function d3_geo_interpolate(x0, y0, x1, y1) {
1414
ky0 = cy0 * Math.sin(x0),
1515
kx1 = cy1 * Math.cos(x1),
1616
ky1 = cy1 * Math.sin(x1),
17-
d = Math.acos(Math.max(-1, Math.min(1, sy0 * sy1 + cy0 * cy1 * Math.cos(x1 - x0)))),
17+
d = 2 * Math.asin(Math.sqrt(d3_geo_haversin(y1 - y0) + cy0 * cy1 * d3_geo_haversin(x1 - x0))),
1818
k = 1 / Math.sin(d);
1919

20-
function interpolate(t) {
20+
var interpolate = d ? function(t) {
2121
var B = Math.sin(t *= d) * k,
2222
A = Math.sin(d - t) * k,
2323
x = A * kx0 + B * kx1,
2424
y = A * ky0 + B * ky1,
2525
z = A * sy0 + B * sy1;
2626
return [
27-
Math.atan2(y, x) / d3_radians,
28-
Math.atan2(z, Math.sqrt(x * x + y * y)) / d3_radians
27+
Math.atan2(y, x) * d3_degrees,
28+
Math.atan2(z, Math.sqrt(x * x + y * y)) * d3_degrees
2929
];
30-
}
30+
} : function() { return [x0 * d3_degrees, y0 * d3_degrees]; };
3131

3232
interpolate.distance = d;
3333

0 commit comments

Comments
 (0)