Last change
on this file since 627 was 627, checked in by framm, 16 years ago |
|
-
Property svn:eol-style
set to
native
|
File size:
1.2 KB
|
Line | |
---|
1 | //License: GPLv2 or later
|
---|
2 | //Copyright 2007 by Raphael Mack and others
|
---|
3 |
|
---|
4 | package org.openstreetmap.josm.data.gpx;
|
---|
5 |
|
---|
6 | import java.text.ParsePosition;
|
---|
7 | import java.text.SimpleDateFormat;
|
---|
8 | import java.util.Date;
|
---|
9 |
|
---|
10 | import org.openstreetmap.josm.Main;
|
---|
11 | import org.openstreetmap.josm.data.coor.EastNorth;
|
---|
12 | import org.openstreetmap.josm.data.coor.LatLon;
|
---|
13 |
|
---|
14 | public 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 | return;
|
---|
38 | }
|
---|
39 | SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); // ignore timezone
|
---|
40 | Date d = f.parse(attr.get("time").toString(), new ParsePosition(0));
|
---|
41 | if (d == null /* failed to parse */) {
|
---|
42 | time = 0.0;
|
---|
43 | } else {
|
---|
44 | time = d.getTime() / 1000.0; /* ms => seconds */
|
---|
45 | }
|
---|
46 | }
|
---|
47 |
|
---|
48 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.