Modify

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)

18436.patch (24.3 KB ) - added by taylor.smock 5 years ago.
Add listeners for data source change events (for DataSets) -- class/method names may need to be changed for clarity
18436.1.patch (24.5 KB ) - added by taylor.smock 5 years ago.
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

Download all attachments as: .zip

Change History (5)

by taylor.smock, 5 years ago

Attachment: 18436.patch added

Add listeners for data source change events (for DataSets) -- class/method names may need to be changed for clarity

comment:1 by Don-vip, 5 years ago

Milestone: 19.12

by taylor.smock, 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:3 by Don-vip, 5 years ago

Resolution: fixed
Status: newclosed

In 15609/josm:

fix #18436 - add listeners to know when a DataSet's DataSources change (patch by taylor.smock)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.