- Timestamp:
- 2006-12-13T14:37:26+01:00 (18 years ago)
- Location:
- src/org/openstreetmap/josm
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/actions/DownloadIncompleteAction.java
r160 r175 14 14 15 15 import org.openstreetmap.josm.Main; 16 import org.openstreetmap.josm.data.osm.OsmPrimitive; 16 17 import org.openstreetmap.josm.data.osm.Way; 18 import org.openstreetmap.josm.data.osm.visitor.MergeVisitor; 17 19 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 18 20 import org.openstreetmap.josm.io.IncompleteDownloader; … … 46 48 47 49 @Override protected void finish() { 50 MergeVisitor merger = new MergeVisitor(Main.ds); 51 for (OsmPrimitive osm : reader.data.allPrimitives()) 52 osm.visit(merger); 48 53 Main.parent.repaint(); 49 54 } -
src/org/openstreetmap/josm/actions/OpenAction.java
r160 r175 69 69 DataSet dataSet; 70 70 if (ExtensionFileFilter.filters[ExtensionFileFilter.OSM].acceptName(fn)) { 71 dataSet = OsmReader.parseDataSet(new FileInputStream(file), Main.ds, Main.pleaseWaitDlg);71 dataSet = OsmReader.parseDataSet(new FileInputStream(file), null, Main.pleaseWaitDlg); 72 72 } else if (ExtensionFileFilter.filters[ExtensionFileFilter.CSV].acceptName(fn)) { 73 73 JOptionPane.showMessageDialog(Main.parent, fn+": "+tr("CSV Data import for non-GPS data is not implemented yet.")); -
src/org/openstreetmap/josm/actions/downloadtasks/DownloadGpsTask.java
r153 r175 17 17 import org.xml.sax.SAXException; 18 18 19 public class DownloadGpsTask extends PleaseWaitRunnable implements DownloadTask { 20 private DownloadAction action; 21 private BoundingBoxDownloader reader; 22 private Collection<Collection<GpsPoint>> rawData; 19 public class DownloadGpsTask implements DownloadTask { 20 21 private static class Task extends PleaseWaitRunnable { 22 private BoundingBoxDownloader reader; 23 private DownloadAction action; 24 private Collection<Collection<GpsPoint>> rawData; 25 26 public Task(BoundingBoxDownloader reader, DownloadAction action) { 27 super(tr("Downloading GPS data")); 28 this.reader = reader; 29 this.action = action; 30 } 31 32 @Override public void realRun() throws IOException, SAXException { 33 rawData = reader.parseRawGps(); 34 } 35 36 @Override protected void finish() { 37 if (rawData == null) 38 return; 39 String name = action.latlon[0].getText() + " " + action.latlon[1].getText() + " x " + this.action.latlon[2].getText() + " " + this.action.latlon[3].getText(); 40 Main.main.addLayer(new RawGpsLayer(rawData, name, null)); 41 } 42 43 @Override protected void cancel() { 44 if (reader != null) 45 reader.cancel(); 46 } 47 } 48 23 49 private JCheckBox checkBox = new JCheckBox(tr("Raw GPS data")); 24 50 25 public DownloadGpsTask() {26 super(tr("Downloading GPS data"));27 }28 29 @Override public void realRun() throws IOException, SAXException {30 rawData = reader.parseRawGps();31 }32 33 @Override protected void finish() {34 if (rawData == null)35 return;36 String name = action.latlon[0].getText() + " " + action.latlon[1].getText() + " x " + this.action.latlon[2].getText() + " " + this.action.latlon[3].getText();37 Main.main.addLayer(new RawGpsLayer(rawData, name, null));38 }39 40 @Override protected void cancel() {41 if (reader != null)42 reader.cancel();43 }44 45 46 51 public void download(DownloadAction action, double minlat, double minlon, double maxlat, double maxlon) { 47 this.action = action; 48 reader = new BoundingBoxDownloader(minlat, minlon, maxlat, maxlon); 49 Main.worker.execute(this); 52 Task task = new Task(new BoundingBoxDownloader(minlat, minlon, maxlat, maxlon), action); 53 Main.worker.execute(task); 50 54 } 51 55 -
src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java
r153 r175 20 20 * Run in the worker thread. 21 21 */ 22 public class DownloadOsmTask extends PleaseWaitRunnable implements DownloadTask { 23 private BoundingBoxDownloader reader; 24 private DataSet dataSet; 22 public class DownloadOsmTask implements DownloadTask { 23 24 private static class Task extends PleaseWaitRunnable { 25 private BoundingBoxDownloader reader; 26 private DataSet dataSet; 27 28 public Task(BoundingBoxDownloader reader) { 29 super(tr("Downloading data")); 30 this.reader = reader; 31 } 32 33 @Override public void realRun() throws IOException, SAXException { 34 dataSet = reader.parseOsm(); 35 } 36 37 @Override protected void finish() { 38 if (dataSet == null) 39 return; // user cancelled download or error occoured 40 if (dataSet.allPrimitives().isEmpty()) 41 errorMessage = tr("No data imported."); 42 Main.main.addLayer(new OsmDataLayer(dataSet, tr("Data Layer"), null)); 43 } 44 45 @Override protected void cancel() { 46 if (reader != null) 47 reader.cancel(); 48 } 49 } 25 50 private JCheckBox checkBox = new JCheckBox(tr("OpenStreetMap data")); 26 51 27 public DownloadOsmTask() {28 super(tr("Downloading data"));29 }30 31 @Override public void realRun() throws IOException, SAXException {32 dataSet = reader.parseOsm();33 }34 35 @Override protected void finish() {36 if (dataSet == null)37 return; // user cancelled download or error occoured38 if (dataSet.allPrimitives().isEmpty())39 errorMessage = tr("No data imported.");40 Main.main.addLayer(new OsmDataLayer(dataSet, tr("Data Layer"), null));41 }42 43 @Override protected void cancel() {44 if (reader != null)45 reader.cancel();46 }47 48 52 public void download(DownloadAction action, double minlat, double minlon, double maxlat, double maxlon) { 49 reader = new BoundingBoxDownloader(minlat, minlon, maxlat, maxlon);50 Main.worker.execute(t his);53 Task task = new Task(new BoundingBoxDownloader(minlat, minlon, maxlat, maxlon)); 54 Main.worker.execute(task); 51 55 } 52 56 -
src/org/openstreetmap/josm/data/osm/DataSet.java
r142 r175 7 7 import java.util.Iterator; 8 8 import java.util.LinkedList; 9 import java.util.List; 9 10 10 11 import org.openstreetmap.josm.data.SelectionChangedListener; … … 12 13 /** 13 14 * DataSet is the data behind the application. It can consists of only a few 14 * points up to the whole osm database. DataSet's can be merged together, 15 * points up to the whole osm database. DataSet's can be merged together, 15 16 * saved, (up/down/disk)loaded etc. 16 17 * 17 * Note, that DataSet is not an osm-primitive and so has no key association 18 * Note, that DataSet is not an osm-primitive and so has no key association 18 19 * but a few members to store some information. 19 * 20 * 20 21 * @author imi 21 22 */ … … 35 36 36 37 /** 37 * All ways (Streets etc.) in the DataSet. 38 * 39 * The nodes of the way segments of this way must be objects from 40 * the nodes list, however the way segments are stored only in the 38 * All ways (Streets etc.) in the DataSet. 39 * 40 * The nodes of the way segments of this way must be objects from 41 * the nodes list, however the way segments are stored only in the 41 42 * way list. 42 43 */ … … 49 50 50 51 /** 51 * @return A collection containing all primitives (except keys) of the 52 * dataset. 52 * @return A collection containing all primitives of the dataset. The 53 * data is ordered after: first comes nodes, then segments, then ways. 54 * Ordering in between the categories is not guaranteed. 53 55 */ 54 public Collection<OsmPrimitive> allPrimitives() {55 Collection<OsmPrimitive> o = new LinkedList<OsmPrimitive>();56 public List<OsmPrimitive> allPrimitives() { 57 List<OsmPrimitive> o = new LinkedList<OsmPrimitive>(); 56 58 o.addAll(nodes); 57 59 o.addAll(segments); … … 153 155 154 156 /** 155 * Remove a listener from the selection changed listener list. 157 * Remove a listener from the selection changed listener list. 156 158 * If <code>null</code> is passed, nothing happens. 157 159 * @param listener The listener to remove from the list. -
src/org/openstreetmap/josm/gui/MainMenu.java
r169 r175 29 29 * This is the JOSM main menu bar. It is overwritten to initialize itself and provide 30 30 * all menu entries as member variables (sort of collect them). 31 * 31 * 32 32 * It also provides possibilities to attach new menu entries (used by plugins). 33 * 33 * 34 34 * @author Immanuel.Scholz 35 35 */ … … 52 52 public final HelpAction help = new HelpAction(); 53 53 public final Action about = new AboutAction(); 54 54 55 55 public final JMenu layerMenu = new JMenu(tr("Layer")); 56 56 public final JMenu editMenu = new JMenu(tr("Edit")); … … 61 61 62 62 63 63 64 64 public MainMenu() { 65 65 fileMenu.setMnemonic('F'); -
src/org/openstreetmap/josm/gui/PleaseWaitRunnable.java
r153 r175 66 66 // show the dialog 67 67 closeDialogCalled = false; 68 EventQueue.invokeLater(new Runnable() { 69 public void run() { 70 Main.pleaseWaitDlg.setVisible(true); 71 } 72 }); 68 synchronized (this) { 69 EventQueue.invokeLater(new Runnable() { 70 public void run() { 71 synchronized (PleaseWaitRunnable.this) { 72 PleaseWaitRunnable.this.notifyAll(); 73 } 74 Main.pleaseWaitDlg.setVisible(true); 75 } 76 }); 77 try {wait();} catch (InterruptedException e) {} 78 } 79 73 80 74 81 realRun(); … … 119 126 } finally { 120 127 Main.pleaseWaitDlg.setVisible(false); 128 Main.pleaseWaitDlg.dispose(); 121 129 } 122 130 if (errorMessage != null) -
src/org/openstreetmap/josm/gui/preferences/PreferenceDialog.java
r172 r175 105 105 settings.add(new PluginPreference()); 106 106 settings.add(Main.toolbar); 107 107 108 108 for (PluginProxy plugin : Main.plugins) { 109 109 PreferenceSetting p = plugin.getPreferenceSetting(); -
src/org/openstreetmap/josm/io/BoundingBoxDownloader.java
r160 r175 37 37 */ 38 38 public Collection<Collection<GpsPoint>> parseRawGps() throws IOException, SAXException { 39 Main.pleaseWaitDlg.currentAction.setText(tr("Contacting OSM Server...")); 39 40 try { 40 41 String url = "trackpoints?bbox="+lon1+","+lat1+","+lon2+","+lat2+"&page="; … … 84 85 public DataSet parseOsm() throws SAXException, IOException { 85 86 try { 87 Main.pleaseWaitDlg.currentAction.setText(tr("Contacting OSM Server...")); 86 88 final InputStream in = getInputStream("map?bbox="+lon1+","+lat1+","+lon2+","+lat2, Main.pleaseWaitDlg); 87 89 if (in == null) 88 90 return null; 89 91 Main.pleaseWaitDlg.currentAction.setText(tr("Downloading OSM data...")); 90 final DataSet data = OsmReader.parseDataSet(in, Main.ds, Main.pleaseWaitDlg);92 final DataSet data = OsmReader.parseDataSet(in, null, Main.pleaseWaitDlg); 91 93 in.close(); 92 94 activeConnection = null; -
src/org/openstreetmap/josm/io/IncompleteDownloader.java
r160 r175 12 12 13 13 import org.openstreetmap.josm.Main; 14 import org.openstreetmap.josm.data.osm.DataSet; 14 15 import org.openstreetmap.josm.data.osm.Node; 15 16 import org.openstreetmap.josm.data.osm.Segment; … … 23 24 /** 24 25 * Capable of downloading ways without having to fully parse their segments. 25 * 26 * 26 27 * @author Imi 27 28 */ … … 29 30 30 31 /** 32 * The new downloaded data will be inserted here. 33 */ 34 public final DataSet data = new DataSet(); 35 36 /** 31 37 * The list of incomplete Ways to download. The ways will be filled and are complete after download. 32 38 */ 33 39 private final Collection<Way> toDownload; 34 private MergeVisitor merger = new MergeVisitor( Main.ds);35 40 private MergeVisitor merger = new MergeVisitor(data); 41 36 42 public IncompleteDownloader(Collection<Way> toDownload) { 37 43 this.toDownload = toDownload; … … 85 91 SegmentParser segmentParser = new SegmentParser(); 86 92 segmentParser.parse(new StringReader(segBuilder.toString())); 87 if (segmentParser.from == 0 || segmentParser.to == 0) { 88 System.out.println(segBuilder.toString()); 93 if (segmentParser.from == 0 || segmentParser.to == 0) 89 94 throw new SAXException("Invalid segment response."); 90 }91 95 if (!hasNode(segmentParser.from)) 92 96 readNode(segmentParser.from, s.id).visit(merger); … … 105 109 106 110 private Segment readSegment(String seg) throws SAXException, IOException { 107 return OsmReader.parseDataSet(new ByteArrayInputStream(seg.getBytes("UTF-8")), Main.ds, null).segments.iterator().next();111 return OsmReader.parseDataSet(new ByteArrayInputStream(seg.getBytes("UTF-8")), data, null).segments.iterator().next(); 108 112 } 109 113 110 114 private Node readNode(long id, long segId) throws SAXException, IOException { 111 115 try { 112 return OsmReader.parseDataSet(getInputStream("node/"+id, null), Main.ds, null).nodes.iterator().next();116 return OsmReader.parseDataSet(getInputStream("node/"+id, null), data, null).nodes.iterator().next(); 113 117 } catch (FileNotFoundException e) { 114 118 e.printStackTrace(); -
src/org/openstreetmap/josm/io/OsmReader.java
r169 r175 192 192 if (node.id == id) 193 193 return node; 194 for (Node node : Main.ds.nodes) 195 if (node.id == id) 196 return node; 194 197 return null; 195 198 } … … 200 203 return s; 201 204 for (Segment seg : references.segments) 205 if (seg.id == id) 206 return seg; 207 for (Segment seg : Main.ds.segments) 202 208 if (seg.id == id) 203 209 return seg; … … 228 234 /** 229 235 * Parse the given input source and return the dataset. 230 * @param pleaseWaitDlg TODO 236 * @param ref The dataset that is search in for references first. If 237 * the Reference is not found here, Main.ds is searched. 231 238 */ 232 239 public static DataSet parseDataSet(InputStream source, DataSet ref, PleaseWaitDialog pleaseWaitDlg) throws SAXException, IOException { 233 240 OsmReader osm = new OsmReader(); 234 osm.references = ref ;241 osm.references = ref == null ? new DataSet() : ref; 235 242 236 243 // phase 1: Parse nodes and read in raw segments and ways -
src/org/openstreetmap/josm/io/OsmServerReader.java
r160 r175 27 27 URL url = new URL(urlStr); 28 28 activeConnection = (HttpURLConnection)url.openConnection(); 29 if (cancel) { 30 activeConnection.disconnect(); 31 return null; 32 } 29 33 System.out.println("got return: "+activeConnection.getResponseCode()); 30 34 activeConnection.setConnectTimeout(15000);
Note:
See TracChangeset
for help on using the changeset viewer.