Changeset 2247 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2009-10-04T15:57:42+02:00 (15 years ago)
Author:
jttt
Message:

Fixed #2480

Location:
trunk/src/org/openstreetmap/josm/data/gpx
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/gpx/GpxData.java

    r2151 r2247  
    117117    public double length(){
    118118        double result = 0.0; // in meters
    119         WayPoint last = null;
    120119
    121         for (GpxTrack trk : tracks)
    122             result += trk.length();
     120        for (GpxTrack trk : tracks) {
     121            result += trk.length();
     122        }
    123123
    124124        return result;
  • trunk/src/org/openstreetmap/josm/data/gpx/GpxTrack.java

    r2151 r2247  
    55
    66import java.util.Collection;
    7 import java.util.LinkedList;
     7import java.util.concurrent.ConcurrentLinkedQueue;
    88
    99public class GpxTrack extends WithAttributes {
    10     public Collection<Collection<WayPoint>> trackSegs
    11         = new LinkedList<Collection<WayPoint>>();
     10    public final Collection<Collection<WayPoint>> trackSegs
     11    = new ConcurrentLinkedQueue<Collection<WayPoint>>();
    1212
    1313    /**
     
    1818        WayPoint last = null;
    1919
    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                 last = tpt;
    28             }
    29             last = null; // restart for each track segment
    30         }
     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        }
    3132        return result;
    3233    }
  • trunk/src/org/openstreetmap/josm/data/gpx/WayPoint.java

    r2017 r2247  
    4141     */
    4242    public void setTime() {
    43         for(String key : new String[]{"time", "cmt", "desc"})
     43        if(attr.containsKey("time"))
    4444        {
    45             if(attr.containsKey("time"))
    46             {
    47                 double t = DateUtils.fromString(attr.get("time").toString()).getTime();
    48                 if(t != 0.0)
    49                 {
    50                     time = t / 1000.0; /* ms => seconds */
    51                     break;
    52                 }
     45            double t = DateUtils.fromString(attr.get("time").toString()).getTime();
     46            if(t != 0.0) {
     47                time = t / 1000.0; /* ms => seconds */
    5348            }
    5449        }
Note: See TracChangeset for help on using the changeset viewer.