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