Changeset 5719 in josm
- Timestamp:
- 2013-02-15T21:58:25+01:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/AlignInCircleAction.java
r5125 r5719 10 10 import java.math.MathContext; 11 11 import java.util.Collection; 12 import java.util.HashSet; 12 13 import java.util.LinkedList; 13 14 import java.util.List; 15 import java.util.Set; 14 16 15 17 import javax.swing.JOptionPane; … … 116 118 // distance between two nodes. 117 119 if (nodes.size() > 0) { 118 if (nodes.size() == 1 && way.containsNode(nodes.get(0)) ) {120 if (nodes.size() == 1 && way.containsNode(nodes.get(0)) && allowRegularPolygon(way.getNodes())) { 119 121 regular = true; 120 } else { 121 122 } else if (nodes.size() >= 2) { 122 123 center = nodes.get(way.containsNode(nodes.get(0)) ? 1 : 0).getEastNorth(); 123 124 if (nodes.size() == 2) { … … 125 126 } 126 127 } 127 nodes = new LinkedList<Node>();128 nodes.clear(); 128 129 } 129 130 … … 239 240 setEnabled(selection != null && !selection.isEmpty()); 240 241 } 242 243 /** 244 * Determines if a regular polygon is allowed to be created with the given nodes collection. 245 * @param nodes The nodes collection to check. 246 * @return true if all nodes in the given collection are referred by the same object, and no other one (see #8431) 247 */ 248 protected boolean allowRegularPolygon(Collection<Node> nodes) { 249 Set<OsmPrimitive> allReferrers = new HashSet<OsmPrimitive>(); 250 for (Node n : nodes) { 251 List<OsmPrimitive> referrers = n.getReferrers(); 252 if (referrers.size() > 1 || (allReferrers.addAll(referrers) && allReferrers.size() > 1)) { 253 return false; 254 } 255 } 256 return true; 257 } 241 258 }
Note:
See TracChangeset
for help on using the changeset viewer.