Changeset 6160 in osm for applications/editors/josm/plugins/livegps
- Timestamp:
- 2007-12-26T23:44:14+01:00 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/livegps/livegps/LiveGpsLayer.java
r3835 r6160 13 13 import org.openstreetmap.josm.Main; 14 14 import org.openstreetmap.josm.data.coor.LatLon; 15 import org.openstreetmap.josm.data.gpx.GpxData; 16 import org.openstreetmap.josm.data.gpx.GpxTrack; 17 import org.openstreetmap.josm.data.gpx.WayPoint; 15 18 import org.openstreetmap.josm.gui.MapView; 19 import org.openstreetmap.josm.gui.layer.GpxLayer; 16 20 import org.openstreetmap.josm.gui.layer.RawGpsLayer; 17 21 import org.openstreetmap.josm.tools.ColorHelper; 18 22 19 public class LiveGpsLayer extends RawGpsLayer implements PropertyChangeListener {23 public class LiveGpsLayer extends GpxLayer implements PropertyChangeListener { 20 24 public static final String LAYER_NAME = "LiveGPS layer"; 21 25 public static final String KEY_LIVEGPS_COLOR ="color.livegps.position"; 22 26 LatLon lastPos; 23 GpsPoint lastPoint; 24 Collection<GpsPoint> trackBeingWritten; 27 WayPoint lastPoint; 28 GpxTrack trackBeingWritten; 29 Collection<WayPoint> trackSegment; 25 30 float speed; 26 31 float course; … … 30 35 private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS"); 31 36 32 public LiveGpsLayer( Collection<Collection<GpsPoint>>data)37 public LiveGpsLayer(GpxData data) 33 38 { 34 super (false, data, LAYER_NAME, null); 35 if (data.isEmpty()) 36 { 37 data.add(new ArrayList<GpsPoint>()); 38 } 39 // use last track in collection: 40 for (Collection<GpsPoint> track : data) { 41 trackBeingWritten = track; 42 } 43 //lbl = new JLabel(); 39 super (data, LAYER_NAME); 40 trackBeingWritten = new GpxTrack(); 41 trackBeingWritten.attr.put("desc", "josm live gps"); 42 trackSegment = new ArrayList<WayPoint>(); 43 trackBeingWritten.trackSegs.add(trackSegment); 44 data.tracks.add(trackBeingWritten); 44 45 } 45 46 … … 55 56 56 57 lastPos = thisPos; 57 lastPoint = new GpsPoint (thisPos, dateFormat.format(new Date())); 58 lastPoint = new WayPoint(thisPos); 59 lastPoint.attr.put("time", dateFormat.format(new Date())); 58 60 // synchronize when adding data, as otherwise the autosave action 59 61 // needs concurrent access and this results in an exception! 60 62 synchronized (LiveGpsLock.class) { 61 track BeingWritten.add(lastPoint);63 trackSegment.add(lastPoint); 62 64 } 63 65 if (autocenter) {
Note:
See TracChangeset
for help on using the changeset viewer.