Changeset 18615 in josm for trunk/src/org
- Timestamp:
- 2022-12-13T22:24:53+01:00 (17 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/AlignInCircleAction.java
r17416 r18615 150 150 * Case 3: Only nodes are selected 151 151 * --> Align these nodes, all are fix 152 * <p> 153 * Case 4: Circularize selected ways 154 * --> Circularize each way of the selection. 152 155 * @param ds data set in which the command operates 153 156 * @return the resulting command to execute to perform action, or null if nothing was changed … … 227 230 fixNodes.addAll(onWay); 228 231 nodes = collectNodesAnticlockwise(ways); 232 } else if (!ways.isEmpty() && selectedNodes.isEmpty()) { 233 List<Command> rcmds = new LinkedList<>(); 234 for (Way w : ways) { 235 if (!w.isDeleted() && w.isArea()) { 236 List<Node> wnodes = w.getNodes(); 237 wnodes.remove(wnodes.size() - 1); 238 if (validateGeometry(wnodes)) { 239 center = Geometry.getCenter(wnodes); 240 } 241 if (center == null) { 242 continue; 243 } 244 boolean skipThisWay = false; 245 radius = 0; 246 for (Node n : wnodes) { 247 if (!n.isLatLonKnown()) { 248 skipThisWay = true; 249 break; 250 } else { 251 radius += center.distance(n.getEastNorth()); 252 } 253 } 254 if (skipThisWay) { 255 continue; 256 } else { 257 radius /= wnodes.size(); 258 } 259 Command c = moveNodesCommand(wnodes, Collections.emptySet(), center, radius); 260 if (c != null) { 261 rcmds.add(c); 262 } 263 } 264 } 265 if (rcmds.isEmpty()) { 266 throw new InvalidSelection(); 267 } 268 return new SequenceCommand(tr("Align each Way in Circle"), rcmds); 229 269 } else { 230 270 throw new InvalidSelection(); … … 259 299 radius = radius / nodes.size(); 260 300 } 261 301 return moveNodesCommand(nodes, fixNodes, center, radius); 302 } 303 304 /** 305 * Move each node of the list of nodes to be arranged in a circle. 306 * @param nodes The list of nodes to be moved. 307 * @param fixNodes The list of nodes that must not be moved. 308 * @param center A center of the circle formed by the nodes. 309 * @param radius A radius of the circle formed by the nodes. 310 * @return the command that arranges the nodes in a circle. 311 * @since 18615 312 */ 313 public static Command moveNodesCommand( 314 List<Node> nodes, 315 Set<Node> fixNodes, 316 EastNorth center, 317 double radius) { 262 318 List<Command> cmds = new LinkedList<>(); 263 319
Note:
See TracChangeset
for help on using the changeset viewer.