Changeset 2907 in josm for trunk/src/org/openstreetmap/josm/data/gpx
- Timestamp:
- 2010-01-30T20:04:10+01:00 (14 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data/gpx
- Files:
-
- 4 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/gpx/GpxData.java
r2795 r2907 63 63 public boolean hasTrackPoints() { 64 64 for (GpxTrack trk : tracks) { 65 for ( Collection<WayPoint> trkseg : trk.trackSegs) {66 if (!trkseg. isEmpty())65 for (GpxTrackSegment trkseg : trk.getSegments()) { 66 if (!trkseg.getWayPoints().isEmpty()) 67 67 return true; 68 68 } … … 103 103 } 104 104 for (GpxTrack trk : tracks) { 105 for (Collection<WayPoint> trkseg : trk.trackSegs) { 106 for (WayPoint wpt : trkseg) { 107 if (bounds == null) { 108 bounds = new Bounds(wpt.getCoor()); 109 } else { 110 bounds.extend(wpt.getCoor()); 111 } 105 Bounds trkBounds = trk.getBounds(); 106 if (trkBounds != null) { 107 if (bounds == null) { 108 bounds = new Bounds(trkBounds); 109 } else { 110 bounds.extend(trkBounds); 112 111 } 113 112 } -
trunk/src/org/openstreetmap/josm/data/gpx/GpxTrack.java
r2247 r2907 5 5 6 6 import java.util.Collection; 7 import java.util. concurrent.ConcurrentLinkedQueue;7 import java.util.Map; 8 8 9 public class GpxTrack extends WithAttributes { 10 public final Collection<Collection<WayPoint>> trackSegs 11 = new ConcurrentLinkedQueue<Collection<WayPoint>>(); 9 import org.openstreetmap.josm.data.Bounds; 12 10 13 /**14 * calculates the length of the track15 */16 public double length(){17 double result = 0.0; // in meters18 WayPoint last = null;19 11 20 for (Collection<WayPoint> trkseg : trackSegs) { 21 for (WayPoint tpt : trkseg) { 22 if(last != null){ 23 Double d = last.getCoor().greatCircleDistance(tpt.getCoor()); 24 if(!d.isNaN() && !d.isInfinite()) { 25 result += d; 26 } 27 } 28 last = tpt; 29 } 30 last = null; // restart for each track segment 31 } 32 return result; 33 } 12 /** 13 * Read-only gpx track. Implementations doesn't have to be immutable, but should always be thread safe. 14 * 15 */ 16 17 public interface GpxTrack { 18 19 Collection<GpxTrackSegment> getSegments(); 20 Map<String, Object> getAttributes(); 21 Bounds getBounds(); 22 double length(); 23 34 24 } -
trunk/src/org/openstreetmap/josm/data/gpx/WayPoint.java
r2874 r2907 10 10 import org.openstreetmap.josm.data.coor.EastNorth; 11 11 import org.openstreetmap.josm.data.coor.LatLon; 12 import org.openstreetmap.josm.tools.DateUtils;13 12 import org.openstreetmap.josm.tools.PrimaryDateParser; 14 13 … … 20 19 public int dir; 21 20 22 private CachedLatLon coor;21 private final CachedLatLon coor; 23 22 24 23 public final LatLon getCoor() {
Note:
See TracChangeset
for help on using the changeset viewer.