Ticket #381: selfoverlapping.patch
| File selfoverlapping.patch, 2.3 KB (added by , 17 years ago) |
|---|
-
src/org/openstreetmap/josm/actions/mapmode/DrawAction.java
old new 33 33 import javax.swing.JOptionPane; 34 34 35 35 import org.openstreetmap.josm.Main; 36 import org.openstreetmap.josm.actions.mapmode.SelectAction; 36 37 import org.openstreetmap.josm.command.AddCommand; 37 38 import org.openstreetmap.josm.command.ChangeCommand; 38 39 import org.openstreetmap.josm.command.Command; … … 166 167 replacedWays = new ArrayList<Way>(); 167 168 boolean newNode = false; 168 169 Node n = null; 170 boolean wayIsFinished = false; 169 171 170 172 if (!ctrl) { 171 173 n = Main.map.mapView.getNearestNode(mousePos); … … 279 281 // Ok we know now that we'll insert a line segment, but will it connect to an 280 282 // existing way or make a new way of its own? The "alt" modifier means that the 281 283 // user wants a new way. 282 283 284 Way way = alt ? null : (selectedWay != null) ? selectedWay : getWayForNode(n0); 285 286 // Don't allow creation of self-overlapping ways 287 if(way != null) { 288 int nodeCount=0; 289 for (Node p : way.nodes) 290 if(p.equals(n0)) nodeCount++; 291 if(nodeCount > 1) way = null; 292 } 293 284 294 if (way == null) { 285 295 way = new Way(); 286 296 way.nodes.add(n0); … … 296 306 } 297 307 } 298 308 309 // Connected to a node that's already in the way 310 if(way != null && way.nodes.contains(n)) { 311 System.out.println("Stop drawing, node is part of current way"); 312 wayIsFinished = true; 313 selection.clear(); 314 //Main.map.selectMapMode(new SelectAction(Main.map)); 315 } 316 317 // Add new node to way 299 318 if (way.nodes.get(way.nodes.size() - 1) == n0) { 300 319 way.nodes.add(n); 301 320 } else { … … 328 347 Command c = new SequenceCommand(title, cmds); 329 348 330 349 Main.main.undoRedo.add(c); 331 lastUsedNode = n;350 if(!wayIsFinished) lastUsedNode = n; 332 351 computeHelperLine(); 333 352 Main.map.mapView.repaint(); 334 353 }
