Changeset 15353 in josm for trunk/src/org


Ignore:
Timestamp:
2019-09-16T01:50:12+02:00 (5 years ago)
Author:
Don-vip
Message:

fix #18118 - don't warn about potentially deleted objects when using download along several times

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  
    203203    }
    204204
     205    protected Collection<OsmPrimitive> searchPotentiallyDeletedPrimitives(DataSet ds) {
     206        return downloadTask.searchPrimitivesToUpdate(currentBounds, ds);
     207    }
     208
    205209    /**
    206210     * Superclass of internal download task.
     
    376380         * @return the primitives to update
    377381         */
    378         private Collection<OsmPrimitive> searchPrimitivesToUpdate(Bounds bounds, DataSet ds) {
     382        protected Collection<OsmPrimitive> searchPrimitivesToUpdate(Bounds bounds, DataSet ds) {
    379383            if (bounds == null)
    380384                return Collections.emptySet();
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadTaskList.java

    r15205 r15353  
    252252                }
    253253            }
    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());
    258255            if (!errors.isEmpty()) {
    259256                final Collection<String> items = new ArrayList<>();
     
    290287                }
    291288            }
    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));
    304311                    }
    305312                }
Note: See TracChangeset for help on using the changeset viewer.