source: josm/trunk/src/org/openstreetmap/josm/io/OsmServerObjectReader.java@ 1388

Last change on this file since 1388 was 1169, checked in by stoecker, 15 years ago

removed usage of tab stops

File size: 2.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.IOException;
7import java.io.InputStream;
8
9import org.openstreetmap.josm.Main;
10import org.openstreetmap.josm.data.osm.DataSet;
11import org.xml.sax.SAXException;
12
13public class OsmServerObjectReader extends OsmServerReader {
14
15 public final static String TYPE_WAY = "way";
16 public final static String TYPE_REL = "relation";
17 public final static String TYPE_NODE = "node";
18
19 long id;
20 String type;
21 boolean full;
22
23 public OsmServerObjectReader(long id, String type, boolean full) {
24 this.id = id;
25 this.type = type;
26 this.full = full;
27 }
28 /**
29 * Method to download single objects from OSM server. ways, relations, nodes
30 * @param id Object ID
31 * @param type way node relation
32 * @param full download with or without child objects
33 * @return the data requested
34 * @throws SAXException
35 * @throws IOException
36 */
37 public DataSet parseOsm() throws SAXException, IOException {
38 try {
39 Main.pleaseWaitDlg.progress.setValue(0);
40 Main.pleaseWaitDlg.currentAction.setText(tr("Contacting OSM Server..."));
41 StringBuffer sb = new StringBuffer();
42 sb.append(type);
43 sb.append("/");
44 sb.append(id);
45 if (full)
46 sb.append("/full");
47
48 final InputStream in = getInputStream(sb.toString(), Main.pleaseWaitDlg);
49 if (in == null)
50 return null;
51 Main.pleaseWaitDlg.currentAction.setText(tr("Downloading OSM data..."));
52 final DataSet data = OsmReader.parseDataSet(in, null, Main.pleaseWaitDlg);
53// String origin = Main.pref.get("osm-server.url")+"/"+Main.pref.get("osm-server.version", "0.5");
54// Bounds bounds = new Bounds(new LatLon(lat1, lon1), new LatLon(lat2, lon2));
55// DataSource src = new DataSource(bounds, origin);
56// data.dataSources.add(src);
57 in.close();
58 activeConnection = null;
59 return data;
60 } catch (IOException e) {
61 if (cancel)
62 return null;
63 throw e;
64 } catch (SAXException e) {
65 throw e;
66 } catch (Exception e) {
67 if (cancel)
68 return null;
69 if (e instanceof RuntimeException)
70 throw (RuntimeException)e;
71 throw new RuntimeException(e);
72 }
73 }
74
75}
Note: See TracBrowser for help on using the repository browser.