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

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

Gpx refactoring - GpxTrack and GpxTrackSegment is now interface, implementations for specific use can be provided (currently JOSM supports immutable gpx track, livegps plugin supports append only track).

  • track length and bounds are precalculated
  • GpxLayer paints only currently visible segments
  • 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.PrimaryDateParser;
13
14public class WayPoint extends WithAttributes implements Comparable<WayPoint>
15{
16 public double time;
17 public Color customColoring;
18 public boolean drawLine;
19 public int dir;
20
21 private final CachedLatLon coor;
22
23 public final LatLon getCoor() {
24 return coor;
25 }
26
27 public final EastNorth getEastNorth() {
28 return coor.getEastNorth();
29 }
30
31 public WayPoint(LatLon ll) {
32 coor = new CachedLatLon(ll);
33 }
34
35 @Override
36 public String toString() {
37 return "WayPoint (" + (attr.containsKey("name") ? attr.get("name") + ", " :"") + coor.toString() + ", " + attr + ")";
38 }
39
40 /**
41 * Convert the time stamp of the waypoint into seconds from the epoch
42 */
43 public void setTime() {
44 if(attr.containsKey("time")) {
45 PrimaryDateParser dateParser = new PrimaryDateParser();
46 try {
47 time = dateParser.parse(attr.get("time").toString()).getTime() / 1000.; /* ms => seconds */
48 } catch(Exception e) {
49 time = 0;
50 }
51 }
52 }
53
54 public int compareTo(WayPoint w)
55 {
56 return Double.compare(time, w.time);
57 }
58
59 public Date getTime() {
60 return new Date((long) (time * 1000));
61 }
62}
Note: See TracBrowser for help on using the repository browser.