source: josm/trunk/src/org/openstreetmap/josm/io/OsmServerLocationReader.java@ 2667

Last change on this file since 2667 was 1811, checked in by jttt, 15 years ago

PleaseWait refactoring. Progress is now reported using ProgressMonitor interface, that is available through PleaseWaitRunnable.

File size: 1.5 KB
Line 
1//License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.io;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.io.InputStream;
7
8import org.openstreetmap.josm.data.osm.DataSet;
9import org.openstreetmap.josm.gui.progress.ProgressMonitor;
10
11public class OsmServerLocationReader extends OsmServerReader {
12
13 String url;
14
15 public OsmServerLocationReader(String url) {
16 this.url = url;
17 }
18
19 /**
20 * Method to download OSM files from somewhere
21 */
22 @Override
23 public DataSet parseOsm(ProgressMonitor progressMonitor) throws OsmTransferException {
24 InputStream in = null;
25 progressMonitor.beginTask(tr("Contacting Server...", 10));
26 try {
27 in = getInputStreamRaw(url, progressMonitor.createSubTaskMonitor(9, false));
28 if (in == null)
29 return null;
30 progressMonitor.subTask(tr("Downloading OSM data..."));
31 return OsmReader.parseDataSet(in, progressMonitor.createSubTaskMonitor(1, false));
32 } catch(OsmTransferException e) {
33 throw e;
34 } catch (Exception e) {
35 if (cancel)
36 return null;
37 throw new OsmTransferException(e);
38 } finally {
39 progressMonitor.finishTask();
40 try {
41 if (in != null) {
42 in.close();
43 }
44 activeConnection = null;
45 } catch(Exception e) {/* ignore it */}
46 }
47 }
48
49}
Note: See TracBrowser for help on using the repository browser.