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

Last change on this file since 2874 was 2874, checked in by bastiK, 14 years ago

use PrimaryDateParser to parse time of GPS points (for geoimage)

  • Property svn:eol-style set to native
File size: 1.6 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.DateUtils;
13import org.openstreetmap.josm.tools.PrimaryDateParser;
14
15public 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}
Note: See TracBrowser for help on using the repository browser.