Changeset 18071 in osm for applications/editors/josm/plugins/michigan_left
- Timestamp:
- 2009-10-10T23:34:39+02:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/michigan_left/src/MichiganLeft/MichiganLeftAction.java
r17647 r18071 28 28 public class MichiganLeftAction extends JosmAction { 29 29 private LinkedList<Command> cmds = new LinkedList<Command>(); 30 30 31 31 public MichiganLeftAction() { 32 32 super(tr("Michigan Left"), "michigan_left", tr("Adds no left turn for sets of 4 or 5 ways."), Shortcut.registerShortcut("tools:michigan_left", tr("Tool: {0}", tr("Michigan Left")), … … 50 50 { 51 51 // Find extremities of ways 52 Hashtable ExtremNodes=new Hashtable();52 Hashtable<Node, Integer> ExtremNodes=new Hashtable<Node, Integer>(); 53 53 for (OsmPrimitive prim : selection) { 54 54 if (prim instanceof Way) … … 59 59 } 60 60 } 61 System.out.println(tr("{0} extrem nodes.", ExtremNodes.size())); 62 61 System.out.println(tr("{0} extrem nodes.", ExtremNodes.size())); 62 63 63 ArrayList<Node> viaNodes=new ArrayList<Node>(); 64 64 // find via nodes (they have 3 occurences in the list) … … 72 72 viaNodes.add(extrem); 73 73 } 74 } 75 System.out.println(tr("{0} via nodes.", viaNodes.size())); 76 74 } 75 System.out.println(tr("{0} via nodes.", viaNodes.size())); 76 77 77 if (viaNodes.size() != 2) { 78 78 JOptionPane.showMessageDialog(Main.parent, tr("Unable to find via nodes. Please check your selection")); 79 79 return; 80 80 } 81 81 82 82 Node viaFirst = viaNodes.get(0); 83 83 Node viaLast = viaNodes.get(1); // Find middle segment … … 96 96 } 97 97 } 98 System.out.println(tr("MIddle way: {0}", middle.getId())); 99 98 System.out.println(tr("MIddle way: {0}", middle.getId())); 99 100 100 // Build relations 101 101 for (OsmPrimitive prim : selection) { … … 121 121 Command c = new SequenceCommand(tr("Create Michigan left turn restriction"), cmds); 122 122 Main.main.undoRedo.add(c); 123 cmds.clear(); 123 cmds.clear(); 124 124 } 125 125 } 126 126 127 public void incrementHashtable(Hashtable hash, Node node)127 public void incrementHashtable(Hashtable<Node, Integer> hash, Node node) 128 128 { 129 129 System.out.println(tr("Processing {0}", node.getId())); … … 137 137 hash.put(node, new Integer (1)); 138 138 } 139 139 140 140 public void buildRelation(Way fromWay, Way toWay, Node viaNode) 141 141 { 142 System.out.println(tr("Relation: from {0} to {1} via {2}", fromWay.getId(), toWay.getId(), viaNode.getId())); 143 142 System.out.println(tr("Relation: from {0} to {1} via {2}", fromWay.getId(), toWay.getId(), viaNode.getId())); 143 144 144 Relation relation = new Relation(); 145 145 146 146 RelationMember from = new RelationMember("from", fromWay); 147 147 relation.addMember(from); 148 148 149 149 RelationMember to = new RelationMember("to", toWay); 150 150 relation.addMember(to); 151 151 152 152 RelationMember via = new RelationMember("via", viaNode); 153 153 relation.addMember(via); 154 154 155 155 relation.put("type", "restriction"); 156 156 relation.put("restriction", "no_left_turn"); 157 157 158 158 cmds.add(new AddCommand(relation)); 159 } 159 } 160 160 161 161 }
Note:
See TracChangeset
for help on using the changeset viewer.