mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-25 09:34:04 +02:00
Require 2 uniq points for circularize. Handle 2 point case, where D3 centroid() fails.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user