Changeset 11627 in josm for trunk/src/org/openstreetmap/josm/data
- Timestamp:
- 2017-02-26T00:59:32+01:00 (7 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/UndoRedoHandler.java
r11553 r11627 52 52 CheckParameterUtil.ensureParameterNotNull(c, "c"); 53 53 c.executeCommand(); 54 c.invalidateAffectedLayers();55 54 commands.add(c); 56 55 // Limit the number of commands in the undo list. … … 81 80 } 82 81 addNoRedraw(c); 82 c.invalidateAffectedLayers(); 83 83 afterAdd(); 84 84 -
trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
r11440 r11627 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.awt.geom.Area; 6 7 import java.util.ArrayList; 7 8 import java.util.Arrays; … … 25 26 26 27 import org.openstreetmap.josm.Main; 28 import org.openstreetmap.josm.data.Bounds; 27 29 import org.openstreetmap.josm.data.Data; 28 30 import org.openstreetmap.josm.data.DataSource; … … 127 129 private final Object selectionLock = new Object(); 128 130 131 private Area cachedDataSourceArea; 132 private List<Bounds> cachedDataSourceBounds; 133 129 134 /** 130 135 * Constructs a new {@code DataSet}. … … 184 189 copyFrom.getReadLock().unlock(); 185 190 } 191 } 192 193 /** 194 * Adds a new data source. 195 * @param source data source to add 196 * @return {@code true} if the collection changed as a result of the call 197 * @since 11626 198 */ 199 public synchronized boolean addDataSource(DataSource source) { 200 return addDataSources(Collections.singleton(source)); 201 } 202 203 /** 204 * Adds new data sources. 205 * @param sources data sources to add 206 * @return {@code true} if the collection changed as a result of the call 207 * @since 11626 208 */ 209 public synchronized boolean addDataSources(Collection<DataSource> sources) { 210 boolean changed = dataSources.addAll(sources); 211 if (changed) { 212 cachedDataSourceArea = null; 213 cachedDataSourceBounds = null; 214 } 215 return changed; 186 216 } 187 217 … … 917 947 fireSelectionChanged(); 918 948 } 949 } 950 951 @Override 952 public synchronized Area getDataSourceArea() { 953 if (cachedDataSourceArea == null) { 954 cachedDataSourceArea = Data.super.getDataSourceArea(); 955 } 956 return cachedDataSourceArea; 957 } 958 959 @Override 960 public synchronized List<Bounds> getDataSourceBounds() { 961 if (cachedDataSourceBounds == null) { 962 cachedDataSourceBounds = Data.super.getDataSourceBounds(); 963 } 964 return Collections.unmodifiableList(cachedDataSourceBounds); 919 965 } 920 966 … … 1334 1380 * @param progressMonitor The progress monitor 1335 1381 */ 1336 public void mergeFrom(DataSet from, ProgressMonitor progressMonitor) {1382 public synchronized void mergeFrom(DataSet from, ProgressMonitor progressMonitor) { 1337 1383 if (from != null) { 1338 1384 new DataSetMerger(this, from).merge(progressMonitor); 1339 dataSources.addAll(from.dataSources); 1340 from.dataSources.clear(); 1385 if (!from.dataSources.isEmpty()) { 1386 if (dataSources.addAll(from.dataSources)) { 1387 cachedDataSourceArea = null; 1388 cachedDataSourceBounds = null; 1389 } 1390 from.dataSources.clear(); 1391 from.cachedDataSourceArea = null; 1392 from.cachedDataSourceBounds = null; 1393 } 1341 1394 } 1342 1395 } -
trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateNode.java
r11590 r11627 309 309 @Override 310 310 public Command fixError(TestError testError) { 311 if (!isFixable(testError)) return null;312 311 Collection<OsmPrimitive> sel = new LinkedList<>(testError.getPrimitives()); 313 312 Set<Node> nodes = new LinkedHashSet<>(OsmPrimitive.getFilteredList(sel, Node.class)); -
trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateRelation.java
r11452 r11627 293 293 } 294 294 295 // Delete all relations in the list295 // Delete all relations in the list 296 296 relFix.remove(relationToKeep); 297 297 commands.add(new DeleteCommand(relFix)); … … 306 306 // We fix it only if there is no more than one relation that is relation member. 307 307 Collection<? extends OsmPrimitive> sel = testError.getPrimitives(); 308 Set<Relation> rel ations = new HashSet<>();308 Set<Relation> rels = new HashSet<>(); 309 309 310 310 for (OsmPrimitive osm : sel) { 311 311 if (osm instanceof Relation) { 312 rel ations.add((Relation) osm);313 } 314 } 315 316 if (rel ations.size() < 2)312 rels.add((Relation) osm); 313 } 314 } 315 316 if (rels.size() < 2) 317 317 return false; 318 318 319 319 int relationsWithRelations = 0; 320 for (Relation w : rel ations) {320 for (Relation w : rels) { 321 321 List<Relation> rel = OsmPrimitive.getFilteredList(w.getReferrers(), Relation.class); 322 322 if (!rel.isEmpty()) { -
trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateWay.java
r11129 r11627 249 249 public Command fixError(TestError testError) { 250 250 Collection<? extends OsmPrimitive> sel = testError.getPrimitives(); 251 Set<Way> way s= new HashSet<>();251 Set<Way> wayz = new HashSet<>(); 252 252 253 253 for (OsmPrimitive osm : sel) { 254 254 if (osm instanceof Way && !osm.isDeleted()) { 255 way s.add((Way) osm);256 } 257 } 258 259 if (way s.size() < 2)255 wayz.add((Way) osm); 256 } 257 } 258 259 if (wayz.size() < 2) 260 260 return null; 261 261 262 262 long idToKeep = 0; 263 Way wayToKeep = way s.iterator().next();263 Way wayToKeep = wayz.iterator().next(); 264 264 // Find the way that is member of one or more relations. (If any) 265 265 Way wayWithRelations = null; 266 266 List<Relation> relations = null; 267 for (Way w : way s) {267 for (Way w : wayz) { 268 268 List<Relation> rel = OsmPrimitive.getFilteredList(w.getReferrers(), Relation.class); 269 269 if (!rel.isEmpty()) { … … 284 284 285 285 // Fix relations. 286 if (wayWithRelations != null && wayToKeep != wayWithRelations) {286 if (wayWithRelations != null && relations != null && wayToKeep != wayWithRelations) { 287 287 for (Relation rel : relations) { 288 288 Relation newRel = new Relation(rel); … … 297 297 } 298 298 299 // Delete all ways in the list300 // Note: nodes are not deleted, these can be detected and deleted at next pass301 way s.remove(wayToKeep);302 commands.add(new DeleteCommand(way s));299 // Delete all ways in the list 300 // Note: nodes are not deleted, these can be detected and deleted at next pass 301 wayz.remove(wayToKeep); 302 commands.add(new DeleteCommand(wayz)); 303 303 return new SequenceCommand(tr("Delete duplicate ways"), commands); 304 304 } … … 309 309 return false; 310 310 311 // Do not automatically fix same ways with different tags311 // Do not automatically fix same ways with different tags 312 312 if (testError.getCode() != DUPLICATE_WAY) return false; 313 313 314 314 // We fix it only if there is no more than one way that is relation member. 315 315 Collection<? extends OsmPrimitive> sel = testError.getPrimitives(); 316 Set<Way> way s= new HashSet<>();316 Set<Way> wayz = new HashSet<>(); 317 317 318 318 for (OsmPrimitive osm : sel) { 319 319 if (osm instanceof Way) { 320 way s.add((Way) osm);321 } 322 } 323 324 if (way s.size() < 2)320 wayz.add((Way) osm); 321 } 322 } 323 324 if (wayz.size() < 2) 325 325 return false; 326 326 327 327 int waysWithRelations = 0; 328 for (Way w : way s) {328 for (Way w : wayz) { 329 329 List<Relation> rel = OsmPrimitive.getFilteredList(w.getReferrers(), Relation.class); 330 330 if (!rel.isEmpty()) {
Note:
See TracChangeset
for help on using the changeset viewer.