Skip to content
Browse files

Merge branch '3.0.2'

  • Loading branch information...
2 parents d2ad9f7 + 633fd27 commit 662226bd842e9acc4cc1e0c30b4c8acfb972b718 @mbostock committed
Showing with 44 additions and 20 deletions.
  1. +1 −1 component.json
  2. +6 −7 d3.js
  3. +3 −3 d3.min.js
  4. +1 −1 package.json
  5. +1 −1 src/core/core.js
  6. +3 −5 src/geo/bounds.js
  7. +1 −1 src/geo/circle.js
  8. +1 −1 src/geo/path.js
  9. +5 −0 test/geo/circle-test.js
  10. +22 −0 test/geo/path-test.js
View
2 component.json
@@ -1,5 +1,5 @@
{
"name": "d3",
- "version": "3.0.1",
+ "version": "3.0.2",
"main": "./d3.js"
}
View
13 d3.js
@@ -12,7 +12,7 @@
};
}
d3 = {
- version: "3.0.1"
+ version: "3.0.2"
};
var π = Math.PI, ε = 1e-6, d3_radians = π / 180, d3_degrees = 180 / π;
function d3_target(d) {
@@ -5557,8 +5557,8 @@
(d3.geo.azimuthalEquidistant = function() {
return d3_geo_projection(d3_geo_azimuthalEquidistant);
}).raw = d3_geo_azimuthalEquidistant;
- d3.geo.bounds = d3_geo_bounds();
- function d3_geo_bounds(projection) {
+ d3.geo.bounds = d3_geo_bounds(d3_identity);
+ function d3_geo_bounds(projectStream) {
var x0, y0, x1, y1;
var bound = {
point: boundPoint,
@@ -5571,7 +5571,6 @@
bound.point = boundPoint;
}
};
- var projectBound = projection ? projection.stream(bound) : bound;
function boundPoint(x, y) {
if (x < x0) x0 = x;
if (x > x1) x1 = x;
@@ -5583,7 +5582,7 @@
}
return function(feature) {
y1 = x1 = -(x0 = y0 = Infinity);
- d3.geo.stream(feature, projectBound);
+ d3.geo.stream(feature, projectStream(bound));
return [ [ x0, y0 ], [ x1, y1 ] ];
};
}
@@ -5671,7 +5670,7 @@
d3.geo.circle = function() {
var origin = [ 0, 0 ], angle, precision = 6, interpolate;
function circle() {
- var center = typeof origin === "function" ? origin.apply(this, arguments) : origin, rotate = d3_geo_rotation(center[0] * d3_radians, center[1] * d3_radians, 0), ring = [];
+ var center = typeof origin === "function" ? origin.apply(this, arguments) : origin, rotate = d3_geo_rotation(-center[0] * d3_radians, -center[1] * d3_radians, 0).invert, ring = [];
interpolate(null, null, 1, {
point: function(x, y) {
ring.push(x = rotate(x, y));
@@ -6229,7 +6228,7 @@
return d3_geo_centroidZ ? [ d3_geo_centroidX / d3_geo_centroidZ, d3_geo_centroidY / d3_geo_centroidZ ] : undefined;
};
path.bounds = function(object) {
- return d3_geo_bounds(projection)(object);
+ return d3_geo_bounds(projectStream)(object);
};
path.projection = function(_) {
if (!arguments.length) return projection;
View
6 d3.min.js
3 additions, 3 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
2 package.json
@@ -1,6 +1,6 @@
{
"name": "d3",
- "version": "3.0.1",
+ "version": "3.0.2",
"description": "A small, free JavaScript library for manipulating documents based on data.",
"keywords": [
"dom",
View
2 src/core/core.js
@@ -1,4 +1,4 @@
-d3 = {version: "3.0.1"}; // semver
+d3 = {version: "3.0.2"}; // semver
var π = Math.PI,
ε = 1e-6,
View
8 src/geo/bounds.js
@@ -1,6 +1,6 @@
-d3.geo.bounds = d3_geo_bounds();
+d3.geo.bounds = d3_geo_bounds(d3_identity);
-function d3_geo_bounds(projection) {
+function d3_geo_bounds(projectStream) {
var x0, y0, x1, y1;
var bound = {
@@ -13,8 +13,6 @@ function d3_geo_bounds(projection) {
polygonEnd: function() { bound.point = boundPoint; }
};
- var projectBound = projection ? projection.stream(bound) : bound;
-
function boundPoint(x, y) {
if (x < x0) x0 = x;
if (x > x1) x1 = x;
@@ -28,7 +26,7 @@ function d3_geo_bounds(projection) {
return function(feature) {
y1 = x1 = -(x0 = y0 = Infinity);
- d3.geo.stream(feature, projectBound);
+ d3.geo.stream(feature, projectStream(bound));
return [[x0, y0], [x1, y1]];
};
}
View
2 src/geo/circle.js
@@ -6,7 +6,7 @@ d3.geo.circle = function() {
function circle() {
var center = typeof origin === "function" ? origin.apply(this, arguments) : origin,
- rotate = d3_geo_rotation(center[0] * d3_radians, center[1] * d3_radians, 0),
+ rotate = d3_geo_rotation(-center[0] * d3_radians, -center[1] * d3_radians, 0).invert,
ring = [];
interpolate(null, null, 1, {
View
2 src/geo/path.js
@@ -29,7 +29,7 @@ d3.geo.path = function() {
};
path.bounds = function(object) {
- return d3_geo_bounds(projection)(object);
+ return d3_geo_bounds(projectStream)(object);
};
path.projection = function(_) {
View
5 test/geo/circle-test.js
@@ -17,6 +17,11 @@ suite.addBatch({
var o = circle.origin([0, 90])();
assert.equal(o.type, "Polygon");
assert.inDelta(o.coordinates, [d3.range(360, -1, -6).map(function(x) { return [x >= 180 ? x - 360 : x, 0]; })], 1e-6);
+ },
+ "origin([45, 45])": function(circle) {
+ var o = circle.origin([45, 45]).angle(0)();
+ assert.equal(o.type, "Polygon");
+ assert.inDelta(o.coordinates[0][0], [45, 45], 1e-6);
}
}
});
View
22 test/geo/path-test.js
@@ -186,6 +186,22 @@ suite.addBatch({
},
"Sphere": function(area) {
assert.strictEqual(area({type: "Sphere"}), 1620000);
+ },
+ "supports fallback stream": function() {
+ var path = d3.geo.path(),
+ area = path.area({type: "Polygon", coordinates: [[[-122, 37], [-71, 42], [-80, 25], [-122, 37]]]});
+ assert.inDelta(area, 109021.503, 1e-3);
+ }
+ },
+
+ "bounds": {
+ "supports fallback stream": function() {
+ var path = d3.geo.path(),
+ bounds = path.bounds({type: "LineString", coordinates: [[-122, 37], [-74, 40], [-100, 0]]});
+ assert.inDelta(bounds[0][0], -5.1214, 1e-3);
+ assert.inDelta(bounds[0][1], 174.825, 1e-3);
+ assert.inDelta(bounds[1][0], 794.602, 1e-3);
+ assert.inDelta(bounds[1][1], 856.501, 1e-3);
}
},
@@ -321,6 +337,12 @@ suite.addBatch({
assert.deepEqual(testContext.buffer().filter(function(d) { return d.type === "moveTo"; }), [
{type: "moveTo", x: 1370, y: 243}
]);
+ },
+ "supports fallback stream": function() {
+ var path = d3.geo.path(),
+ centroid = path.centroid({type: "LineString", coordinates: [[-122, 37], [-74, 40], [-100, 0]]});
+ assert.inDelta(centroid[0], 434.655, 1e-3);
+ assert.inDelta(centroid[1], 397.940, 1e-3);
}
},

0 comments on commit 662226b

Please sign in to comment.
Something went wrong with that request. Please try again.