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

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.