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:
Коммит
9b1fefca81
|
@ -1921,6 +1921,26 @@
|
||||||
};
|
};
|
||||||
return albers;
|
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 d3_geo_circleClip(degrees, rotate) {
|
||||||
function visible(point) {
|
function visible(point) {
|
||||||
return Math.cos(point[1]) * Math.cos(point[0]) > cr;
|
return Math.cos(point[1]) * Math.cos(point[0]) > cr;
|
||||||
|
@ -6473,24 +6493,7 @@
|
||||||
(d3.geo.azimuthalEquidistant = function() {
|
(d3.geo.azimuthalEquidistant = function() {
|
||||||
return d3_geo_projection(d3_geo_azimuthalEquidistant);
|
return d3_geo_projection(d3_geo_azimuthalEquidistant);
|
||||||
}).raw = d3_geo_azimuthalEquidistant;
|
}).raw = d3_geo_azimuthalEquidistant;
|
||||||
d3.geo.bounds = function(feature) {
|
d3.geo.bounds = d3_geo_bounds(d3_identity);
|
||||||
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.circle = function() {
|
d3.geo.circle = function() {
|
||||||
function circle() {}
|
function circle() {}
|
||||||
function bufferContext(lineStrings) {
|
function bufferContext(lineStrings) {
|
||||||
|
@ -6775,7 +6778,7 @@
|
||||||
}
|
}
|
||||||
return z ? [ x, y, 6 * z ] : null;
|
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 = {
|
var bufferContext = {
|
||||||
point: function(x, y) {
|
point: function(x, y) {
|
||||||
buffer.push("M", x, ",", y, pointCircle);
|
buffer.push("M", x, ",", y, pointCircle);
|
||||||
|
@ -6855,12 +6858,16 @@
|
||||||
Point: singleCentroid(pointCentroid),
|
Point: singleCentroid(pointCentroid),
|
||||||
Polygon: singleCentroid(polygonCentroid)
|
Polygon: singleCentroid(polygonCentroid)
|
||||||
});
|
});
|
||||||
|
path.bounds = function(object) {
|
||||||
|
return (bounds || (bounds = d3_geo_bounds(projection)))(object);
|
||||||
|
};
|
||||||
path.centroid = function(object) {
|
path.centroid = function(object) {
|
||||||
return centroidType.object(object);
|
return centroidType.object(object);
|
||||||
};
|
};
|
||||||
path.projection = function(_) {
|
path.projection = function(_) {
|
||||||
if (!arguments.length) return projection;
|
if (!arguments.length) return projection;
|
||||||
projection = _;
|
projection = _;
|
||||||
|
bounds = null;
|
||||||
return path;
|
return path;
|
||||||
};
|
};
|
||||||
path.context = function(_) {
|
path.context = function(_) {
|
||||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -1,23 +1,23 @@
|
||||||
d3.geo.bounds = function(feature) {
|
d3.geo.bounds = d3_geo_bounds(d3_identity);
|
||||||
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,
|
function d3_geo_bounds(projection) {
|
||||||
d3_geo_boundsBottom,
|
var x0, y0, x1, y1, bounds = d3_geo_type({
|
||||||
d3_geo_boundsRight,
|
|
||||||
d3_geo_boundsTop;
|
|
||||||
|
|
||||||
var d3_geo_bounds = d3_geo_type({
|
|
||||||
point: function(point) {
|
point: function(point) {
|
||||||
|
point = projection(point);
|
||||||
var x = point[0], y = point[1];
|
var x = point[0], y = point[1];
|
||||||
if (x < d3_geo_boundsLeft) d3_geo_boundsLeft = x;
|
if (x < x0) x0 = x;
|
||||||
if (x > d3_geo_boundsRight) d3_geo_boundsRight = x;
|
if (x > x1) x1 = x;
|
||||||
if (y < d3_geo_boundsBottom) d3_geo_boundsBottom = y;
|
if (y < y0) y0 = y;
|
||||||
if (y > d3_geo_boundsTop) d3_geo_boundsTop = y;
|
if (y > y1) y1 = y;
|
||||||
},
|
},
|
||||||
polygon: function(coordinates) {
|
polygon: function(coordinates) {
|
||||||
this.line(coordinates[0]); // ignore holes
|
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,
|
var pointRadius = 4.5,
|
||||||
pointCircle = d3_geo_pathCircle(pointRadius),
|
pointCircle = d3_geo_pathCircle(pointRadius),
|
||||||
projection = d3.geo.albersUsa(),
|
projection = d3.geo.albersUsa(),
|
||||||
|
bounds,
|
||||||
buffer = [];
|
buffer = [];
|
||||||
|
|
||||||
var bufferContext = {
|
var bufferContext = {
|
||||||
|
@ -178,11 +179,18 @@ d3.geo.path = function() {
|
||||||
return z ? [x, y, 6 * z] : null; // weighted centroid
|
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(_) {
|
path.projection = function(_) {
|
||||||
if (!arguments.length) return projection;
|
if (!arguments.length) return projection;
|
||||||
projection = _;
|
projection = _;
|
||||||
|
bounds = null;
|
||||||
return path;
|
return path;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче