Changeset 14456 in josm for trunk/src


Ignore:
Timestamp:
2018-11-27T21:40:10+01:00 (5 years ago)
Author:
Don-vip
Message:

fix #16995 - de-duplicate storage of timestamp within WayPoint and refactor some methods, added documentation, added some robustness against legacy code (will also log a warning if detected). Patch by cmuelle8, modified

Location:
trunk/src/org/openstreetmap/josm
Files:
12 edited

Legend:

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

    r14451 r14456  
    99import java.util.Collections;
    1010import java.util.Date;
    11 import java.util.DoubleSummaryStatistics;
    1211import java.util.HashMap;
    1312import java.util.HashSet;
    1413import java.util.Iterator;
    1514import java.util.List;
     15import java.util.LongSummaryStatistics;
    1616import java.util.Map;
    1717import java.util.NoSuchElementException;
     
    175175                Date prevWpTime = null;
    176176                for (WayPoint wp : wpsOld) {
    177                     Date wpTime = wp.setTimeFromAttribute();
     177                    Date wpTime = wp.getDate();
    178178                    boolean overlap = false;
    179179                    if (wpTime != null) {
     
    267267
    268268        GpxTrackSegmentSpan(WayPoint a, WayPoint b) {
    269             Date at = a.getTime();
    270             Date bt = b.getTime();
     269            Date at = a.getDate();
     270            Date bt = b.getDate();
    271271            inv = bt.before(at);
    272272            if (inv) {
     
    324324            List<WayPoint> wps = new ArrayList<>(seg.getWayPoints());
    325325            for (int i = forward ? 0 : wps.size() - 1; i >= 0 && i < wps.size(); i += forward ? 1 : -1) {
    326                 if (wps.get(i).setTimeFromAttribute() != null) {
     326                if (wps.get(i).hasDate()) {
    327327                    return wps.get(i);
    328328                }
     
    691691     */
    692692    public static Date[] getMinMaxTimeForTrack(GpxTrack trk) {
    693         final DoubleSummaryStatistics statistics = trk.getSegments().stream()
     693        final LongSummaryStatistics statistics = trk.getSegments().stream()
    694694                .flatMap(seg -> seg.getWayPoints().stream())
    695                 .mapToDouble(pnt -> pnt.time)
     695                .mapToLong(pnt -> pnt.getTimeInMillis())
    696696                .summaryStatistics();
    697697        return statistics.getCount() == 0
    698698                ? null
    699                 : new Date[]{new Date((long) (statistics.getMin() * 1000)), new Date((long) (statistics.getMax() * 1000))};
     699                : new Date[]{new Date(statistics.getMin()), new Date(statistics.getMax())};
    700700    }
    701701
     
    708708    */
    709709    public synchronized Date[] getMinMaxTimeForAllTracks() {
    710         double now = System.currentTimeMillis() / 1000.0;
    711         final DoubleSummaryStatistics statistics = tracks.stream()
     710        long now = System.currentTimeMillis();
     711        final LongSummaryStatistics statistics = tracks.stream()
    712712                .flatMap(trk -> trk.getSegments().stream())
    713713                .flatMap(seg -> seg.getWayPoints().stream())
    714                 .mapToDouble(pnt -> pnt.time)
     714                .mapToLong(pnt -> pnt.getTimeInMillis())
    715715                .filter(t -> t > 0 && t <= now)
    716716                .summaryStatistics();
    717717        return statistics.getCount() == 0
    718718                ? new Date[0]
    719                 : new Date[]{new Date((long) (statistics.getMin() * 1000)), new Date((long) (statistics.getMax() * 1000))};
     719                : new Date[]{new Date(statistics.getMin()), new Date(statistics.getMax())};
    720720    }
    721721
     
    755755        double pnminsq = tolerance * tolerance;
    756756        EastNorth bestEN = null;
    757         double bestTime = 0.0;
     757        double bestTime = Double.NaN;
    758758        double px = p.east();
    759759        double py = p.north();
     
    774774                            pnminsq = pRsq;
    775775                            bestEN = en;
    776                             bestTime = r.time;
     776                            if (r.hasDate()) {
     777                                bestTime = r.getTime();
     778                            }
    777779                        }
    778780                    } else {
     
    800802                                double ny = ry + rnoverRS * a;
    801803                                bestEN = new EastNorth(nx, ny);
    802                                 bestTime = r.time + rnoverRS * (wpSeg.time - r.time);
     804                                if (r.hasDate() && wpSeg.hasDate()) {
     805                                    bestTime = r.getTime() + rnoverRS * (wpSeg.getTime() - r.getTime());
     806                                }
    803807                                pnminsq = pnsq;
    804808                            }
     
    820824                        pnminsq = prsq;
    821825                        bestEN = c;
    822                         bestTime = r.time;
     826                        if (r.hasDate()) {
     827                            bestTime = r.getTime();
     828                        }
    823829                    }
    824830                }
     
    828834            return null;
    829835        WayPoint best = new WayPoint(ProjectionRegistry.getProjection().eastNorth2latlon(bestEN));
    830         best.time = bestTime;
     836        if (!Double.isNaN(bestTime)) {
     837            best.setTimeInMillis((long) (bestTime * 1000));
     838        }
    831839        return best;
    832840    }
  • trunk/src/org/openstreetmap/josm/data/gpx/GpxImageCorrelation.java

    r14211 r14456  
    4646                    int wp;
    4747                    for (wp = 0; wp < wps.size(); wp++) {
    48                         if (wps.get(wp).setTimeFromAttribute() != null) {
     48                        if (wps.get(wp).hasDate()) {
    4949                            break;
    5050                        }
     
    6262                    if (o1.isEmpty() || o2.isEmpty())
    6363                        return 0;
    64                     return Double.compare(o1.get(0).time, o2.get(0).time);
     64                    return o1.get(0).compareTo(o2.get(0));
    6565                });
    6666                trks.add(segs);
     
    7272             || o2.isEmpty() || o2.get(0).isEmpty())
    7373                return 0;
    74             return Double.compare(o1.get(0).get(0).time, o2.get(0).get(0).time);
     74            return o1.get(0).get(0).compareTo(o2.get(0).get(0));
    7575        });
    7676
     
    111111                for (int i = 0; i < wps.size(); i++) {
    112112                    WayPoint curWp = wps.get(i);
    113                     Date parsedTime = curWp.setTimeFromAttribute();
    114113                    // Interpolate timestamps in the segment, if one or more waypoints miss them
    115                     if (parsedTime == null) {
     114                    if (!curWp.hasDate()) {
    116115                        //check if any of the following waypoints has a timestamp...
    117                         if (i > 0 && wps.get(i - 1).time != 0) {
    118                             long prevWpTimeNoOffset = wps.get(i - 1).getTime().getTime();
     116                        if (i > 0 && wps.get(i - 1).hasDate()) {
     117                            long prevWpTimeNoOffset = wps.get(i - 1).getTimeInMillis();
    119118                            double totalDist = 0;
    120119                            List<Pair<Double, WayPoint>> nextWps = new ArrayList<>();
     
    122121                                totalDist += wps.get(j - 1).getCoor().greatCircleDistance(wps.get(j).getCoor());
    123122                                nextWps.add(new Pair<>(totalDist, wps.get(j)));
    124                                 final Date nextTime = wps.get(j).setTimeFromAttribute();
    125                                 if (nextTime != null) {
     123                                if (wps.get(j).hasDate()) {
    126124                                    // ...if yes, interpolate everything in between
    127                                     long timeDiff = nextTime.getTime() - prevWpTimeNoOffset;
     125                                    long timeDiff = wps.get(j).getTimeInMillis() - prevWpTimeNoOffset;
    128126                                    for (Pair<Double, WayPoint> pair : nextWps) {
    129                                         pair.b.setTime(new Date((long) (prevWpTimeNoOffset + (timeDiff * (pair.a / totalDist)))));
     127                                        pair.b.setTimeInMillis((long) (prevWpTimeNoOffset + (timeDiff * (pair.a / totalDist))));
    130128                                    }
    131129                                    break;
    132130                                }
    133131                            }
    134                             parsedTime = curWp.setTimeFromAttribute();
    135                             if (parsedTime == null) {
     132                            if (!curWp.hasDate()) {
    136133                                break; //It's pointless to continue with this segment, because none of the following waypoints had a timestamp
    137134                            }
     
    142139                    }
    143140
    144                     final long curWpTime = parsedTime.getTime() + offset;
     141                    final long curWpTime = curWp.getTimeInMillis() + offset;
    145142                    boolean interpolate = true;
    146143                    int tagTime = 0;
  • trunk/src/org/openstreetmap/josm/data/gpx/WayPoint.java

    r14446 r14456  
    55import java.util.ArrayList;
    66import java.util.Date;
     7import java.util.HashMap;
    78import java.util.List;
    89import java.util.Objects;
     
    1415import org.openstreetmap.josm.data.projection.Projecting;
    1516import org.openstreetmap.josm.tools.Logging;
     17import org.openstreetmap.josm.tools.date.DateUtils;
    1618import org.openstreetmap.josm.tools.template_engine.TemplateEngineDataProvider;
    1719
     
    2325
    2426    /**
    25      * The seconds (not milliseconds!) since 1970-01-01 00:00 UTC
    26      */
    27     public double time;
    28     /**
    2927     * The color to draw the segment before this point in
    3028     * @see #drawLine
    3129     */
    3230    public Color customColoring;
     31
    3332    /**
    3433     * <code>true</code> indicates that the line before this point should be drawn
    3534     */
    3635    public boolean drawLine;
     36
    3737    /**
    3838     * The direction of the line before this point. Used as cache to speed up drawing. Should not be relied on.
     
    4040    public int dir;
    4141
     42    /*
     43     * We "inline" lat/lon, rather than using a LatLon internally => reduces memory overhead. Relevant
     44     * because a lot of GPX waypoints are created when GPS tracks are downloaded from the OSM server.
     45     */
     46    private final double lat;
     47    private final double lon;
     48
     49    /*
     50     * internal cache of projected coordinates
     51     */
     52    private double east = Double.NaN;
     53    private double north = Double.NaN;
     54    private Object eastNorthCacheKey;
     55
    4256    /**
    4357     * Constructs a new {@code WayPoint} from an existing one.
     58     *
     59     * Except for PT_TIME attribute, all attribute objects are shallow copied.
     60     * This means modification of attr objects will affect original and new {@code WayPoint}.
     61     *
    4462     * @param p existing waypoint
    4563     */
    4664    public WayPoint(WayPoint p) {
     65        init_attr();
    4766        attr.putAll(p.attr);
     67        attr.put(PT_TIME, p.getDate());
    4868        lat = p.lat;
    4969        lon = p.lon;
     
    5171        north = p.north;
    5272        eastNorthCacheKey = p.eastNorthCacheKey;
    53         time = p.time;
    5473        customColoring = p.customColoring;
    5574        drawLine = p.drawLine;
     
    6281     */
    6382    public WayPoint(LatLon ll) {
     83        init_attr();
    6484        lat = ll.lat();
    6585        lon = ll.lon();
    6686    }
    6787
    68     /*
    69      * We "inline" lat/lon, rather than usinga LatLon internally => reduces memory overhead. Relevant
    70      * because a lot of GPX waypoints are created when GPS tracks are downloaded from the OSM server.
    71      */
    72     private final double lat;
    73     private final double lon;
    74 
    75     /*
    76      * internal cache of projected coordinates
    77      */
    78     private double east = Double.NaN;
    79     private double north = Double.NaN;
    80     private Object eastNorthCacheKey;
     88    /**
     89     * Interim to detect legacy code that is not using {@code WayPoint.setTime(x)}
     90     * functions, but {@code attr.put(PT_TIME, (String) x)} logic.
     91     * To remove mid 2019
     92     */
     93    private void init_attr() {
     94        attr = new HashMap<String, Object>(0) {
     95            @Override
     96            public Object put(String key, Object value) {
     97                Object ret = null;
     98                if (key != PT_TIME || (key == PT_TIME && value instanceof Date)) {
     99                    ret = super.put(key, value);
     100                } else {
     101                    if (value instanceof String) {
     102                        ret = super.put(PT_TIME, DateUtils.fromString((String) value));
     103                        List<String> lastErrorAndWarnings = Logging.getLastErrorAndWarnings();
     104                        if (!lastErrorAndWarnings.isEmpty() && !lastErrorAndWarnings.get(0).contains("calling WayPoint.put")) {
     105                            StackTraceElement[] e = Thread.currentThread().getStackTrace();
     106                            int n = 1;
     107                            while (n < e.length && "put".equals(e[n].getMethodName())) {
     108                                n++;
     109                            }
     110                            if (n < e.length) {
     111                                Logging.warn("{0}:{1} calling WayPoint.put(PT_TIME, ..) is deprecated. " +
     112                                    "Use WayPoint.setTime(..) instead.", e[n].getClassName(), e[n].getMethodName());
     113                            }
     114                        }
     115                    }
     116                }
     117                return ret;
     118            }
     119        };
     120    }
    81121
    82122    /**
     
    126166
    127167    /**
    128      * Sets the {@link #time} field as well as the {@link #PT_TIME} attribute to the specified time.
     168     * Sets the {@link #PT_TIME} attribute to the specified time.
    129169     *
    130170     * @param time the time to set
     
    132172     */
    133173    public void setTime(Date time) {
    134         this.time = time.getTime() / 1000.;
    135         this.attr.put(PT_TIME, time);
     174        setTimeInMillis(time.getTime());
    136175    }
    137176
     
    139178     * Convert the time stamp of the waypoint into seconds from the epoch.
    140179     *
    141      * @deprecated call {@link #setTimeFromAttribute()} directly if you need this
     180     * @deprecated Use {@link #setTime(Date)}, {@link #setTime(long)}, {@link #setTimeInMillis(long)}
    142181     */
    143182    @Deprecated
     
    147186
    148187    /**
    149      * Sets the {@link #time} field as well as the {@link #PT_TIME} attribute to the specified time.
     188     * Sets the {@link #PT_TIME} attribute to the specified time.
    150189     *
    151190     * @param ts seconds from the epoch
     
    153192     */
    154193    public void setTime(long ts) {
    155         setTimeInMillis(ts*1000);
    156     }
    157 
    158     /**
    159      * Sets the {@link #time} field as well as the {@link #PT_TIME} attribute to the specified time.
     194        setTimeInMillis(ts * 1000);
     195    }
     196
     197    /**
     198     * Sets the {@link #PT_TIME} attribute to the specified time.
    160199     *
    161200     * @param ts milliseconds from the epoch
     
    163202     */
    164203    public void setTimeInMillis(long ts) {
    165         this.time = ts / 1000.;
    166         this.attr.put(PT_TIME, new Date(ts));
    167     }
    168 
    169     /**
    170      * Convert the time stamp of the waypoint into seconds from the epoch
     204        attr.put(PT_TIME, new Date(ts));
     205    }
     206
     207    /**
     208     * Convert the time stamp of the waypoint into seconds from the epoch.
    171209     * @return The parsed time if successful, or {@code null}
    172210     * @since 9383
    173      */
     211     * @deprecated Use {@link #setTime(Date)}, {@link #setTime(long)}, {@link #setTimeInMillis(long)}
     212     */
     213    @Deprecated
    174214    public Date setTimeFromAttribute() {
    175         if (attr.containsKey(PT_TIME)) {
    176             final Object obj = get(PT_TIME);
     215        Logging.warn("WayPoint.setTimeFromAttribute() is deprecated, please fix calling code");
     216        return getDate();
     217    }
     218
     219    @Override
     220    public int compareTo(WayPoint w) {
     221        return Long.compare(getTimeInMillis(), w.getTimeInMillis());
     222    }
     223
     224    /**
     225     * Returns the waypoint time in seconds since the epoch.
     226     *
     227     * @return the waypoint time
     228     */
     229    public double getTime() {
     230        return getTimeInMillis() / 1000.;
     231    }
     232
     233    /**
     234     * Returns the waypoint time in milliseconds since the epoch.
     235     *
     236     * @return the waypoint time
     237     * @since 14456
     238     */
     239    public long getTimeInMillis() {
     240        Date d = getDateImpl();
     241        return d == null ? 0 : d.getTime();
     242    }
     243
     244    /**
     245     * Returns true if this waypoint has a time.
     246     *
     247     * @return true if a time is set, false otherwise
     248     * @since 14456
     249     */
     250    public boolean hasDate() {
     251        return attr.get(PT_TIME) instanceof Date;
     252    }
     253
     254    /**
     255     * Returns the waypoint time Date object.
     256     *
     257     * @return a copy of the Date object associated with this waypoint
     258     * @since 14456
     259     */
     260    public Date getDate() {
     261        return DateUtils.cloneDate(getDateImpl());
     262    }
     263
     264    /**
     265     * Returns the waypoint time Date object.
     266     *
     267     * @return the Date object associated with this waypoint
     268     */
     269    private Date getDateImpl() {
     270        if (attr != null) {
     271            final Object obj = attr.get(PT_TIME);
     272
    177273            if (obj instanceof Date) {
    178                 final Date date = (Date) obj;
    179                 time = date.getTime() / 1000.;
    180                 return date;
     274                return (Date) obj;
    181275            } else if (obj == null) {
    182276                Logging.info("Waypoint {0} value unset", PT_TIME);
    183277            } else {
    184278                Logging.warn("Unsupported waypoint {0} value: {1}", PT_TIME, obj);
    185                 time = 0;
    186279            }
    187280        }
     281
    188282        return null;
    189     }
    190 
    191     @Override
    192     public int compareTo(WayPoint w) {
    193         return Double.compare(time, w.time);
    194     }
    195 
    196     /**
    197      * Returns the waypoint time.
    198      * @return the waypoint time
    199      */
    200     public Date getTime() {
    201         return new Date((long) (time * 1000));
    202283    }
    203284
     
    228309        temp = Double.doubleToLongBits(lon);
    229310        result = prime * result + (int) (temp ^ (temp >>> 32));
    230         temp = Double.doubleToLongBits(time);
     311        temp = getTimeInMillis();
    231312        result = prime * result + (int) (temp ^ (temp >>> 32));
    232313        return result;
     
    242323        return Double.doubleToLongBits(lat) == Double.doubleToLongBits(other.lat)
    243324            && Double.doubleToLongBits(lon) == Double.doubleToLongBits(other.lon)
    244             && Double.doubleToLongBits(time) == Double.doubleToLongBits(other.time);
     325            && getTimeInMillis() == other.getTimeInMillis();
    245326    }
    246327}
  • trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java

    r14434 r14456  
    801801                wpt.setTimeInMillis(time);
    802802            } else if (n.hasKey(GpxConstants.PT_TIME)) {
    803                 wpt.setTime(DateUtils.fromString(n.get(GpxConstants.PT_TIME)));
     803                wpt.setTimeInMillis(DateUtils.tsFromString(n.get(GpxConstants.PT_TIME)));
    804804            } else if (!n.isTimestampEmpty()) {
    805805                wpt.setTime(Integer.toUnsignedLong(n.getRawTimestamp()));
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImages.java

    r14212 r14456  
    12301230            for (GpxTrackSegment segment : trk.getSegments()) {
    12311231                for (WayPoint curWp : segment.getWayPoints()) {
    1232                     final Date parsedTime = curWp.setTimeFromAttribute();
    1233                     if (parsedTime != null) {
    1234                         firstGPXDate = parsedTime.getTime();
     1232                    if (curWp.hasDate()) {
     1233                        firstGPXDate = curWp.getTimeInMillis();
    12351234                        break outer;
    12361235                    }
  • trunk/src/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelper.java

    r14451 r14456  
    509509                            continue;
    510510                        }
    511                         if (oldWp != null && trkPnt.time > oldWp.time) {
     511                        if (oldWp != null && trkPnt.getTimeInMillis() > oldWp.getTimeInMillis()) {
    512512                            double vel = trkPnt.getCoor().greatCircleDistance(oldWp.getCoor())
    513                                     / (trkPnt.time - oldWp.time);
     513                                    / (trkPnt.getTime() - oldWp.getTime());
    514514                            velocities.add(vel);
    515515                        }
     
    587587                    switch (colored) {
    588588                    case VELOCITY:
    589                         double dtime = trkPnt.time - oldWp.time;
     589                        double dtime = trkPnt.getTime() - oldWp.getTime();
    590590                        if (dtime > 0) {
    591591                            color = velocityScale.getColor(dist / dtime);
     
    599599                        break;
    600600                    case TIME:
    601                         double t = trkPnt.time;
     601                        double t = trkPnt.getTime();
    602602                        // skip bad timestamps and very short tracks
    603603                        if (t > 0 && t <= now && maxval - minval > minTrackDurationForTimeColoring) {
  • trunk/src/org/openstreetmap/josm/gui/layer/gpx/ImportAudioAction.java

    r14302 r14456  
    150150                for (GpxTrackSegment seg : track.getSegments()) {
    151151                    for (WayPoint w : seg.getWayPoints()) {
    152                         firstTime = w.time;
     152                        firstTime = w.getTime();
    153153                        break;
    154154                    }
     
    175175        if (hasWaypoints && Config.getPref().getBoolean("marker.audiofromexplicitwaypoints", true)) {
    176176            for (WayPoint w : layer.data.waypoints) {
    177                 if (w.time > firstTime) {
     177                if (w.getTime() > firstTime) {
    178178                    waypoints.add(w);
    179                 } else if (w.time > 0.0) {
     179                } else if (w.getTime() > 0.0) {
    180180                    timedMarkersOmitted = true;
    181181                }
     
    192192                if (wNear != null) {
    193193                    WayPoint wc = new WayPoint(w.getCoor());
    194                     wc.time = wNear.time;
     194                    wc.setTimeInMillis(wNear.getTimeInMillis());
    195195                    if (w.attr.containsKey(GpxConstants.GPX_NAME)) {
    196196                        wc.put(GpxConstants.GPX_NAME, w.getString(GpxConstants.GPX_NAME));
     
    230230                for (GpxTrackSegment seg : track.getSegments()) {
    231231                    for (WayPoint w : seg.getWayPoints()) {
    232                         if (startTime < w.time) {
     232                        if (startTime < w.getTime()) {
    233233                            w2 = w;
    234234                            break;
     
    246246            } else {
    247247                wayPointFromTimeStamp = new WayPoint(w1.getCoor().interpolate(w2.getCoor(),
    248                         (startTime - w1.time) / (w2.time - w1.time)));
    249                 wayPointFromTimeStamp.time = startTime;
     248                        (startTime - w1.getTime()) / (w2.getTime() - w1.getTime())));
     249                wayPointFromTimeStamp.setTimeInMillis((long) (startTime * 1000));
    250250                String name = audioFile.getName();
    251251                int dot = name.lastIndexOf('.');
     
    268268                        WayPoint wStart = new WayPoint(w.getCoor());
    269269                        wStart.put(GpxConstants.GPX_NAME, "start");
    270                         wStart.time = w.time;
     270                        wStart.setTimeInMillis(w.getTimeInMillis());
    271271                        waypoints.add(wStart);
    272272                        gotOne = true;
     
    284284
    285285        // we must have got at least one waypoint now
    286         ((ArrayList<WayPoint>) waypoints).sort(Comparator.comparingDouble(o -> o.time));
     286        ((ArrayList<WayPoint>) waypoints).sort((wp, other) -> wp.compareTo(other));
    287287
    288288        firstTime = -1.0; // this time of the first waypoint, not first trackpoint
    289289        for (WayPoint w : waypoints) {
    290290            if (firstTime < 0.0) {
    291                 firstTime = w.time;
    292             }
    293             double offset = w.time - firstTime;
    294             AudioMarker am = new AudioMarker(w.getCoor(), w, url, ml, w.time, offset);
     291                firstTime = w.getTime();
     292            }
     293            double offset = w.getTime() - firstTime;
     294            AudioMarker am = new AudioMarker(w.getCoor(), w, url, ml, w.getTime(), offset);
    295295            // timeFromAudio intended for future use to shift markers of this type on synchronization
    296296            if (w == wayPointFromTimeStamp) {
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/Marker.java

    r14447 r14456  
    256256    public WayPoint convertToWayPoint() {
    257257        WayPoint wpt = new WayPoint(getCoor());
    258         wpt.setTime((long) (time*1000));
     258        wpt.setTimeInMillis((long) (time * 1000));
    259259        if (text != null) {
    260260            wpt.addExtension("text", text);
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/MarkerLayer.java

    r14153 r14456  
    9797        for (WayPoint wpt : indata.waypoints) {
    9898            /* calculate time differences in waypoints */
    99             double time = wpt.time;
     99            double time = wpt.getTime();
    100100            boolean wptHasLink = wpt.attr.containsKey(GpxConstants.META_LINKS);
    101101            if (firstTime < 0 && wptHasLink) {
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/PlayHeadMarker.java

    r14153 r14456  
    167167                if (m instanceof AudioMarker) {
    168168                    AudioMarker a = (AudioMarker) m;
    169                     if (a.time > cw.time) {
     169                    if (a.time > cw.getTime()) {
    170170                        break;
    171171                    }
     
    188188            if (cw != null) {
    189189                setCoor(cw.getCoor());
    190                 ca.play(cw.time - ca.time);
     190                ca.play(cw.getTime() - ca.time);
    191191            }
    192192            endDrag(false);
     
    245245                return;
    246246            }
    247             ca = recent.parentLayer.addAudioMarker(cw.time, cw.getCoor());
     247            ca = recent.parentLayer.addAudioMarker(cw.getTime(), cw.getCoor());
    248248        }
    249249
     
    330330            for (GpxTrackSegment trackseg : track.getSegments()) {
    331331                for (WayPoint w: trackseg.getWayPoints()) {
    332                     if (audioTime < w.time) {
     332                    if (audioTime < w.getTime()) {
    333333                        w2 = w;
    334334                        break;
     
    350350                w1.getEastNorth(ProjectionRegistry.getProjection()) :
    351351                    w1.getEastNorth(ProjectionRegistry.getProjection()).interpolate(w2.getEastNorth(ProjectionRegistry.getProjection()),
    352                             (audioTime - w1.time)/(w2.time - w1.time)));
     352                            (audioTime - w1.getTime())/(w2.getTime() - w1.getTime())));
    353353        time = audioTime;
    354354        MapView mapView = MainApplication.getMap().mapView;
  • trunk/src/org/openstreetmap/josm/io/GpxReader.java

    r14447 r14456  
    445445                    }
    446446                    break;
    447                 case GpxConstants.PT_TIME:
     447                case PT_TIME:
    448448                    try {
    449                         currentWayPoint.setTime(DateUtils.fromString(accumulator.toString()));
     449                        currentWayPoint.setTimeInMillis(DateUtils.tsFromString(accumulator.toString()));
    450450                    } catch (UncheckedParseException e) {
    451451                        Logging.error(e);
  • trunk/src/org/openstreetmap/josm/io/nmea/NmeaReader.java

    r14434 r14456  
    525525            if (ps.pWp != currentwp) {
    526526                if (ps.pWp != null) {
    527                     ps.pWp.setTimeFromAttribute();
     527                    ps.pWp.getDate();
    528528                }
    529529                ps.pWp = currentwp;
Note: See TracChangeset for help on using the changeset viewer.