Changeset 26542 in osm
- Timestamp:
- 2011-08-14T19:53:04+02:00 (13 years ago)
- Location:
- applications/editors/josm/plugins/livegps/src/livegps
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/livegps/src/livegps/LiveGpsAcquirer.java
r25833 r26542 265 265 float speed = 0; 266 266 float course = 0; 267 float epx = 0; 268 float epy = 0; 267 269 268 270 try { … … 281 283 speed = (new Float(report.getDouble("speed"))).floatValue(); 282 284 course = (new Float(report.getDouble("track"))).floatValue(); 283 284 return new LiveGpsData(lat, lon, course, speed, true); 285 epx = (new Float(report.getDouble("epx"))).floatValue(); 286 epy = (new Float(report.getDouble("epy"))).floatValue(); 287 288 return new LiveGpsData(lat, lon, course, speed, epx, epy); 285 289 } catch (JSONException je) {} 286 290 … … 318 322 course = Float.parseFloat(status[8]); 319 323 } catch (NumberFormatException nex) {} 320 return new LiveGpsData(lat, lon, course, speed , true);324 return new LiveGpsData(lat, lon, course, speed); 321 325 } 322 326 break; … … 329 333 speed = Float.NaN; 330 334 course = Float.NaN; 331 return new LiveGpsData(lat, lon, course, speed , true);335 return new LiveGpsData(lat, lon, course, speed); 332 336 } 333 337 break; -
applications/editors/josm/plugins/livegps/src/livegps/LiveGpsData.java
r26218 r26542 18 18 */ 19 19 public class LiveGpsData { 20 private boolean fix; 20 21 private LatLon latLon; 21 22 private float course; 22 23 private float speed; 23 private boolean fix;24 private float epx, epy; 24 25 private String wayString; 25 26 private Way way; … … 32 33 * @param haveFix 33 34 */ 34 public LiveGpsData(double latitude, double longitude, float course, float speed , boolean haveFix) {35 public LiveGpsData(double latitude, double longitude, float course, float speed) { 35 36 super(); 37 this.fix = true; 36 38 this.latLon = new LatLon(latitude, longitude); 37 39 this.course = course; 38 40 this.speed = speed; 39 this.fix = haveFix; 40 } 41 /** 42 * 43 */ 44 public LiveGpsData() { 45 // TODO Auto-generated constructor stub 46 } 41 } 42 /** 43 * @param latitude 44 * @param longitude 45 * @param course 46 * @param speed 47 * @param haveFix 48 * @param epx 49 * @param epy 50 */ 51 public LiveGpsData(double latitude, double longitude, float course, float speed, float epx, float epy) { 52 super(); 53 this.fix = true; 54 this.latLon = new LatLon(latitude, longitude); 55 this.course = course; 56 this.speed = speed; 57 this.epx = epx; 58 this.epy = epy; 59 } 60 47 61 /** 48 62 * @return the course … … 106 120 public void setLatLon(LatLon latLon) { 107 121 this.latLon = latLon; 122 } 123 124 public void setEpy(float epy) { 125 this.epy = epy; 126 } 127 128 public void setEpx(float epx) { 129 this.epx = epx; 130 } 131 132 public float getEpy() { 133 return this.epy; 134 } 135 136 public float getEpx() { 137 return this.epx; 108 138 } 109 139 -
applications/editors/josm/plugins/livegps/src/livegps/LiveGpsLayer.java
r26541 r26542 26 26 public class LiveGpsLayer extends GpxLayer implements PropertyChangeListener { 27 27 public static final String LAYER_NAME = tr("LiveGPS layer"); 28 public static final String KEY_LIVEGPS_COLOR = "color.livegps.position"; 28 public static final String C_LIVEGPS_COLOR_POSITION = "color.livegps.position"; 29 public static final String C_LIVEGPS_COLOR_POSITION_ESTIMATE = "color.livegps.position_estimate"; 29 30 30 31 private static final int DEFAULT_REFRESH_INTERVAL = 250; … … 43 44 private long lastCenter = 0; 44 45 46 LiveGpsData lastData; 45 47 LatLon lastPos; 46 48 WayPoint lastPoint; 47 49 private final AppendableGpxTrackSegment trackSegment; 48 float speed;49 float course;50 50 boolean autocenter; 51 51 private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS"); … … 99 99 } 100 100 101 // void setStatus(String status)102 // {103 // this.status = status;104 // Main.map.repaint();105 // System.out.println("LiveGps status: " + status);106 // }107 108 void setSpeed(float metresPerSecond) {109 speed = metresPerSecond;110 }111 112 void setCourse(float degrees) {113 course = degrees;114 }115 116 101 public void setAutoCenter(boolean ac) { 117 102 autocenter = ac; … … 126 111 127 112 Point screen = mv.getPoint(lastPoint.getCoor()); 128 g.setColor(Main.pref.getColor( KEY_LIVEGPS_COLOR, Color.RED));113 g.setColor(Main.pref.getColor(C_LIVEGPS_COLOR_POSITION, Color.RED)); 129 114 130 115 int TriaHeight = Main.pref.getInteger(C_CURSOR_H, 20); … … 133 118 int[] x = new int[4]; 134 119 int[] y = new int[4]; 120 float course = lastData.getCourse(); 135 121 136 122 x[0] = screen.x + Math.round(TriaHeight * (float )Math.sin(Math.toRadians(course))); … … 144 130 145 131 g.drawPolygon(x, y, 4); 132 133 g.setColor(Main.pref.getColor(C_LIVEGPS_COLOR_POSITION_ESTIMATE, Color.CYAN)); 134 135 int w, h; 136 double ppm = 100 / mv.getDist100Pixel(); /* pixels per metre */ 137 138 w = (int )Math.round(lastData.getEpx() * ppm); 139 h = (int )Math.round(lastData.getEpy() * ppm); 140 141 if (w > TriaWidth || h > TriaWidth) { 142 int xo, yo; 143 144 yo = screen.y - Math.round(h/2); 145 xo = screen.x - Math.round(w/2); 146 147 g.drawOval(xo, yo, w, h); 148 } 146 149 } 147 150 … … 154 157 } 155 158 if ("gpsdata".equals(evt.getPropertyName())) { 156 LiveGpsData data = (LiveGpsData) evt.getNewValue(); 157 if (data.isFix()) { 158 setCurrentPosition(data.getLatitude(), data.getLongitude()); 159 if (!Float.isNaN(data.getSpeed())) { 160 setSpeed(data.getSpeed()); 161 } 162 if (!Float.isNaN(data.getCourse())) { 163 setCourse(data.getCourse()); 164 } 159 lastData = (LiveGpsData) evt.getNewValue(); 160 if (lastData.isFix()) { 161 setCurrentPosition(lastData.getLatitude(), lastData.getLongitude()); 165 162 if (allowRedraw()) 166 163 Main.map.repaint();
Note:
See TracChangeset
for help on using the changeset viewer.