Changeset 18083 in osm for applications/editors/josm/plugins/michigan_left/src/MichiganLeft/MichiganLeftAction.java
- Timestamp:
- 2009-10-11T15:34:14+02:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/michigan_left/src/MichiganLeft/MichiganLeftAction.java
r18072 r18083 47 47 } 48 48 49 if (ways == 4) 50 { 51 // Find extremities of ways 52 Hashtable<Node, Integer> ExtremNodes=new Hashtable<Node, Integer>(); 53 for (OsmPrimitive prim : selection) 54 { 55 if (prim instanceof Way) 56 { 57 Way way = (Way) prim; 58 incrementHashtable(ExtremNodes, way.firstNode()); 59 incrementHashtable(ExtremNodes, way.lastNode()); 60 } 61 } 62 System.out.println(tr("{0} extrem nodes.", ExtremNodes.size())); 63 if (ExtremNodes.size() != 4) 64 { 65 JOptionPane.showMessageDialog(Main.parent, tr("Please select 4 ways that form a closed relation.")); 66 return; 67 } 68 69 // order the ways 70 ArrayList<Way> orderedWays=new ArrayList<Way>(); 71 Way currentWay=(Way) selection.iterator().next(); 72 orderedWays.add((Way) currentWay); 73 selection.remove(currentWay); 74 while (selection.size()>0) 75 { 76 boolean found=false; 77 Node nextNode=currentWay.lastNode(); 78 for (OsmPrimitive prim : selection) 79 { 80 Way tmpWay=(Way) prim; 81 if (tmpWay.firstNode() == nextNode) 82 { 83 orderedWays.add(tmpWay); 84 selection.remove(prim); 85 currentWay=tmpWay; 86 found=true; 87 break; 88 } 89 } 90 if (!found) 91 { 92 JOptionPane.showMessageDialog(Main.parent, tr("Unable to order the ways. Please verify their directions")); 93 return; 94 } 95 } 96 97 // Build relations 98 for (int index=0 ; index<4 ; index++) 99 { 100 Way firstWay=orderedWays.get(index); 101 Way lastWay=orderedWays.get( (index+1) % 4); 102 Node lastNode = firstWay.lastNode(); 103 104 buildRelation(firstWay, lastWay, lastNode); 105 } 106 Command c = new SequenceCommand(tr("Create Michigan left turn restriction"), cmds); 107 Main.main.undoRedo.add(c); 108 cmds.clear(); 109 } 110 49 111 if (ways == 5) 50 112 {
Note:
See TracChangeset
for help on using the changeset viewer.