Ignore:
Timestamp:
2008-08-21T00:34:53+02:00 (16 years ago)
Author:
stoecker
Message:

support of Garmin time stamps in GPX import. patch by Roland Ramthun

Location:
trunk/src/org/openstreetmap/josm/data
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/gpx/WayPoint.java

    r748 r813  
    3535         * Convert the time stamp of the waypoint into seconds from the epoch
    3636         */
    37         public void setTime () {
     37        public void setTime() {
    3838                if (! attr.containsKey("time")) {
    39                         time = 0.0;
    4039                        return;
    4140                }
    4241                SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); // ignore timezone
    4342                Date d = f.parse(attr.get("time").toString(), new ParsePosition(0));
    44                 if (d == null /* failed to parse */) {
    45                         time = 0.0;
    46                 } else {
     43                if (d != null /* parsing ok */) {
     44                        time = d.getTime() / 1000.0; /* ms => seconds */
     45                }
     46        }
     47
     48        /**
     49         * Convert a time stamp of the waypoint from the <cmt> or <desc> field
     50         * into seconds from the epoch. Handles the date format as it is used by
     51         * Garmin handhelds. Does not overwrite an existing timestamp (!= 0.0).
     52         * A value of <time> fields overwrites values set with by method.
     53         * Does nothing if specified key does not exist or text cannot be parsed.
     54         *
     55         * @param key The key that contains the text to convert.
     56         */
     57        public void setGarminCommentTime(String key) {
     58                // do not overwrite time if already set
     59                if (time != 0.0) {
     60                        return;
     61                }
     62                if (! attr.containsKey(key)) {
     63                        return;
     64                }
     65                // example date format "18-AUG-08 13:33:03"
     66                SimpleDateFormat f = new SimpleDateFormat("dd-MMM-yy HH:mm:ss"); // Garmin wpts have no timezone
     67                Date d = f.parse(attr.get(key).toString(), new ParsePosition(0));
     68                if (d != null /* parsing OK */) {
    4769                        time = d.getTime() / 1000.0; /* ms => seconds */
    4870                }
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java

    r805 r813  
    108108                fillUnselectedNode = Main.pref.getBoolean("mappaint.node.fill-unselected", false);
    109109                virtualNodeSize = virtual ? Main.pref.getInteger("mappaint.node.virtual-size", 4) / 2 : 0;
    110                 virtualNodeSpace = Main.pref.getInteger("mappaint.node.virtual-space", 50);
     110                virtualNodeSpace = Main.pref.getInteger("mappaint.node.virtual-space", 70);
    111111
    112112                ((Graphics2D)g)
Note: See TracChangeset for help on using the changeset viewer.