Ignore:
Timestamp:
2008-02-20T18:53:10+01:00 (16 years ago)
Author:
david
Message:

audio synchronization for tracks without waypoints

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/MarkerLayer.java

    r551 r552  
    1717import java.util.Collection;
    1818import java.util.Iterator;
    19 import java.util.Date;
    20 import java.text.SimpleDateFormat;
    21 import java.text.ParsePosition;
    22 import java.text.ParseException;
    2319import java.net.URL;
    2420
     
    7066                this.associatedFile = associatedFile;
    7167                this.data = new ArrayList<Marker>();
    72                 double offset = 0.0;
    73                 Date firstDate = null;
     68                double firstTime = -1.0;
    7469
    7570                for (WayPoint wpt : indata.waypoints) {
    7671                        /* calculate time differences in waypoints */
    77                         if (wpt.attr.containsKey("time")) {
    78                                 SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); // ignore timezone, as it is all relative
    79                                 Date d = f.parse(wpt.attr.get("time").toString(), new ParsePosition(0));
    80                                 if (d == null /* failed to parse */) {
    81                                         offset = 0.0;
    82                                 } else if (firstDate == null) {
    83                                         firstDate = d;
    84                                         offset = 0.0;
    85                                 } else {
    86                                         offset = (d.getTime() - firstDate.getTime()) / 1000.0; /* ms => seconds */
    87                                 }
    88                         }
    89                        
    90             Marker m = Marker.createMarker(wpt, indata.storageFile, offset);
     72                        double time = wpt.time();
     73                        if (firstTime < 0)
     74                                firstTime = time;
     75            Marker m = Marker.createMarker(wpt, indata.storageFile, time - firstTime);
    9176            if (m != null)
    9277                data.add(m);
Note: See TracChangeset for help on using the changeset viewer.