Changeset 16933 in osm for applications/editors/josm/plugins/livegps/src
- Timestamp:
- 2009-08-09T13:32:56+02:00 (15 years ago)
- Location:
- applications/editors/josm/plugins/livegps/src/livegps
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/livegps/src/livegps/LiveGpsAcquirer.java
r14057 r16933 16 16 17 17 import org.openstreetmap.josm.data.coor.LatLon; 18 import org.openstreetmap.josm.Main; 18 19 19 20 public class LiveGpsAcquirer implements Runnable { … … 21 22 BufferedReader gpsdReader; 22 23 boolean connected = false; 23 String gpsdHost = "localhost"; 24 int gpsdPort = 2947; 25 String configFile = "liveGPS.conf"; 24 String gpsdHost = Main.pref.get("livegps.gpsd.host","localhost"); 25 int gpsdPort = Main.pref.getInteger("livegps.gpsd.port", 2947); 26 26 boolean shutdownFlag = false; 27 27 private List<PropertyChangeListener> propertyChangeListener = new ArrayList<PropertyChangeListener>(); 28 28 private PropertyChangeEvent lastStatusEvent; 29 29 private PropertyChangeEvent lastDataEvent; 30 31 public LiveGpsAcquirer(String pluginDir) {32 33 Properties liveGPSconfig = new Properties();34 35 FileInputStream fis = null;36 37 try {38 fis = new FileInputStream(pluginDir + configFile);39 } catch (FileNotFoundException e) {40 System.err.println("No liveGPS.conf found, using defaults");41 }42 43 if(fis != null)44 {45 try {46 liveGPSconfig.load(fis);47 this.gpsdHost = liveGPSconfig.getProperty("host");48 this.gpsdPort = Integer.parseInt(liveGPSconfig.getProperty("port"));49 50 } catch (IOException e) {51 System.err.println("Error while loading liveGPS.conf, using defaults");52 }53 54 if(this.gpsdHost == null || this.gpsdPort == 0)55 {56 System.err.println("Error in liveGPS.conf, using defaults");57 this.gpsdHost = "localhost";58 this.gpsdPort = 2947;59 }60 }61 62 }63 30 64 31 /** … … 230 197 } 231 198 232 fireGpsStatusChangeEvent(LiveGpsStatus.GpsStatus.DISCONNECTED, tr("Not connected")); 199 fireGpsStatusChangeEvent(LiveGpsStatus.GpsStatus.DISCONNECTED, tr("Not connected")); 233 200 if (gpsdSocket != null) { 234 try { 235 gpsdSocket.close(); 236 gpsdSocket = null; 237 System.out.println("LiveGps: Disconnected from gpsd"); 238 } 239 catch (Exception e) { 240 System.out.println("LiveGps: Unable to close socket; reconnection may not be possible"); 241 };242 } 243 } 201 try { 202 gpsdSocket.close(); 203 gpsdSocket = null; 204 System.out.println("LiveGps: Disconnected from gpsd"); 205 } 206 catch (Exception e) { 207 System.out.println("LiveGps: Unable to close socket; reconnection may not be possible"); 208 } 209 } 210 } 244 211 245 212 public void shutdown() -
applications/editors/josm/plugins/livegps/src/livegps/LiveGpsData.java
r14057 r16933 3 3 */ 4 4 package livegps; 5 6 import static org.openstreetmap.josm.tools.I18n.tr; 5 7 6 8 import java.awt.Point; … … 109 111 return getClass().getSimpleName() + "[fix=" + fix + ", lat=" + latLon.lat() 110 112 + ", long=" + latLon.lon() + ", speed=" + speed + ", course=" + course + "]"; 111 112 113 } 113 114 … … 127 128 builder.append(tmp); 128 129 } else { 129 builder.append("no name"); 130 builder.append(tr("no name")); 130 131 } 131 132 tmp = way.get("ref"); … … 163 164 public Way getWay() { 164 165 if(way == null) { 165 EastNorth eastnorth = Main.proj.latlon2eastNorth(getLatLon()); 166 Point xy = Main.map.mapView.getPoint(eastnorth); 166 Point xy = Main.map.mapView.getPoint(getLatLon()); 167 167 way = Main.map.mapView.getNearestWay(xy); 168 168 } 169 169 return way; 170 171 170 } 172 171 … … 206 205 return true; 207 206 } 208 209 210 211 207 } -
applications/editors/josm/plugins/livegps/src/livegps/LiveGpsDialog.java
r14057 r16933 84 84 wayLabel.setText(wayString); 85 85 } else { 86 wayLabel.setText("unknown"); 86 wayLabel.setText(tr("unknown")); 87 87 } 88 88 -
applications/editors/josm/plugins/livegps/src/livegps/LiveGpsPlugin.java
r14120 r16933 131 131 { 132 132 if (acquirer == null) { 133 acquirer = new LiveGpsAcquirer( getPluginDir());133 acquirer = new LiveGpsAcquirer(); 134 134 if (lgpslayer == null) { 135 135 lgpslayer = new LiveGpsLayer(data);
Note:
See TracChangeset
for help on using the changeset viewer.