- Timestamp:
- 2009-10-17T15:40:11+02:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/command/DeleteCommand.java
r2273 r2296 427 427 428 428 public static Command deleteWaySegment(OsmDataLayer layer, WaySegment ws) { 429 if (ws.way.getNodesCount() < 3) { 430 // If the way contains less than three nodes, it can't have more 431 // than one segment, so the way should be deleted. 432 433 return new DeleteCommand(layer, Collections.singleton(ws.way)); 434 } 435 436 if (ws.way.firstNode() == ws.way.lastNode()) { 437 // If the way is circular (first and last nodes are the same), 438 // the way shouldn't be splitted 439 440 List<Node> n = new ArrayList<Node>(); 441 442 n.addAll(ws.way.getNodes().subList(ws.lowerIndex + 1, ws.way.getNodesCount() - 1)); 443 n.addAll(ws.way.getNodes().subList(0, ws.lowerIndex + 1)); 444 445 Way wnew = new Way(ws.way); 446 wnew.setNodes(n); 447 448 return new ChangeCommand(ws.way, wnew); 449 } 450 429 451 List<Node> n1 = new ArrayList<Node>(), n2 = new ArrayList<Node>(); 430 452 431 453 n1.addAll(ws.way.getNodes().subList(0, ws.lowerIndex + 1)); 432 454 n2.addAll(ws.way.getNodes().subList(ws.lowerIndex + 1, ws.way.getNodesCount())); 433 434 if (n1.size() < 2 && n2.size() < 2)435 return new DeleteCommand(layer, Collections.singleton(ws.way));436 455 437 456 Way wnew = new Way(ws.way); … … 453 472 wnew2.setNodes(n2); 454 473 cmds.add(new AddCommand(wnew2)); 474 475 // FIXME: relation memberships are not handled 455 476 456 477 return new SequenceCommand(tr("Split way segment"), cmds);
Note:
See TracChangeset
for help on using the changeset viewer.