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

audio synchronization for tracks without waypoints

File:
1 edited

Legend:

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

    r444 r552  
    33
    44package org.openstreetmap.josm.data.gpx;
     5
     6import java.text.ParsePosition;
     7import java.text.SimpleDateFormat;
     8import java.util.Date;
    59
    610import org.openstreetmap.josm.Main;
     
    2226                return "WayPoint (" + (attr.containsKey("name") ? attr.get("name") + ", " :"") + latlon.toString() + ", " + attr + ")";
    2327        }
     28       
     29        /**
     30         * convert the time stamp of ther waypoint into seconds from the epoch
     31         * @return seconds
     32         */
     33        public double time () {
     34                if (! attr.containsKey("time"))
     35                        return 0.0;
     36                SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); // ignore timezone
     37                Date d = f.parse(attr.get("time").toString(), new ParsePosition(0));
     38                if (d == null /* failed to parse */)
     39                        return 0.0;
     40                return d.getTime() / 1000.0; /* ms => seconds */
     41        }
     42
    2443}
Note: See TracChangeset for help on using the changeset viewer.