Changeset 5487 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2012-09-01T18:02:59+02:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateWay.java
r5480 r5487 6 6 import java.util.ArrayList; 7 7 import java.util.Collection; 8 import java.util.Collections; 8 9 import java.util.HashSet; 9 10 import java.util.LinkedList; … … 77 78 78 79 /** Bag of all ways */ 79 MultiMap<WayPair, OsmPrimitive> ways;80 private MultiMap<WayPair, OsmPrimitive> ways; 80 81 81 82 /** Bag of all ways, regardless of tags */ 82 MultiMap<WayPairNoTags, OsmPrimitive> waysNoTags; 83 private MultiMap<WayPairNoTags, OsmPrimitive> waysNoTags; 84 85 /** Set of known hashcodes for list of coordinates **/ 86 private Set<Integer> knownHashCodes; 83 87 84 88 /** … … 96 100 ways = new MultiMap<WayPair, OsmPrimitive>(1000); 97 101 waysNoTags = new MultiMap<WayPairNoTags, OsmPrimitive>(1000); 102 knownHashCodes = new HashSet<Integer>(1000); 98 103 } 99 104 … … 136 141 ways = null; 137 142 waysNoTags = null; 143 knownHashCodes = null; 138 144 } 139 145 … … 150 156 if (!w.isUsable()) 151 157 return; 152 List<Node> wNodes = w.getNodes(); 153 List< LatLon> wLat = new ArrayList<LatLon>(wNodes.size());158 List<Node> wNodes = w.getNodes(); // The original list of nodes for this way 159 List<Node> wNodesToUse = new ArrayList<Node>(wNodes.size()); // The list that will be considered for this test 154 160 if (w.isClosed()) { 155 161 // In case of a closed way, build the list of lat/lon starting from the node with the lowest id … … 165 171 } 166 172 for (int i=lowestIndex; i<wNodes.size()-1; i++) { 167 wLat.add(wNodes.get(i).getCoor());173 wNodesToUse.add(wNodes.get(i)); 168 174 } 169 175 for (int i=0; i<lowestIndex; i++) { 170 wLat.add(wNodes.get(i).getCoor()); 171 } 172 wLat.add(wNodes.get(lowestIndex).getCoor()); 173 } else { 174 for (int i=0; i<wNodes.size(); i++) { 175 wLat.add(wNodes.get(i).getCoor()); 176 } 176 wNodesToUse.add(wNodes.get(i)); 177 } 178 wNodesToUse.add(wNodes.get(lowestIndex)); 179 } 180 // Build the list of lat/lon 181 List<LatLon> wLat = new ArrayList<LatLon>(wNodesToUse.size()); 182 for (int i=0; i<wNodesToUse.size(); i++) { 183 wLat.add(wNodesToUse.get(i).getCoor()); 184 } 185 // If this way has not direction-dependant keys, make sure the list is ordered the same for all ways (fix #8015) 186 if (!w.hasDirectionKeys()) { 187 int hash = wLat.hashCode(); 188 if (!knownHashCodes.contains(hash)) { 189 List<LatLon> reversedwLat = new ArrayList<LatLon>(wLat); 190 Collections.reverse(reversedwLat); 191 int reverseHash = reversedwLat.hashCode(); 192 if (!knownHashCodes.contains(reverseHash)) { 193 // Neither hash or reversed hash is known, remember hash 194 knownHashCodes.add(hash); 195 } else { 196 // Reversed hash is known, use the reverse list then 197 wLat = reversedwLat; 198 } 199 } 177 200 } 178 201 Map<String, String> wkeys = w.getKeys();
Note:
See TracChangeset
for help on using the changeset viewer.