Changeset 7501 in josm
- Timestamp:
- 2014-09-05T14:45:30+02:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data/osm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
r7395 r7501 102 102 private static final int MAX_EVENTS = 1000; 103 103 104 private Storage<OsmPrimitive> allPrimitives = new Storage<>(new Storage.PrimitiveIdHash(), true);105 private Map<PrimitiveId, OsmPrimitive> primitivesMap = allPrimitives.foreignKey(new Storage.PrimitiveIdHash());106 private CopyOnWriteArrayList<DataSetListener> listeners = new CopyOnWriteArrayList<>();104 private final Storage<OsmPrimitive> allPrimitives = new Storage<>(new Storage.PrimitiveIdHash(), true); 105 private final Map<PrimitiveId, OsmPrimitive> primitivesMap = allPrimitives.foreignKey(new Storage.PrimitiveIdHash()); 106 private final CopyOnWriteArrayList<DataSetListener> listeners = new CopyOnWriteArrayList<>(); 107 107 108 108 // provide means to highlight map elements that are not osm primitives … … 257 257 * conversion of the whole DataSet by iterating over this data structure. 258 258 */ 259 private QuadBuckets<Node> nodes = new QuadBuckets<>();259 private final QuadBuckets<Node> nodes = new QuadBuckets<>(); 260 260 261 261 private <T extends OsmPrimitive> Collection<T> getPrimitives(Predicate<OsmPrimitive> predicate) { … … 287 287 288 288 /** 289 * Determines if the given node can be retrieved in the data set through its bounding box. Useful for dataset consistency test. 290 * For efficiency reasons this method does not lock the dataset, you have to lock it manually. 291 * 292 * @param n The node to search 293 * @return {@code true} if {@code n} ban be retrieved in this data set, {@code false} otherwise 294 * @since 7501 295 */ 296 public boolean containsNode(Node n) { 297 return nodes.contains(n); 298 } 299 300 /** 289 301 * All ways (Streets etc.) in the DataSet. 290 302 * 291 303 * The way nodes are stored only in the way list. 292 304 */ 293 private QuadBuckets<Way> ways = new QuadBuckets<>();305 private final QuadBuckets<Way> ways = new QuadBuckets<>(); 294 306 295 307 /** … … 317 329 318 330 /** 331 * Determines if the given way can be retrieved in the data set through its bounding box. Useful for dataset consistency test. 332 * For efficiency reasons this method does not lock the dataset, you have to lock it manually. 333 * 334 * @param w The way to search 335 * @return {@code true} if {@code w} ban be retrieved in this data set, {@code false} otherwise 336 * @since 7501 337 */ 338 public boolean containsWay(Way w) { 339 return ways.contains(w); 340 } 341 342 /** 319 343 * All relations/relationships 320 344 */ 321 private Collection<Relation> relations = new ArrayList<>();345 private final Collection<Relation> relations = new ArrayList<>(); 322 346 323 347 /** … … 349 373 lock.readLock().unlock(); 350 374 } 375 } 376 377 /** 378 * Determines if the given relation can be retrieved in the data set through its bounding box. Useful for dataset consistency test. 379 * For efficiency reasons this method does not lock the dataset, you have to lock it manually. 380 * 381 * @param r The relation to search 382 * @return {@code true} if {@code r} ban be retrieved in this data set, {@code false} otherwise 383 * @since 7501 384 */ 385 public boolean containsRelation(Relation r) { 386 return relations.contains(r); 351 387 } 352 388 -
trunk/src/org/openstreetmap/josm/data/osm/DatasetConsistencyTest.java
r7500 r7501 9 9 10 10 import org.openstreetmap.josm.Main; 11 import org.openstreetmap.josm.data.coor.LatLon;12 11 import org.openstreetmap.josm.tools.Utils; 13 12 … … 105 104 public void searchNodes() { 106 105 long startTime = System.currentTimeMillis(); 107 for (Node n : dataSet.getNodes()) {108 if (!n.isIncomplete() && !n.isDeleted()){109 LatLon c = n.getCoor();110 if (c != null) {111 BBox box = c.toBBox(0.0001);112 if (!dataSet.searchNodes(box).contains(n)) {113 printError("SEARCH NODES", "%s not found using Dataset.searchNodes()", n);114 115 }116 }106 dataSet.getReadLock().lock(); 107 try { 108 for (Node n : dataSet.getNodes()) { 109 // Call isDrawable() as an efficient replacement to previous checks (!deleted, !incomplete, getCoor() != null) 110 if (n.isDrawable() && !dataSet.containsNode(n)) { 111 printError("SEARCH NODES", "%s not found using Dataset.searchNodes()", n); 112 } 113 } 114 } finally { 115 dataSet.getReadLock().unlock(); 117 116 } 118 117 printElapsedTime(startTime); … … 124 123 public void searchWays() { 125 124 long startTime = System.currentTimeMillis(); 126 for (Way w : dataSet.getWays()) { 127 if (!w.isIncomplete() && !w.isDeleted() && w.getNodesCount() >= 2 && !dataSet.searchWays(w.getBBox()).contains(w)) { 128 printError("SEARCH WAYS", "%s not found using Dataset.searchWays()", w); 129 } 125 dataSet.getReadLock().lock(); 126 try { 127 for (Way w : dataSet.getWays()) { 128 if (!w.isIncomplete() && !w.isDeleted() && w.getNodesCount() >= 2 && !dataSet.containsWay(w)) { 129 printError("SEARCH WAYS", "%s not found using Dataset.searchWays()", w); 130 } 131 } 132 } finally { 133 dataSet.getReadLock().unlock(); 130 134 } 131 135 printElapsedTime(startTime);
Note:
See TracChangeset
for help on using the changeset viewer.