Changeset 16585 in osm for applications/editors/josm/plugins/globalsat
- Timestamp:
- 2009-07-19T18:52:06+02:00 (16 years ago)
- Location:
- applications/editors/josm/plugins/globalsat
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/globalsat/build.xml
r14015 r16585 32 32 <attribute name="Plugin-Description" value="Download GPS points from Globalsat dg100 data logger directly in JOSM."/> 33 33 <attribute name="Plugin-Link" value="http://www.raphael-mack.de/josm-globalsat-gpx-import-plugin/"/> 34 <attribute name="Plugin-Mainversion" value="1 465"/>34 <attribute name="Plugin-Mainversion" value="1813"/> 35 35 <attribute name="Plugin-Version" value="${version.entry.commit.revision}"/> 36 36 </manifest> -
applications/editors/josm/plugins/globalsat/src/org/openstreetmap/josm/plugins/globalsat/GlobalsatDg100.java
r13497 r16585 6 6 package org.openstreetmap.josm.plugins.globalsat; 7 7 8 import java.util.*; 9 import java.util.logging.*; 10 import java.io.FileOutputStream; 11 import java.io.OutputStream; 8 import gnu.io.CommPortIdentifier; 9 import gnu.io.PortInUseException; 10 import gnu.io.SerialPort; 11 import gnu.io.UnsupportedCommOperationException; 12 12 13 import java.io.IOException; 13 14 import java.io.InputStream; 15 import java.io.OutputStream; 14 16 import java.nio.ByteBuffer; 15 import java. lang.Exception;16 17 import gnu.io.*;18 19 import org.kaintoch.gps.globalsat.dg100. Response;17 import java.util.ArrayList; 18 import java.util.Collection; 19 import java.util.List; 20 21 import org.kaintoch.gps.globalsat.dg100.ByteHelper; 20 22 import org.kaintoch.gps.globalsat.dg100.Dg100Config; 21 23 import org.kaintoch.gps.globalsat.dg100.FileInfoRec; 22 24 import org.kaintoch.gps.globalsat.dg100.GpsRec; 23 import org.kaintoch.gps.globalsat.dg100.ByteHelper; 24 25 import org.openstreetmap.josm.Main; 25 import org.kaintoch.gps.globalsat.dg100.Response; 26 import org.openstreetmap.josm.data.coor.LatLon; 26 27 import org.openstreetmap.josm.data.gpx.GpxData; 27 28 import org.openstreetmap.josm.data.gpx.GpxTrack; 28 29 import org.openstreetmap.josm.data.gpx.WayPoint; 29 import org.openstreetmap.josm. data.coor.LatLon;30 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 30 31 31 32 /** … … 132 133 * @param port DG-100 is connected to port. 133 134 */ 134 public GpxData readData() throws ConnectionException { 135 GpxData result = null; 136 int cnt = 0; 137 cancelled = false; 138 if(port == null){ 139 connect(); 140 } 141 Main.pleaseWaitDlg.progress.setValue(0); 142 143 List<FileInfoRec> fileInfoList = readFileInfoList(); 144 List<GpsRec> gpsRecList = readGpsRecList(fileInfoList); 145 146 Main.pleaseWaitDlg.progress.setMaximum(gpsRecList.size()); 147 if(gpsRecList.size() > 0){ 148 GpsRec last = null; 149 GpxTrack trk = new GpxTrack(); 150 Collection<WayPoint> seg = new ArrayList<WayPoint>(100); 151 result = new GpxData(); 152 result.tracks.add(trk); 153 trk.trackSegs.add(seg); 154 for(GpsRec r:gpsRecList){ 155 if(cancelled){ 156 return result; 157 } 158 WayPoint p = wayPointFrom(r); 159 if(r.equals(last)){ 160 result.waypoints.add(p); 161 }else{ 162 seg.add(p); 163 } 164 last = r; 165 Main.pleaseWaitDlg.progress.setValue(cnt++); 166 } 167 } 168 return result; 135 public GpxData readData(ProgressMonitor progressMonitor) throws ConnectionException { 136 progressMonitor.beginTask(null); 137 try { 138 GpxData result = null; 139 cancelled = false; 140 if(port == null){ 141 connect(); 142 } 143 144 List<FileInfoRec> fileInfoList = readFileInfoList(); 145 List<GpsRec> gpsRecList = readGpsRecList(fileInfoList); 146 147 progressMonitor.setTicksCount(gpsRecList.size()); 148 if(gpsRecList.size() > 0){ 149 GpsRec last = null; 150 GpxTrack trk = new GpxTrack(); 151 Collection<WayPoint> seg = new ArrayList<WayPoint>(100); 152 result = new GpxData(); 153 result.tracks.add(trk); 154 trk.trackSegs.add(seg); 155 for(GpsRec r:gpsRecList){ 156 if(cancelled){ 157 return result; 158 } 159 WayPoint p = wayPointFrom(r); 160 if(r.equals(last)){ 161 result.waypoints.add(p); 162 }else{ 163 seg.add(p); 164 } 165 last = r; 166 progressMonitor.worked(1); 167 } 168 } 169 return result; 170 } finally { 171 progressMonitor.finishTask(); 172 } 169 173 } 170 174 -
applications/editors/josm/plugins/globalsat/src/org/openstreetmap/josm/plugins/globalsat/GlobalsatPlugin.java
r13497 r16585 2 2 /// @author Raphael Mack <ramack@raphael-mack.de> 3 3 import static org.openstreetmap.josm.tools.I18n.tr; 4 import gnu.io.CommPortIdentifier; 4 5 5 import java.io.IOException;6 import org.xml.sax.SAXException;7 8 import java.util.Enumeration;9 6 import java.awt.event.ActionEvent; 10 7 import java.awt.event.KeyEvent; 8 import java.io.IOException; 9 import java.util.Enumeration; 11 10 12 11 import javax.swing.JDialog; 13 12 import javax.swing.JOptionPane; 14 import javax.swing.JPanel;15 13 16 14 import org.openstreetmap.josm.Main; 17 import org.openstreetmap.josm.gui.IconToggleButton;18 import org.openstreetmap.josm.gui.MapFrame;19 import org.openstreetmap.josm.gui.layer.Layer;20 import org.openstreetmap.josm.gui.layer.GpxLayer;21 import org.openstreetmap.josm.gui.PleaseWaitRunnable;22 import org.openstreetmap.josm.plugins.Plugin;23 15 import org.openstreetmap.josm.actions.JosmAction; 24 16 import org.openstreetmap.josm.data.gpx.GpxData; 17 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 18 import org.openstreetmap.josm.gui.layer.GpxLayer; 19 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 20 import org.openstreetmap.josm.plugins.Plugin; 25 21 import org.openstreetmap.josm.tools.Shortcut; 26 27 import gnu.io.*; 22 import org.xml.sax.SAXException; 28 23 29 24 public class GlobalsatPlugin extends Plugin { … … 51 46 52 47 @Override public void realRun() throws IOException, SAXException { 53 Main.pleaseWaitDlg.progress.setValue(0); 54 Main.pleaseWaitDlg.currentAction.setText(tr("Importing data from DG100...")); 48 progressMonitor.subTask(tr("Importing data from DG100...")); 55 49 try{ 56 data = GlobalsatPlugin.dg100().readData(); 50 data = GlobalsatPlugin.dg100().readData(progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, true)); 57 51 }catch(Exception e){ 58 52 eee = e;
Note:
See TracChangeset
for help on using the changeset viewer.