Ignore:
Timestamp:
2015-04-18T12:33:06+02:00 (5 years ago)
Author:
simon04
Message:

fix #10868 - Add osm.notes.daysClosed to preference dialog

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/BoundingBoxDownloader.java

    r8217 r8218  
    88import java.util.List;
    99
    10 import org.openstreetmap.josm.Main;
    1110import org.openstreetmap.josm.data.Bounds;
    1211import org.openstreetmap.josm.data.DataSource;
     
    162161
    163162    @Override
    164     public List<Note> parseNotes(Integer noteLimit, Integer daysClosed, ProgressMonitor progressMonitor) throws OsmTransferException, MoreNotesException {
     163    public List<Note> parseNotes(int noteLimit, int daysClosed, ProgressMonitor progressMonitor) throws OsmTransferException, MoreNotesException {
    165164        progressMonitor.beginTask("Downloading notes");
    166         noteLimit = checkNoteLimit(noteLimit);
    167         daysClosed = checkDaysClosed(daysClosed);
    168         String url = new StringBuilder()
    169         .append("notes?limit=")
    170         .append(noteLimit)
    171         .append("&closed=")
    172         .append(daysClosed)
    173         .append("&bbox=")
    174         .append(lon1)
    175         .append(",").append(lat1)
    176         .append(",").append(lon2)
    177         .append(",").append(lat2)
    178         .toString();
     165        CheckParameterUtil.ensureThat(noteLimit > 0, "Requested note limit is less than 1.");
     166        // see max_number_of_nodes in https://github.com/openstreetmap/openstreetmap-website/blob/master/config/example.application.yml
     167        CheckParameterUtil.ensureThat(noteLimit <= 50000, "Requested note limit is over API hard limit of 50000.");
     168        CheckParameterUtil.ensureThat(daysClosed >= 0, "Requested note limit is less than 0.");
     169        String url = "notes?limit=" + noteLimit + "&closed=" + daysClosed + "&bbox=" + lon1 + "," + lat1 + "," + lon2 + "," + lat2;
    179170        try {
    180171            InputStream is = getInputStream(url, progressMonitor.createSubTaskMonitor(1, false));
     
    213204    }
    214205
    215     private Integer checkNoteLimit(Integer limit) {
    216         if (limit == null) {
    217             limit = Main.pref.getInteger("osm.notes.downloadLimit", 1000);
    218         }
    219         if (limit > 50000) {
    220             // see max_number_of_nodes in https://github.com/openstreetmap/openstreetmap-website/blob/master/config/example.application.yml
    221             Main.error("Requested note limit is over API hard limit of 50000. Reducing to 50000.");
    222             limit = 50000;
    223         }
    224         if (limit < 1) {
    225             Main.error("Requested note limit is less than 1. Setting to 1.");
    226             limit = 1;
    227         }
    228         return limit;
    229     }
    230 
    231     private Integer checkDaysClosed(Integer days) {
    232         if (days == null) {
    233             days = Main.pref.getInteger("osm.notes.daysClosed", 7);
    234         }
    235         if (days < -1) {
    236             Main.error("Requested days closed must be greater than -1");
    237             days = -1;
    238         }
    239         return days;
    240     }
    241 
    242206}
  • trunk/src/org/openstreetmap/josm/io/OsmServerReader.java

    r7531 r8218  
    354354     * Downloads notes from the API, given API limit parameters
    355355     *
    356      * @param noteLimit How many notes to download. Defaults to 1000 if not specified. API has a hard limit of 10000
     356     * @param noteLimit How many notes to download.
    357357     * @param daysClosed Return notes closed this many days in the past. -1 means all notes, ever. 0 means only unresolved notes.
    358358     * @param progressMonitor Progress monitor for user feedback
     
    360360     * @throws OsmTransferException if any errors happen
    361361     */
    362     public List<Note> parseNotes(Integer noteLimit, Integer daysClosed, ProgressMonitor progressMonitor) throws OsmTransferException {
     362    public List<Note> parseNotes(int noteLimit, int daysClosed, ProgressMonitor progressMonitor) throws OsmTransferException {
    363363        return null;
    364364    }
Note: See TracChangeset for help on using the changeset viewer.