Changeset 13499 in osm for applications/editors/josm/plugins/tcxplugin
- Timestamp:
- 2009-02-01T22:18:44+01:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/tcxplugin/src/org/openstreetmap/josm/io/TcxReader.java
r13497 r13499 10 10 import javax.xml.bind.JAXBException; 11 11 import javax.xml.bind.Unmarshaller; 12 import javax.xml.datatype.XMLGregorianCalendar; 12 13 13 14 import org.openstreetmap.josm.data.coor.LatLon; … … 18 19 import org.openstreetmap.josm.io.tcx.ActivityT; 19 20 import org.openstreetmap.josm.io.tcx.CourseT; 21 import org.openstreetmap.josm.io.tcx.PositionT; 20 22 import org.openstreetmap.josm.io.tcx.TrackT; 21 23 import org.openstreetmap.josm.io.tcx.TrackpointT; … … 86 88 } 87 89 90 /** Convert a TrackpointT to a WayPoint. 91 * @param tp TrackpointT to convert 92 * @return tp converted to WayPoint, or null 93 */ 94 private static WayPoint convertPoint(TrackpointT tp) { 95 96 PositionT p = tp.getPosition(); 97 98 if (p == null) { 99 // If the TrackPointT lacks a position, return null. 100 return null; 101 } 102 103 WayPoint waypt = new WayPoint(new LatLon(p.getLatitudeDegrees(), 104 p.getLongitudeDegrees())); 105 // If WayPoint handled elevation data, we could get it from 106 // tp.getAltitudeMeters(). 107 108 XMLGregorianCalendar time = tp.getTime(); 109 110 if (time != null) { 111 waypt.time = .001 * time.toGregorianCalendar().getTimeInMillis(); 112 } 113 114 return waypt; 115 } 116 88 117 /** 89 118 * @param tcd … … 102 131 Collection<WayPoint> currentTrackSeg = new ArrayList<WayPoint>(); 103 132 currentTrack.trackSegs.add(currentTrackSeg); 104 for (TrackpointT trackpoint : track 105 .getTrackpoint()) { 106 // Some trackspoints don't have a 107 // position. 108 // Check it 109 // first to avoid an NPE! 110 if (trackpoint.getPosition() != null) { 111 LatLon latLon = new LatLon( 112 trackpoint 113 .getPosition() 114 .getLatitudeDegrees(), 115 trackpoint 116 .getPosition() 117 .getLongitudeDegrees()); 118 WayPoint currentWayPoint = new WayPoint( 119 latLon); 120 // We usually have altitude info 121 // here 122 // (trackpoint.getAltitudeMeters()) 123 // Don't know how to add it to 124 // the GPX 125 // Data... 126 currentTrackSeg 127 .add(currentWayPoint); 133 for (TrackpointT tp : 134 track.getTrackpoint()) { 135 WayPoint waypt = convertPoint(tp); 136 137 if (waypt != null) { 138 currentTrackSeg.add(waypt); 128 139 } 129 140 } … … 151 162 Collection<WayPoint> currentTrackSeg = new ArrayList<WayPoint>(); 152 163 currentTrack.trackSegs.add(currentTrackSeg); 153 for (TrackpointT trackpoint : track.getTrackpoint()) { 154 // Some trackspoints don't have a position. 155 // Check it 156 // first to avoid an NPE! 157 if (trackpoint.getPosition() != null) { 158 LatLon latLon = new LatLon( 159 trackpoint.getPosition() 160 .getLatitudeDegrees(), 161 trackpoint.getPosition() 162 .getLongitudeDegrees()); 163 WayPoint currentWayPoint = new WayPoint( 164 latLon); 165 // We usually have altitude info here 166 // (trackpoint.getAltitudeMeters()) 167 // Don't know how to add it to the GPX 168 // Data... 169 currentTrackSeg.add(currentWayPoint); 164 for (TrackpointT tp : track.getTrackpoint()) { 165 WayPoint waypt = convertPoint(tp); 166 167 if (waypt != null) { 168 currentTrackSeg.add(waypt); 170 169 } 171 170 }
Note:
See TracChangeset
for help on using the changeset viewer.