Changeset 7531 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2014-09-13T00:40:11+02:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/DownloadAction.java
r7509 r7531 11 11 import org.openstreetmap.josm.Main; 12 12 import org.openstreetmap.josm.actions.downloadtasks.DownloadGpsTask; 13 import org.openstreetmap.josm.actions.downloadtasks.DownloadNotesTask; 13 14 import org.openstreetmap.josm.actions.downloadtasks.DownloadOsmTask; 14 15 import org.openstreetmap.josm.actions.downloadtasks.PostDownloadHandler; … … 54 55 Main.worker.submit(new PostDownloadHandler(task, future)); 55 56 } 57 58 //TODO: This eventually needs to be a checkbox in the UI 59 //For now I'm adding it as a hidden feature since this is still a work in progress 60 if (Main.pref.getBoolean("osm.notes.enableDownload", false)) { 61 DownloadNotesTask task = new DownloadNotesTask(); 62 Future<?> future = task.download(false, area, null); 63 Main.worker.submit(new PostDownloadHandler(task, future)); 64 } 56 65 } 57 66 } -
trunk/src/org/openstreetmap/josm/actions/OpenLocationAction.java
r7434 r7531 23 23 import org.openstreetmap.josm.Main; 24 24 import org.openstreetmap.josm.actions.downloadtasks.DownloadGpsTask; 25 import org.openstreetmap.josm.actions.downloadtasks.DownloadNotesTask; 25 26 import org.openstreetmap.josm.actions.downloadtasks.DownloadOsmChangeCompressedTask; 26 27 import org.openstreetmap.josm.actions.downloadtasks.DownloadOsmChangeTask; … … 59 60 addDownloadTaskClass(DownloadOsmTask.class); 60 61 addDownloadTaskClass(DownloadGpsTask.class); 62 addDownloadTaskClass(DownloadNotesTask.class); 61 63 addDownloadTaskClass(DownloadOsmChangeTask.class); 62 64 addDownloadTaskClass(DownloadOsmUrlTask.class); -
trunk/src/org/openstreetmap/josm/io/BoundingBoxDownloader.java
r7033 r7531 6 6 import java.io.IOException; 7 7 import java.io.InputStream; 8 8 import java.util.List; 9 10 import org.openstreetmap.josm.Main; 9 11 import org.openstreetmap.josm.data.Bounds; 10 12 import org.openstreetmap.josm.data.gpx.GpxData; 13 import org.openstreetmap.josm.data.notes.Note; 11 14 import org.openstreetmap.josm.data.osm.DataSet; 12 15 import org.openstreetmap.josm.gui.progress.ProgressMonitor; … … 154 157 } 155 158 } 159 160 @Override 161 public List<Note> parseNotes(Integer noteLimit, Integer daysClosed, ProgressMonitor progressMonitor) throws OsmTransferException { 162 progressMonitor.beginTask("Downloading notes"); 163 noteLimit = checkNoteLimit(noteLimit); 164 daysClosed = checkDaysClosed(daysClosed); 165 String url = new StringBuilder() 166 .append("notes?limit=") 167 .append(noteLimit) 168 .append("&closed=") 169 .append(daysClosed) 170 .append("&bbox=") 171 .append(lon1) 172 .append(",").append(lat1) 173 .append(",").append(lon2) 174 .append(",").append(lat2) 175 .toString(); 176 try { 177 InputStream is = getInputStream(url, progressMonitor.createSubTaskMonitor(1, false)); 178 NoteReader reader = new NoteReader(is); 179 return reader.parse(); 180 } catch (IOException e) { 181 throw new OsmTransferException(e); 182 } catch (SAXException e) { 183 throw new OsmTransferException(e); 184 } finally { 185 progressMonitor.finishTask(); 186 } 187 } 188 189 private Integer checkNoteLimit(Integer limit) { 190 if (limit == null) { 191 limit = Main.pref.getInteger("osm.notes.downloadLimit", 1000); 192 } 193 if (limit > 10000) { 194 Main.error("Requested note limit is over API hard limit of 10000. Reducing to 10000."); 195 limit = 10000; 196 } 197 if (limit < 1) { 198 Main.error("Requested note limit is less than 1. Setting to 1."); 199 limit = 1; 200 } 201 Main.debug("returning note limit: " + limit); 202 return limit; 203 } 204 205 private Integer checkDaysClosed(Integer days) { 206 if (days == null) { 207 days = Main.pref.getInteger("osm.notes.daysClosed", 1); 208 } 209 if (days < -1) { 210 Main.error("Requested days closed must be greater than -1"); 211 days = -1; 212 } 213 Main.debug("returning days closed: " + days); 214 return days; 215 } 216 156 217 } -
trunk/src/org/openstreetmap/josm/io/OsmServerLocationReader.java
r7509 r7531 6 6 import java.io.IOException; 7 7 import java.io.InputStream; 8 import java.util.ArrayList; 9 import java.util.List; 8 10 9 11 import org.openstreetmap.josm.actions.downloadtasks.DownloadGpsTask; 10 12 import org.openstreetmap.josm.data.gpx.GpxData; 13 import org.openstreetmap.josm.data.notes.Note; 11 14 import org.openstreetmap.josm.data.osm.DataSet; 12 15 import org.openstreetmap.josm.gui.progress.ProgressMonitor; … … 106 109 } 107 110 111 @Override 112 public List<Note> parseRawNotes(final ProgressMonitor progressMonitor) throws OsmTransferException { 113 return doParse(new NoteParser(progressMonitor, Compression.NONE), progressMonitor); 114 } 115 116 @Override 117 public List<Note> parseRawNotesBzip2(final ProgressMonitor progressMonitor) throws OsmTransferException { 118 return doParse(new NoteParser(progressMonitor, Compression.BZIP2), progressMonitor); 119 } 120 108 121 protected class OsmParser extends Parser<DataSet> { 109 122 protected OsmParser(ProgressMonitor progressMonitor, Compression compression) { … … 154 167 } 155 168 } 169 170 protected class NoteParser extends Parser<List<Note>> { 171 172 public NoteParser(ProgressMonitor progressMonitor, Compression compression) { 173 super(progressMonitor, compression); 174 } 175 176 @Override 177 public List<Note> parse() throws OsmTransferException, IllegalDataException, IOException, SAXException { 178 in = getInputStream(url, progressMonitor.createSubTaskMonitor(1, true)); 179 if (in == null) { 180 return new ArrayList<Note>(); 181 } 182 progressMonitor.subTask(tr("Downloading OSM notes...")); 183 NoteReader reader = new NoteReader(compression.getUncompressedInputStream(in)); 184 return reader.parse(); 185 } 186 } 156 187 } -
trunk/src/org/openstreetmap/josm/io/OsmServerReader.java
r7434 r7531 20 20 import org.openstreetmap.josm.Main; 21 21 import org.openstreetmap.josm.data.gpx.GpxData; 22 import org.openstreetmap.josm.data.notes.Note; 22 23 import org.openstreetmap.josm.data.osm.DataSet; 23 24 import org.openstreetmap.josm.gui.progress.ProgressMonitor; … … 349 350 return gpxParsedProperly; 350 351 } 352 353 /** 354 * Downloads notes from the API, given API limit parameters 355 * 356 * @param noteLimit How many notes to download. Defaults to 1000 if not specified. API has a hard limit of 10000 357 * @param daysClosed Return notes closed this many days in the past. -1 means all notes, ever. 0 means only unresolved notes. 358 * @param progressMonitor Progress monitor for user feedback 359 * @return List of notes returned by the API 360 * @throws OsmTransferException if any errors happen 361 */ 362 public List<Note> parseNotes(Integer noteLimit, Integer daysClosed, ProgressMonitor progressMonitor) throws OsmTransferException { 363 return null; 364 } 365 366 /** 367 * Downloads notes from a given raw URL. The URL is assumed to be complete and no API limits are added 368 * 369 * @param progressMonitor 370 * @return A list of notes parsed from the URL 371 * @throws OsmTransferException 372 */ 373 public List<Note> parseRawNotes(final ProgressMonitor progressMonitor) throws OsmTransferException { 374 return null; 375 } 376 377 /** 378 * Download notes from a URL that contains a bzip2 compressed notes dump file 379 * @param progressMonitor 380 * @return A list of notes parsed from the URL 381 * @throws OsmTransferException 382 */ 383 public List<Note> parseRawNotesBzip2(final ProgressMonitor progressMonitor) throws OsmTransferException { 384 return null; 385 } 351 386 }
Note:
See TracChangeset
for help on using the changeset viewer.