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

Last change on this file since 2474 was 2070, checked in by Gubaer, 15 years ago

new: rewrite of CombineWay action
new: conflict resolution dialog for CombineWay, including conflicts for different relation memberships
cleanup: cleanup in OsmReader, reduces memory footprint and reduces parsing time
cleanup: made most of the public fields in OsmPrimitive @deprecated, added accessors and changed the code
cleanup: replaced usages of @deprecated constructors for ExtendedDialog
fixed #3208: Combine ways brokes relation order

WARNING: this changeset touches a lot of code all over the code base. "latest" might become slightly unstable in the next days. Also experience incompatibility issues with plugins in the next few days.

File size: 2.1 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.data.osm.DataSet;
10import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
11import org.openstreetmap.josm.gui.progress.ProgressMonitor;
12import org.xml.sax.SAXException;
13
14public class OsmServerObjectReader extends OsmServerReader {
15
16 long id;
17 OsmPrimitiveType type;
18 boolean full;
19
20 public OsmServerObjectReader(long id, OsmPrimitiveType type, boolean full) {
21 this.id = id;
22 this.type = type;
23 this.full = full;
24 }
25 /**
26 * Method to download single objects from OSM server. ways, relations, nodes
27 * @return the data requested
28 * @throws SAXException
29 * @throws IOException
30 */
31 @Override
32 public DataSet parseOsm(ProgressMonitor progressMonitor) throws OsmTransferException {
33 progressMonitor.beginTask("", 1);
34 InputStream in = null;
35 try {
36 progressMonitor.subTask(tr("Downloading OSM data..."));
37 StringBuffer sb = new StringBuffer();
38 sb.append(type.getAPIName());
39 sb.append("/");
40 sb.append(id);
41 if (full && ! type.equals(OsmPrimitiveType.NODE)) {
42 sb.append("/full");
43 }
44
45 in = getInputStream(sb.toString(), progressMonitor.createSubTaskMonitor(1, true));
46 if (in == null)
47 return null;
48 final DataSet data = OsmReader.parseDataSet(in, progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false));
49 return data;
50 } catch(OsmTransferException e) {
51 if (cancel) return null;
52 throw e;
53 } catch (Exception e) {
54 if (cancel) return null;
55 throw new OsmTransferException(e);
56 } finally {
57 progressMonitor.finishTask();
58 if (in!=null) {
59 try {
60 in.close();
61 } catch(Exception e) {}
62 }
63 activeConnection = null;
64 }
65 }
66
67}
Note: See TracBrowser for help on using the repository browser.