Opened 5 years ago
Closed 5 years ago
#18436 closed enhancement (fixed)
[PATCH RFC] There should be a method to know when a DataSet's DataSources change
Reported by: | taylor.smock | Owned by: | team |
---|---|---|---|
Priority: | normal | Milestone: | 19.12 |
Component: | Core | Version: | |
Keywords: | datasource, download | Cc: |
Description
In the attached patch, I've created a new listener that the DataSet triggers when it modifies the DataSource list.
Possible use cases:
- Mapillary
- Microsoft Streetside (the interesting code is literally the same as Mapillary's)
- OpenStreetCam
- MapWithAI
Mapillary currently uses the following in src/main/java/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java
:
new DataSetListenerAdapter(e -> { if (e instanceof DataChangedEvent && MapillaryDownloader.getMode() == DOWNLOAD_MODE.OSM_AREA) { // When more data is downloaded, a delayed update is thrown, in order to // wait for the data bounds to be set. MainApplication.worker.execute(MapillaryDownloader::downloadOSMArea); } });
While it works, it is prone to being called when the user didn't download an additional area.
Attachments (2)
Change History (5)
by , 5 years ago
Attachment: | 18436.patch added |
---|
comment:1 by , 5 years ago
Milestone: | → 19.12 |
---|
by , 5 years ago
Attachment: | 18436.1.patch added |
---|
Don't add duplicate DataSource
entries to dataSources
(DataSetMerger
adds them, and then mergeFrom
was adding them again). See source:trunk/src/org/openstreetmap/josm/data/osm/DataSet.java@15559:1084-1087#L1084
comment:2 by , 5 years ago
source:trunk/src/org/openstreetmap/josm/data/osm/DataSetMerger.java@15559:458-461#L458 is where DataSetMerger
adds the bounds.
Add listeners for data source change events (for DataSets) -- class/method names may need to be changed for clarity