diff --git a/src/path/string.js b/src/path/string.js index f2a084f..02e57b0 100644 --- a/src/path/string.js +++ b/src/path/string.js @@ -3,9 +3,11 @@ export default function PathString() { } PathString.prototype = { + _radius: 4.5, _circle: circle(4.5), pointRadius: function(_) { - return this._circle = circle(_), this; + if ((_ = +_) !== this._radius) this._radius = _, this._circle = null; + return this; }, polygonStart: function() { this._line = 0; @@ -32,6 +34,7 @@ PathString.prototype = { break; } default: { + if (this._circle == null) this._circle = circle(this._radius); this._string.push("M", x, ",", y, this._circle); break; } diff --git a/test/path/string-test.js b/test/path/string-test.js index fab5189..26caa60 100644 --- a/test/path/string-test.js +++ b/test/path/string-test.js @@ -21,6 +21,16 @@ tape("geoPath(Point) renders a point", function(test) { test.end(); }); +tape("geoPath.pointRadius(radius)(Point) renders a point of the given radius", function(test) { + test.pathEqual(d3_geo.geoPath() + .projection(equirectangular) + .pointRadius(10)({ + type: "Point", + coordinates: [-63, 18] + }), "M165,160m0,10a10,10 0 1,1 0,-20a10,10 0 1,1 0,20z"); + test.end(); +}); + tape("geoPath(MultiPoint) renders a point", function(test) { test.pathEqual(testPath(equirectangular, { type: "MultiPoint",