Merge branch 'geo-bounds' of git://github.com/jasondavies/d3 into 3.0

Conflicts:
	src/geo/bounds.js
	src/geo/path.js
	src/geo/type.js
	test/geo/bounds-test.js
This commit is contained in:
Mike Bostock 2012-10-29 09:07:00 -07:00
Родитель 9828afda19 e3f4b90aa5
Коммит 9b1fefca81
4 изменённых файлов: 60 добавлений и 45 удалений

45
d3.js поставляемый
Просмотреть файл

@ -1921,6 +1921,26 @@
};
return albers;
}
function d3_geo_bounds(projection) {
var x0, y0, x1, y1, bounds = d3_geo_type({
point: function(point) {
point = projection(point);
var x = point[0], y = point[1];
if (x < x0) x0 = x;
if (x > x1) x1 = x;
if (y < y0) y0 = y;
if (y > y1) y1 = y;
},
polygon: function(coordinates) {
this.line(coordinates[0]);
}
});
return function(feature) {
y1 = x1 = -(x0 = y0 = Infinity);
bounds.object(feature);
return [ [ x0, y0 ], [ x1, y1 ] ];
};
}
function d3_geo_circleClip(degrees, rotate) {
function visible(point) {
return Math.cos(point[1]) * Math.cos(point[0]) > cr;
@ -6473,24 +6493,7 @@
(d3.geo.azimuthalEquidistant = function() {
return d3_geo_projection(d3_geo_azimuthalEquidistant);
}).raw = d3_geo_azimuthalEquidistant;
d3.geo.bounds = function(feature) {
d3_geo_boundsTop = d3_geo_boundsRight = -(d3_geo_boundsLeft = d3_geo_boundsBottom = Infinity);
d3_geo_bounds.object(feature);
return [ [ d3_geo_boundsLeft, d3_geo_boundsBottom ], [ d3_geo_boundsRight, d3_geo_boundsTop ] ];
};
var d3_geo_boundsLeft, d3_geo_boundsBottom, d3_geo_boundsRight, d3_geo_boundsTop;
var d3_geo_bounds = d3_geo_type({
point: function(point) {
var x = point[0], y = point[1];
if (x < d3_geo_boundsLeft) d3_geo_boundsLeft = x;
if (x > d3_geo_boundsRight) d3_geo_boundsRight = x;
if (y < d3_geo_boundsBottom) d3_geo_boundsBottom = y;
if (y > d3_geo_boundsTop) d3_geo_boundsTop = y;
},
polygon: function(coordinates) {
this.line(coordinates[0]);
}
});
d3.geo.bounds = d3_geo_bounds(d3_identity);
d3.geo.circle = function() {
function circle() {}
function bufferContext(lineStrings) {
@ -6775,7 +6778,7 @@
}
return z ? [ x, y, 6 * z ] : null;
}
var pointRadius = 4.5, pointCircle = d3_geo_pathCircle(pointRadius), projection = d3.geo.albersUsa(), buffer = [];
var pointRadius = 4.5, pointCircle = d3_geo_pathCircle(pointRadius), projection = d3.geo.albersUsa(), bounds, buffer = [];
var bufferContext = {
point: function(x, y) {
buffer.push("M", x, ",", y, pointCircle);
@ -6855,12 +6858,16 @@
Point: singleCentroid(pointCentroid),
Polygon: singleCentroid(polygonCentroid)
});
path.bounds = function(object) {
return (bounds || (bounds = d3_geo_bounds(projection)))(object);
};
path.centroid = function(object) {
return centroidType.object(object);
};
path.projection = function(_) {
if (!arguments.length) return projection;
projection = _;
bounds = null;
return path;
};
path.context = function(_) {

8
d3.min.js поставляемый

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -1,23 +1,23 @@
d3.geo.bounds = function(feature) {
d3_geo_boundsTop = d3_geo_boundsRight = -(d3_geo_boundsLeft = d3_geo_boundsBottom = Infinity);
d3_geo_bounds.object(feature);
return [[d3_geo_boundsLeft, d3_geo_boundsBottom], [d3_geo_boundsRight, d3_geo_boundsTop]];
};
d3.geo.bounds = d3_geo_bounds(d3_identity);
var d3_geo_boundsLeft,
d3_geo_boundsBottom,
d3_geo_boundsRight,
d3_geo_boundsTop;
function d3_geo_bounds(projection) {
var x0, y0, x1, y1, bounds = d3_geo_type({
point: function(point) {
point = projection(point);
var x = point[0], y = point[1];
if (x < x0) x0 = x;
if (x > x1) x1 = x;
if (y < y0) y0 = y;
if (y > y1) y1 = y;
},
polygon: function(coordinates) {
this.line(coordinates[0]); // ignore holes
}
});
var d3_geo_bounds = d3_geo_type({
point: function(point) {
var x = point[0], y = point[1];
if (x < d3_geo_boundsLeft) d3_geo_boundsLeft = x;
if (x > d3_geo_boundsRight) d3_geo_boundsRight = x;
if (y < d3_geo_boundsBottom) d3_geo_boundsBottom = y;
if (y > d3_geo_boundsTop) d3_geo_boundsTop = y;
},
polygon: function(coordinates) {
this.line(coordinates[0]); // ignore holes
}
});
return function(feature) {
y1 = x1 = -(x0 = y0 = Infinity);
bounds.object(feature);
return [[x0, y0], [x1, y1]];
};
}

Просмотреть файл

@ -4,6 +4,7 @@ d3.geo.path = function() {
var pointRadius = 4.5,
pointCircle = d3_geo_pathCircle(pointRadius),
projection = d3.geo.albersUsa(),
bounds,
buffer = [];
var bufferContext = {
@ -178,11 +179,18 @@ d3.geo.path = function() {
return z ? [x, y, 6 * z] : null; // weighted centroid
}
path.centroid = function(object) { return centroidType.object(object); };
path.bounds = function(object) {
return (bounds || (bounds = d3_geo_bounds(projection)))(object);
};
path.centroid = function(object) {
return centroidType.object(object);
};
path.projection = function(_) {
if (!arguments.length) return projection;
projection = _;
bounds = null;
return path;
};