Changeset 8216 in josm for trunk


Ignore:
Timestamp:
2015-04-18T11:50:47+02:00 (5 years ago)
Author:
simon04
Message:

fix #10867 - Notes download: inform user about reaching download limit

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

Legend:

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

    r8195 r8216  
    33
    44import static org.openstreetmap.josm.tools.I18n.tr;
     5import static org.openstreetmap.josm.tools.I18n.trn;
    56
    67import java.io.IOException;
     
    89import java.util.List;
    910import java.util.concurrent.Future;
     11
     12import javax.swing.JOptionPane;
    1013
    1114import org.openstreetmap.josm.Main;
     
    141144            try {
    142145                notesData = reader.parseNotes(null, null, subMonitor);
     146            } catch (BoundingBoxDownloader.MoreNotesException e) {
     147                JOptionPane.showMessageDialog(Main.parent, "<html>"
     148                                + trn("{0} note has been downloaded.", "{0} notes have been downloaded.", e.limit, e.limit)
     149                                + "<br>"
     150                                + tr("Since the download limit was {0}, there might be more notes to download.", e.limit)
     151                                + "<br>"
     152                                + tr("Request a smaller area to make sure that all notes are being downloaded.")
     153                                + "</html>",
     154                        tr("More notes to download"), JOptionPane.INFORMATION_MESSAGE);
    143155            } catch (Exception e) {
    144156                if (isCanceled())
  • trunk/src/org/openstreetmap/josm/io/BoundingBoxDownloader.java

    r8118 r8216  
    162162
    163163    @Override
    164     public List<Note> parseNotes(Integer noteLimit, Integer daysClosed, ProgressMonitor progressMonitor) throws OsmTransferException {
     164    public List<Note> parseNotes(Integer noteLimit, Integer daysClosed, ProgressMonitor progressMonitor) throws OsmTransferException, MoreNotesException {
    165165        progressMonitor.beginTask("Downloading notes");
    166166        noteLimit = checkNoteLimit(noteLimit);
     
    180180            InputStream is = getInputStream(url, progressMonitor.createSubTaskMonitor(1, false));
    181181            NoteReader reader = new NoteReader(is);
    182             return reader.parse();
     182            final List<Note> notes = reader.parse();
     183            if (notes.size() == noteLimit) {
     184                throw new MoreNotesException(noteLimit);
     185            }
     186            return notes;
    183187        } catch (IOException e) {
    184188            throw new OsmTransferException(e);
     
    187191        } finally {
    188192            progressMonitor.finishTask();
     193        }
     194    }
     195
     196    /**
     197     * Indicates that the number of fetched notes equals the specified limit. Thus there might be more notes to download.
     198     */
     199    public static class MoreNotesException extends RuntimeException{
     200        /**
     201         * The download limit sent to the server.
     202         */
     203        public final int limit;
     204
     205        public MoreNotesException(int limit) {
     206            this.limit = limit;
    189207        }
    190208    }
     
    194212            limit = Main.pref.getInteger("osm.notes.downloadLimit", 1000);
    195213        }
    196         if (limit > 10000) {
    197             Main.error("Requested note limit is over API hard limit of 10000. Reducing to 10000.");
    198             limit = 10000;
     214        if (limit > 50000) {
     215            // see max_number_of_nodes in https://github.com/openstreetmap/openstreetmap-website/blob/master/config/example.application.yml
     216            Main.error("Requested note limit is over API hard limit of 50000. Reducing to 50000.");
     217            limit = 50000;
    199218        }
    200219        if (limit < 1) {
     
    202221            limit = 1;
    203222        }
    204         Main.debug("returning note limit: " + limit);
    205223        return limit;
    206224    }
     
    214232            days = -1;
    215233        }
    216         Main.debug("returning days closed: " + days);
    217234        return days;
    218235    }
Note: See TracChangeset for help on using the changeset viewer.