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