Skip to content

Commit 3b11c2c

Browse files
committed
Polygon area is consistent with holes.
1 parent d5bbc2a commit 3b11c2c

3 files changed

Lines changed: 12 additions & 14 deletions

File tree

d3.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6401,32 +6401,31 @@
64016401
}
64026402
return stream;
64036403
}
6404-
var d3_geo_pathAreaScale, d3_geo_pathArea = {
6404+
var d3_geo_pathAreaPolygon, d3_geo_pathArea = {
64056405
point: d3_noop,
64066406
lineStart: d3_noop,
64076407
lineEnd: d3_noop,
64086408
polygonStart: function() {
6409-
d3_geo_pathAreaScale = .5;
6409+
d3_geo_pathAreaPolygon = 0;
64106410
d3_geo_pathArea.lineStart = d3_geo_pathAreaRingStart;
64116411
},
64126412
polygonEnd: function() {
64136413
d3_geo_pathArea.lineStart = d3_geo_pathArea.lineEnd = d3_geo_pathArea.point = d3_noop;
6414+
d3_geo_areaSum += Math.abs(d3_geo_pathAreaPolygon / 2);
64146415
}
64156416
};
64166417
function d3_geo_pathAreaRingStart() {
6417-
var x00, y00, x0, y0, area = 0;
6418+
var x00, y00, x0, y0;
64186419
d3_geo_pathArea.point = function(x, y) {
64196420
d3_geo_pathArea.point = nextPoint;
64206421
x00 = x0 = x, y00 = y0 = y;
64216422
};
64226423
function nextPoint(x, y) {
6423-
area += y0 * x - x0 * y;
6424+
d3_geo_pathAreaPolygon += y0 * x - x0 * y;
64246425
x0 = x, y0 = y;
64256426
}
64266427
d3_geo_pathArea.lineEnd = function() {
64276428
nextPoint(x00, y00);
6428-
d3_geo_areaSum += Math.abs(area) * d3_geo_pathAreaScale;
6429-
d3_geo_pathAreaScale = -.5;
64306429
};
64316430
}
64326431
var d3_geo_pathCentroid = {

0 commit comments

Comments
 (0)