Changeset 16893 in josm


Ignore:
Timestamp:
2020-08-14T23:46:00+02:00 (8 months ago)
Author:
simon04
Message:

fix #3450 - SlippyMapBBoxChooser: confirm download bounds outside current map view

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/bbox/SlippyMapBBoxChooser.java

    r16623 r16893  
    359359        // Do nothing
    360360    }
     361
     362    /**
     363     * Returns the currently visible map area
     364     * @return the currently visible map area
     365     */
     366    public Bounds getVisibleMapArea() {
     367        final ICoordinate topLeft = getPosition(0, 0);
     368        final ICoordinate bottomRight = getPosition(getWidth(), getHeight());
     369        final Bounds bounds = new Bounds(topLeft.getLat(), topLeft.getLon(), false);
     370        bounds.extend(bottomRight.getLat(), bottomRight.getLon());
     371        return bounds;
     372    }
    361373}
  • trunk/src/org/openstreetmap/josm/gui/download/DownloadDialog.java

    r16684 r16893  
    4444import org.openstreetmap.josm.gui.MainApplication;
    4545import org.openstreetmap.josm.gui.MapView;
     46import org.openstreetmap.josm.gui.bbox.SlippyMapBBoxChooser;
    4647import org.openstreetmap.josm.gui.datatransfer.ClipboardUtils;
    4748import org.openstreetmap.josm.gui.help.ContextSensitiveHelpAction;
     
    502503     */
    503504    public DownloadSettings getDownloadSettings(boolean newLayer) {
    504         return new DownloadSettings(currentBounds, newLayer, isZoomToDownloadedDataRequired());
     505        final Component areaSelector = tpDownloadAreaSelectors.getSelectedComponent();
     506        final Bounds slippyMapBounds = areaSelector instanceof SlippyMapBBoxChooser
     507                ? ((SlippyMapBBoxChooser) areaSelector).getVisibleMapArea()
     508                : null;
     509        return new DownloadSettings(currentBounds, slippyMapBounds, newLayer, isZoomToDownloadedDataRequired());
    505510    }
    506511
  • trunk/src/org/openstreetmap/josm/gui/download/DownloadSettings.java

    r12846 r16893  
    1515
    1616    private final Bounds downloadBounds;
     17    private final Bounds slippyMapBounds;
    1718    private final boolean downloadAsNewLayer;
    1819    private final boolean zoomToDownloadedData;
     
    2122     * Initializes a new instance of {@code DownloadSettings}.
    2223     * @param bbox The bounding box
     24     * @param slippyMapBounds The bounds of the {@link SlippyMapChooser}/{@link org.openstreetmap.josm.gui.bbox.SlippyMapBBoxChooser}
    2325     * @param downloadAsNewLayer The flag defining if a new layer must be created for the downloaded data.
    2426     * @param zoomToDownloadedData The flag defining if the map view, see {@link SlippyMapChooser},
    25      *                             must zoom to the downloaded data.
    2627     */
    27     public DownloadSettings(Bounds bbox, boolean downloadAsNewLayer, boolean zoomToDownloadedData) {
     28    public DownloadSettings(Bounds bbox, Bounds slippyMapBounds, boolean downloadAsNewLayer, boolean zoomToDownloadedData) {
    2829        this.downloadBounds = bbox;
     30        this.slippyMapBounds = slippyMapBounds;
    2931        this.downloadAsNewLayer = downloadAsNewLayer;
    3032        this.zoomToDownloadedData = zoomToDownloadedData;
     
    5456        return Optional.ofNullable(downloadBounds);
    5557    }
     58
     59    /**
     60     * Gets the slippy map bounds
     61     * @return the slippy map bounds or an empty {@link Optional} if no slippy map was used to select the download bounds
     62     */
     63    public Optional<Bounds> getSlippyMapBounds() {
     64        return Optional.ofNullable(slippyMapBounds);
     65    }
    5666}
  • trunk/src/org/openstreetmap/josm/gui/download/OSMDownloadSource.java

    r16553 r16893  
    273273            }
    274274
     275            final Boolean slippyMapShowsDownloadBounds = settings.getSlippyMapBounds()
     276                    .map(b -> b.intersects(settings.getDownloadBounds().get()))
     277                    .orElse(true);
     278            if (!slippyMapShowsDownloadBounds) {
     279                final int confirmation = JOptionPane.showConfirmDialog(
     280                        this.getParent(),
     281                        tr("The slippy map no longer shows the selected download bounds. Continue?"),
     282                        tr("Confirmation"),
     283                        JOptionPane.OK_CANCEL_OPTION,
     284                        JOptionPane.QUESTION_MESSAGE
     285                );
     286                if (confirmation != JOptionPane.OK_OPTION) {
     287                    return false;
     288                }
     289            }
     290
    275291            /*
    276292             * Checks if the user selected the type of data to download. At least one the following
Note: See TracChangeset for help on using the changeset viewer.