- Timestamp:
- 2019-09-16T01:50:12+02:00 (5 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/actions/downloadtasks
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java
r14624 r15353 203 203 } 204 204 205 protected Collection<OsmPrimitive> searchPotentiallyDeletedPrimitives(DataSet ds) { 206 return downloadTask.searchPrimitivesToUpdate(currentBounds, ds); 207 } 208 205 209 /** 206 210 * Superclass of internal download task. … … 376 380 * @return the primitives to update 377 381 */ 378 pr ivateCollection<OsmPrimitive> searchPrimitivesToUpdate(Bounds bounds, DataSet ds) {382 protected Collection<OsmPrimitive> searchPrimitivesToUpdate(Bounds bounds, DataSet ds) { 379 383 if (bounds == null) 380 384 return Collections.emptySet(); -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadTaskList.java
r15205 r15353 252 252 } 253 253 } 254 Set<Object> errors = new LinkedHashSet<>(); 255 for (DownloadTask dt : tasks) { 256 errors.addAll(dt.getErrorObjects()); 257 } 254 Set<Object> errors = tasks.stream().flatMap(t -> t.getErrorObjects().stream()).collect(Collectors.toSet()); 258 255 if (!errors.isEmpty()) { 259 256 final Collection<String> items = new ArrayList<>(); … … 290 287 } 291 288 } 292 final OsmDataLayer editLayer = MainApplication.getLayerManager().getEditLayer(); 293 if (editLayer != null && osmData) { 294 final Set<OsmPrimitive> myPrimitives = getCompletePrimitives(editLayer.getDataSet()); 295 for (DownloadTask task : tasks) { 296 if (task instanceof DownloadOsmTask) { 297 DataSet ds = ((DownloadOsmTask) task).getDownloadedData(); 298 if (ds != null) { 299 // myPrimitives.removeAll(ds.allPrimitives()) will do the same job but much slower 300 for (OsmPrimitive primitive: ds.allPrimitives()) { 301 myPrimitives.remove(primitive); 302 } 303 } 289 final DataSet editDataSet = MainApplication.getLayerManager().getEditDataSet(); 290 if (editDataSet != null && osmData) { 291 final List<DownloadOsmTask> osmTasks = tasks.stream() 292 .filter(t -> t instanceof DownloadOsmTask).map(t -> (DownloadOsmTask) t) 293 .filter(t -> t.getDownloadedData() != null) 294 .collect(Collectors.toList()); 295 final Set<Bounds> tasksBounds = osmTasks.stream() 296 .flatMap(t -> t.getDownloadedData().getDataSourceBounds().stream()) 297 .collect(Collectors.toSet()); 298 final Set<Bounds> layerBounds = new LinkedHashSet<>(editDataSet.getDataSourceBounds()); 299 final Set<OsmPrimitive> myPrimitives = new LinkedHashSet<>(); 300 if (layerBounds.equals(tasksBounds)) { 301 // the full edit layer is updated (we have downloaded again all its current bounds) 302 myPrimitives.addAll(getCompletePrimitives(editDataSet)); 303 for (DownloadOsmTask task : osmTasks) { 304 // myPrimitives.removeAll(ds.allPrimitives()) will do the same job but much slower 305 task.getDownloadedData().allPrimitives().forEach(myPrimitives::remove); 306 } 307 } else { 308 // partial update, only check what has been downloaded 309 for (DownloadOsmTask task : osmTasks) { 310 myPrimitives.addAll(task.searchPotentiallyDeletedPrimitives(editDataSet)); 304 311 } 305 312 }
Note:
See TracChangeset
for help on using the changeset viewer.