Changeset 1898 in josm for trunk/src/org/openstreetmap/josm/command
- Timestamp:
- 2009-08-03T21:18:50+02:00 (14 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/command
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/command/DeleteCommand.java
r1856 r1898 67 67 * Constructor for a single data item. Use the collection constructor to delete multiple 68 68 * objects. 69 * 69 * 70 70 * @param layer the layer context for deleting this primitive 71 71 * @param data the primitive to delete … … 79 79 * Constructor for a collection of data to be deleted in the context of 80 80 * a specific layer 81 * 81 * 82 82 * @param layer the layer context for deleting these primitives 83 83 * @param data the primitives to delete … … 137 137 /** 138 138 * Delete the primitives and everything they reference. 139 * 139 * 140 140 * If a node is deleted, the node and all ways and relations the node is part of are deleted as 141 141 * well. 142 * 142 * 143 143 * If a way is deleted, all relations the way is member of are also deleted. 144 * 144 * 145 145 * If a way is deleted, only the way and no nodes are deleted. 146 * 146 * 147 147 * @param selection The list of all object to be deleted. 148 148 * @return command A command to perform the deletions, or null of there is nothing to delete. … … 204 204 continue; 205 205 } 206 for (Node n : ((Way) osm). nodes) {206 for (Node n : ((Way) osm).getNodes()) { 207 207 if (n.isTagged()) { 208 208 continue; … … 221 221 /** 222 222 * Try to delete all given primitives. 223 * 223 * 224 224 * If a node is used by a way, it's removed from that way. If a node or a way is used by a 225 225 * relation, inform the user and do not delete. 226 * 226 * 227 227 * If this would cause ways with less than 2 nodes to be created, delete these ways instead. If 228 228 * they are part of a relation, inform the user and do not delete. 229 * 229 * 230 230 * @param layer the {@see OsmDataLayer} in whose context a primitive the primitives are deleted 231 231 * @param selection The objects to delete. … … 279 279 Way wnew = new Way(w); 280 280 wnew.removeNodes(primitivesToDelete); 281 if (wnew. nodes.size() < 2) {281 if (wnew.getNodesCount() < 2) { 282 282 primitivesToDelete.add(w); 283 283 … … 347 347 } 348 348 Way wnew = new Way(w); 349 ArrayList<Node> nodesToStrip = new ArrayList<Node>();349 List<Node> nodesToKeep = new ArrayList<Node>(); 350 350 // lookup new nodes which have been added to the set of deleted 351 351 // nodes ... 352 for (Node n : wnew. nodes) {353 if (n.id == 0 &&primitivesToDelete.contains(n)) {354 nodesTo Strip.add(n);352 for (Node n : wnew.getNodes()) { 353 if (n.id != 0 || !primitivesToDelete.contains(n)) { 354 nodesToKeep.add(n); 355 355 } 356 356 } 357 357 // .. and remove them from the way 358 358 // 359 wnew. nodes.removeAll(nodesToStrip);360 if ( !nodesToStrip.isEmpty()) {359 wnew.setNodes(nodesToKeep); 360 if (nodesToKeep.size() < w.getNodesCount()) { 361 361 cmds.add(new ChangeCommand(w, wnew)); 362 362 } … … 373 373 List<Node> n1 = new ArrayList<Node>(), n2 = new ArrayList<Node>(); 374 374 375 n1.addAll(ws.way. nodes.subList(0, ws.lowerIndex + 1));376 n2.addAll(ws.way. nodes.subList(ws.lowerIndex + 1, ws.way.nodes.size()));375 n1.addAll(ws.way.getNodes().subList(0, ws.lowerIndex + 1)); 376 n2.addAll(ws.way.getNodes().subList(ws.lowerIndex + 1, ws.way.getNodesCount())); 377 377 378 378 if (n1.size() < 2 && n2.size() < 2) … … 380 380 381 381 Way wnew = new Way(ws.way); 382 wnew.nodes.clear();383 382 384 383 if (n1.size() < 2) { 385 wnew. nodes.addAll(n2);384 wnew.setNodes(n2); 386 385 return new ChangeCommand(ws.way, wnew); 387 386 } else if (n2.size() < 2) { 388 wnew. nodes.addAll(n1);387 wnew.setNodes(n1); 389 388 return new ChangeCommand(ws.way, wnew); 390 389 } else { 391 390 Collection<Command> cmds = new LinkedList<Command>(); 392 391 393 wnew. nodes.addAll(n1);392 wnew.setNodes(n1); 394 393 cmds.add(new ChangeCommand(ws.way, wnew)); 395 394 … … 398 397 wnew2.keys = new HashMap<String, String>(wnew.keys); 399 398 } 400 wnew2. nodes.addAll(n2);399 wnew2.setNodes(n2); 401 400 cmds.add(new AddCommand(wnew2)); 402 401 … … 408 407 * Check whether user is about to delete data outside of the download area. Request confirmation 409 408 * if he is. 410 * 409 * 411 410 * @param layer the layer in whose context data is deleted 412 411 * @param primitivesToDelete the primitives to delete -
trunk/src/org/openstreetmap/josm/command/PurgePrimitivesCommand.java
r1862 r1898 190 190 // remember it on the "hive" 191 191 // 192 if (w. nodes.size() < 2) {192 if (w.getNodesCount() < 2) { 193 193 System.out.println(tr("Warning: Purging way {0} because number of nodes dropped below 2. Current is {1}", 194 w.id,w. nodes.size()));194 w.id,w.getNodesCount())); 195 195 if (!hive.contains(w)) { 196 196 hive.add(w);
Note: See TracChangeset
for help on using the changeset viewer.