Modify

Opened 2 years ago

Closed 14 months ago

#21886 closed defect (fixed)

[patch] Download Dialog incorrectly reports note area rejection

Reported by: gaben Owned by: team
Priority: minor Milestone: 23.05
Component: Core Version:
Keywords: template_report download note area reject Cc:

Description

What steps will reproduce the problem?

  1. Open download dialog
  2. Play with the bounding box while only the OSM data download checked
  3. Repeat step 2 with notes checked only

What is the expected result?

For note download the allowed bounding box is 100x greater than data, so the message should reflect that.

What happens instead?

The note's allowed bounding box size (25) ignored, the data restrictions (0.25) used instead.

Please provide any additional information below. Attach a screenshot if possible.

This patch fixes the issue, but the existing code not working as expected. See the comment.

  • src/org/openstreetmap/josm/gui/download/OSMDownloadSource.java

     
    340340            }
    341341
    342342            displaySizeCheckResult(DOWNLOAD_SOURCES.stream()
     343                    // this line doesn't work, but should: .filter(IDownloadSourceType::isEnabled)
     344                    .filter(type -> type.getCheckBox().isSelected())    //this works
    343345                    .anyMatch(type -> type.isDownloadAreaTooLarge(bbox)));
    344346        }
    345347
     
    414416        @Override
    415417        public boolean isDownloadAreaTooLarge(Bounds bound) {
    416418            // see max_request_area in
    417             // https://github.com/openstreetmap/openstreetmap-website/blob/master/config/example.application.yml
     419            // https://github.com/openstreetmap/openstreetmap-website/blob/master/config/settings.yml
    418420            return bound.getArea() > Config.getPref().getDouble("osm-server.max-request-area", 0.25);
    419421        }
    420422    }
     
    492494        @Override
    493495        public boolean isDownloadAreaTooLarge(Bounds bound) {
    494496            // see max_note_request_area in
    495             // https://github.com/openstreetmap/openstreetmap-website/blob/master/config/example.application.yml
     497            // https://github.com/openstreetmap/openstreetmap-website/blob/master/config/settings.yml
    496498            return bound.getArea() > Config.getPref().getDouble("osm-server.max-request-area-notes", 25);
    497499        }
    498500    }

Attachments (1)

josm_21886.patch (2.9 KB ) - added by gaben 15 months ago.

Download all attachments as: .zip

Change History (18)

comment:1 by gaben, 2 years ago

Keywords: download note area reject added

comment:2 by gaben, 2 years ago

Summary: Download Dialog incorrectly reports note area rejection[WIP patch] Download Dialog incorrectly reports note area rejection

comment:3 by gaben, 2 years ago

Ping/up/whatever. I have no idea why IDownloadSourceType::isEnabled isn't working.

comment:4 by taylor.smock, 2 years ago

It looks like it is due to the preferences not being updated when the checkbox state changes.

isEnabled() calls getBooleanProperty().get().

EDIT: And the answer is in the javadoc

Determines the last state of the download type

Last edited 2 years ago by taylor.smock (previous) (diff)

comment:5 by gaben, 2 years ago

Is it desired? Because we are now dealing with two states. One for live and the other for stored checkbox (BooleanProperty) state.

For this reason, the javadoc is misleading.

Last edited 2 years ago by gaben (previous) (diff)

comment:6 by taylor.smock, 2 years ago

I cannot remember exactly why I did that, but most likely due to having a Cancel button (AKA don't persist changed state when user has canceled), which would kind of argue against live updates to the property.

comment:7 by gaben, 2 years ago

Checkbox states saved on the Download window close, doesn't matter if you cancel or download. See here and here.

comment:8 by taylor.smock, 2 years ago

In that case, we might as well add a new checkbox listener that updates the preferences. Which means we can remove the call in rememberSettings. But only if we notify plugins that use it.

comment:9 by gaben, 2 years ago

I'm not familiar with Java GUI programming, but I see listeners for download source checkboxes e.g. here.

comment:10 by taylor.smock, 2 years ago

Yes. That listener is defined here.

comment:11 by gaben, 20 months ago

What could be the solution, a new listener you mentioned in comment:8?

in reply to:  8 comment:12 by gaben, 18 months ago

Replying to taylor.smock:

In that case, we might as well add a new checkbox listener that updates the preferences. Which means we can remove the call in rememberSettings. But only if we notify plugins that use it.

How can I check which plugins are using the rememberSettings() function?

comment:13 by taylor.smock, 18 months ago

I'd probably start by doing a grep in a JOSM svn checkout (the one with core plugins).

Beyond that, we have a (currently broken) check-plugins ant target, which someone should probably fix.

I had a script for checking plugins using GitLab CI, but I don't know if it still works. It used japi.

comment:14 by gaben, 15 months ago

I found three usages so far:

  • plugins/wikipedia/src/main/java/org/wikipedia/gui/SophoxDownloadReader.java:240
  • plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/download/CadastreDownloadSourcePanel.java:181
  • plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/download/CadastreDownloadSourcePanel.java:125

Don't know how to proceed :(

by gaben, 15 months ago

Attachment: josm_21886.patch added

comment:15 by gaben, 15 months ago

Milestone: 23.04
Summary: [WIP patch] Download Dialog incorrectly reports note area rejection[patch] Download Dialog incorrectly reports note area rejection

The attached patch should not break plugins.

comment:16 by taylor.smock, 14 months ago

Milestone: 23.0423.05

Ticket retargeted after milestone closed

comment:17 by taylor.smock, 14 months ago

Resolution: fixed
Status: newclosed

In 18728/josm:

Fix #21886: Download Dialog incorrectly reports note area rejection (patch by gaben, modified)

The modifications are as follows:

  • SonarLint fixes
  • Removal of unused code (see r16503)

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.