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

Last change on this file since 3715 was 3321, checked in by jttt, 14 years ago

Validate tagging presets when they're added in Preferences dialog

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