Skip to content

Commit

Permalink
Merge branch '3.0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock committed Jan 1, 2013
2 parents d2ad9f7 + 633fd27 commit 662226b
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 20 deletions.
2 changes: 1 addition & 1 deletion component.json
@@ -1,5 +1,5 @@
{
"name": "d3",
"version": "3.0.1",
"version": "3.0.2",
"main": "./d3.js"
}
13 changes: 6 additions & 7 deletions d3.js
Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
Expand All @@ -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;
Expand All @@ -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 ] ];
};
}
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions d3.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion 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",
Expand Down
2 changes: 1 addition & 1 deletion 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,
Expand Down
8 changes: 3 additions & 5 deletions 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 = {
Expand All @@ -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;
Expand All @@ -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]];
};
}
2 changes: 1 addition & 1 deletion src/geo/circle.js
Expand Up @@ -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, {
Expand Down
2 changes: 1 addition & 1 deletion src/geo/path.js
Expand Up @@ -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(_) {
Expand Down
5 changes: 5 additions & 0 deletions test/geo/circle-test.js
Expand Up @@ -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);
}
}
});
Expand Down
22 changes: 22 additions & 0 deletions test/geo/path-test.js
Expand Up @@ -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);
}
},

Expand Down Expand Up @@ -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);
}
},

Expand Down

0 comments on commit 662226b

Please sign in to comment.