Changeset 429 in josm for trunk/src/org/openstreetmap/josm/actions/CombineWayAction.java
- Timestamp:
- 2007-10-26T10:44:20+02:00 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/CombineWayAction.java
r426 r429 38 38 import org.openstreetmap.josm.data.osm.Way; 39 39 import org.openstreetmap.josm.data.osm.Node; 40 import org.openstreetmap.josm. data.osm.NodePair;40 import org.openstreetmap.josm.tools.Pair; 41 41 import org.openstreetmap.josm.tools.GBC; 42 42 … … 53 53 } 54 54 55 private static class RelationRolePair {56 public Relation rel;57 public String role;58 59 public RelationRolePair(Relation rel, String role) {60 this.rel = rel;61 this.role = role;62 }63 64 @Override public boolean equals(Object o) {65 return o instanceof RelationRolePair66 && rel == ((RelationRolePair) o).rel67 && role.equals(((RelationRolePair) o).role);68 }69 70 @Override public int hashCode() {71 return rel.hashCode() ^ role.hashCode();72 }73 }74 75 55 public void actionPerformed(ActionEvent event) { 76 56 Collection<OsmPrimitive> selection = Main.ds.getSelected(); … … 96 76 // Step 1, iterate over all relations and figure out which of our 97 77 // selected ways are members of a relation. 98 HashMap<Relation RolePair, HashSet<Way>> backlinks =99 new HashMap<Relation RolePair, HashSet<Way>>();78 HashMap<Pair<Relation,String>, HashSet<Way>> backlinks = 79 new HashMap<Pair<Relation,String>, HashSet<Way>>(); 100 80 HashSet<Relation> relationsUsingWays = new HashSet<Relation>(); 101 81 for (Relation r : Main.ds.relations) { … … 105 85 for(Way w : selectedWays) { 106 86 if (rm.member == w) { 107 Relation RolePairpair = new RelationRolePair(r, rm.role);87 Pair<Relation,String> pair = new Pair<Relation,String>(r, rm.role); 108 88 HashSet<Way> waylinks = new HashSet<Way>(); 109 89 if (backlinks.containsKey(pair)) { … … 238 218 // 4. Profit! 239 219 240 HashSet< NodePair> chunkSet = new HashSet<NodePair>();220 HashSet<Pair<Node,Node>> chunkSet = new HashSet<Pair<Node,Node>>(); 241 221 for (Way w : ways) { 242 222 if (w.nodes.size() == 0) continue; … … 248 228 } 249 229 250 NodePairnp = newNodePair(lastN, n);230 Pair<Node,Node> np = new Pair<Node,Node>(lastN, n); 251 231 if (ignoreDirection) { 252 np.sort();232 Pair.sort(np); 253 233 } 254 234 chunkSet.add(np); … … 257 237 } 258 238 } 259 LinkedList< NodePair> chunks = new LinkedList<NodePair>(chunkSet);239 LinkedList<Pair<Node,Node>> chunks = new LinkedList<Pair<Node,Node>>(chunkSet); 260 240 261 241 if (chunks.isEmpty()) { … … 263 243 } 264 244 265 List<Node> nodeList = chunks.poll() .toArrayList();245 List<Node> nodeList = Pair.toArrayList(chunks.poll()); 266 246 while (!chunks.isEmpty()) { 267 ListIterator< NodePair> it = chunks.listIterator();247 ListIterator<Pair<Node,Node>> it = chunks.listIterator(); 268 248 boolean foundChunk = false; 269 249 while (it.hasNext()) { 270 NodePaircurChunk = it.next();250 Pair<Node,Node> curChunk = it.next(); 271 251 if (curChunk.a == nodeList.get(nodeList.size() - 1)) { // append 272 252 nodeList.add(curChunk.b);
Note:
See TracChangeset
for help on using the changeset viewer.
