Require 2 uniq points for circularize. Handle 2 point case, where D3 centroid() fails.

This commit is contained in:
Bryan Housel
2014-04-21 23:29:25 -04:00
parent a2331f8c93
commit 33782a3958
2 changed files with 4 additions and 2 deletions
+1 -1
View File
@@ -12,7 +12,7 @@ iD.actions.Circularize = function(wayId, projection, maxAngle) {
keyNodes = nodes.filter(function(n) { return graph.parentWays(n).length !== 1; }),
points = nodes.map(function(n) { return projection(n.loc); }),
keyPoints = keyNodes.map(function(n) { return projection(n.loc); }),
centroid = d3.geom.polygon(points).centroid(),
centroid = (points.length === 2) ? iD.geo.interp(points[0], points[1], 0.5) : d3.geom.polygon(points).centroid(),
radius = d3.median(points, function(p) { return iD.geo.euclideanDistance(centroid, p); }),
sign = d3.geom.polygon(points).area() > 0 ? 1 : -1,
ids;
+3 -1
View File
@@ -9,8 +9,10 @@ iD.operations.Circularize = function(selectedIDs, context) {
};
operation.available = function() {
var entity = context.entity(entityId);
return selectedIDs.length === 1 &&
context.entity(entityId).type === 'way';
entity.type === 'way' &&
_.uniq(entity.nodes).length > 1;
};
operation.disabled = function() {