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.awt.Color;
|
---|
7 | import java.util.Date;
|
---|
8 |
|
---|
9 | import org.openstreetmap.josm.data.coor.CachedLatLon;
|
---|
10 | import org.openstreetmap.josm.data.coor.EastNorth;
|
---|
11 | import org.openstreetmap.josm.data.coor.LatLon;
|
---|
12 | import org.openstreetmap.josm.tools.DateUtils;
|
---|
13 | import org.openstreetmap.josm.tools.PrimaryDateParser;
|
---|
14 |
|
---|
15 | public class WayPoint extends WithAttributes implements Comparable<WayPoint>
|
---|
16 | {
|
---|
17 | public double time;
|
---|
18 | public Color customColoring;
|
---|
19 | public boolean drawLine;
|
---|
20 | public int dir;
|
---|
21 |
|
---|
22 | private CachedLatLon coor;
|
---|
23 |
|
---|
24 | public final LatLon getCoor() {
|
---|
25 | return coor;
|
---|
26 | }
|
---|
27 |
|
---|
28 | public final EastNorth getEastNorth() {
|
---|
29 | return coor.getEastNorth();
|
---|
30 | }
|
---|
31 |
|
---|
32 | public WayPoint(LatLon ll) {
|
---|
33 | coor = new CachedLatLon(ll);
|
---|
34 | }
|
---|
35 |
|
---|
36 | @Override
|
---|
37 | public String toString() {
|
---|
38 | return "WayPoint (" + (attr.containsKey("name") ? attr.get("name") + ", " :"") + coor.toString() + ", " + attr + ")";
|
---|
39 | }
|
---|
40 |
|
---|
41 | /**
|
---|
42 | * Convert the time stamp of the waypoint into seconds from the epoch
|
---|
43 | */
|
---|
44 | public void setTime() {
|
---|
45 | if(attr.containsKey("time")) {
|
---|
46 | PrimaryDateParser dateParser = new PrimaryDateParser();
|
---|
47 | try {
|
---|
48 | time = dateParser.parse(attr.get("time").toString()).getTime() / 1000.; /* ms => seconds */
|
---|
49 | } catch(Exception e) {
|
---|
50 | time = 0;
|
---|
51 | }
|
---|
52 | }
|
---|
53 | }
|
---|
54 |
|
---|
55 | public int compareTo(WayPoint w)
|
---|
56 | {
|
---|
57 | return Double.compare(time, w.time);
|
---|
58 | }
|
---|
59 |
|
---|
60 | public Date getTime() {
|
---|
61 | return new Date((long) (time * 1000));
|
---|
62 | }
|
---|
63 | }
|
---|