Changeset 18868 in josm


Ignore:
Timestamp:
2023-10-12T22:32:39+02:00 (14 months ago)
Author:
taylor.smock
Message:

See #16207: Keep track of download area for notes

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadNotesTask.java

    r15784 r18868  
    1313
    1414import org.openstreetmap.josm.data.Bounds;
     15import org.openstreetmap.josm.data.DataSource;
    1516import org.openstreetmap.josm.data.ProjectionBounds;
    1617import org.openstreetmap.josm.data.ViewportData;
     
    7374    @Override
    7475    public Future<?> download(DownloadParams settings, Bounds downloadArea, ProgressMonitor progressMonitor) {
    75         downloadTask = new DownloadBoundingBoxTask(new BoundingBoxDownloader(downloadArea), progressMonitor);
     76        downloadTask = new DownloadBoundingBoxTask(downloadArea, progressMonitor);
    7677        return MainApplication.worker.submit(downloadTask);
    7778    }
     
    145146
    146147            noteLayer = new NoteLayer(notesData, tr("Notes"));
     148            if (this instanceof DownloadBoundingBoxTask && ((DownloadBoundingBoxTask) this).bounds != null) {
     149                noteLayer.getNoteData().addDataSource(new DataSource(((DownloadBoundingBoxTask) this).bounds, "OpenStreetMap server"));
     150            }
    147151            NoteLayer l = MainApplication.getLayerManager().getNoteLayer();
    148152            if (l != null) {
     
    170174
    171175    class DownloadBoundingBoxTask extends DownloadTask {
     176        private Bounds bounds;
     177
     178        DownloadBoundingBoxTask(Bounds bounds, ProgressMonitor progressMonitor) {
     179            this(new BoundingBoxDownloader(bounds), progressMonitor);
     180            this.bounds = bounds;
     181        }
    172182
    173183        DownloadBoundingBoxTask(OsmServerReader reader, ProgressMonitor progressMonitor) {
  • trunk/src/org/openstreetmap/josm/data/osm/NoteData.java

    r18208 r18868  
    77import java.util.Collections;
    88import java.util.Comparator;
     9import java.util.HashSet;
    910import java.util.List;
    1011import java.util.Map;
     12import java.util.Set;
    1113
    1214import org.openstreetmap.josm.data.Data;
     
    5355    private final ListenerList<NoteDataUpdateListener> listeners = ListenerList.create();
    5456
     57    private final Set<DataSource> dataSourceSet = new HashSet<>();
     58
    5559    /**
    5660     * Construct a new note container without notes
     
    140144        if (this != from) {
    141145            addNotes(from.noteList);
     146            from.getDataSources().forEach(this::addDataSource);
    142147        }
    143148    }
     
    315320    @Override
    316321    public Collection<DataSource> getDataSources() {
    317         return Collections.emptyList(); // Notes don't currently store data sources
     322        return Collections.unmodifiableSet(this.dataSourceSet);
     323    }
     324
     325    /**
     326     * Adds a new data source.
     327     * @param source data source to add
     328     * @return {@code true} if the collection changed as a result of the call
     329     * @since 18868
     330     */
     331    public synchronized boolean addDataSource(DataSource source) {
     332        return this.dataSourceSet.add(source);
    318333    }
    319334}
Note: See TracChangeset for help on using the changeset viewer.