source: josm/trunk/src/org/openstreetmap/josm/data/gpx/WayPoint.java@ 553

Last change on this file since 553 was 553, checked in by david, 16 years ago

(a) add preference dialog, (b) add audio tracing

File size: 1.2 KB
Line 
1//License: GPLv2 or later
2//Copyright 2007 by Raphael Mack and others
3
4package org.openstreetmap.josm.data.gpx;
5
6import java.text.ParsePosition;
7import java.text.SimpleDateFormat;
8import java.util.Date;
9
10import org.openstreetmap.josm.Main;
11import org.openstreetmap.josm.data.coor.EastNorth;
12import org.openstreetmap.josm.data.coor.LatLon;
13
14public class WayPoint extends WithAttributes {
15
16 public final LatLon latlon;
17 public final EastNorth eastNorth;
18 public double time;
19
20 public WayPoint(LatLon ll) {
21 latlon = ll;
22 eastNorth = Main.proj.latlon2eastNorth(ll);
23 }
24
25 @Override
26 public String toString() {
27 return "WayPoint (" + (attr.containsKey("name") ? attr.get("name") + ", " :"") + latlon.toString() + ", " + attr + ")";
28 }
29
30 /**
31 * convert the time stamp of ther waypoint into seconds from the epoch
32 * @return seconds
33 */
34 public void setTime () {
35 if (! attr.containsKey("time"))
36 time = 0.0;
37 SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); // ignore timezone
38 Date d = f.parse(attr.get("time").toString(), new ParsePosition(0));
39 if (d == null /* failed to parse */)
40 time = 0.0;
41 time = d.getTime() / 1000.0; /* ms => seconds */
42 }
43
44}
Note: See TracBrowser for help on using the repository browser.