Bodo Meissner confirmed the problem on talk-de.
Even MapSource exports waypoints without <time>, but with the time set
in <cmt> and <desc>, so it is no gpsbabel problem.
Attached a better second version of the patch, combined from Bodo's and
mine. Please merge this into trunk.
Additionally it increases the value for the allowed distance of the
waypoints from the trackpoints.
This is useful for the "guessed" correlation of untimed waypoints.
###
Bodo Meissner wrote:
Ich habe das mal für den ersten Punkt "001" überprüft. JOSM erlaubt eine
Abweichung von 10.0e-7 (= 1.0e-6) mit einem Kommentar "about 25m". Laut
GPS-Track-Analyse beträgt der Abstand ca. 0,4m. (Keine Ahnung, ob das
Programm richtig rechnet.)
Die größte Abweichung gibt es bei Punkt "036" mit ca. 2.9e-5, laut
GPS-Track-Analyse ca. 3,2m.
Durch experimentelles Verändern des Limits habe ich festgestellt, daß
bei 4.0e-4 nur noch Punkt "036" nicht zugeordnet wird, bei 5.0e-4 werden
sämtliche Punkte zugeordnet. (Weitere Zwischenwerte habe ich nicht
ausprobiert.)
Wenn ich die unterschiedliche Abweichung in x- und y-Richtung und die
Abhängigkeit von der geografischen Breite ignoriere, würde wohl ein
Limit von 3.5e-3 etwa 25m entsprechen.
Ich habe mal das Limit auf 1.0e-3 geändert und Code zum Parsen der
Garmin-Zeiteinträge in <cmt> und <desc> eingebaut.
###
If you consider this to be harmful, please do not apply the change in
GpxLayer.java.
Regards
Roland
Index: src/org/openstreetmap/josm/data/gpx/WayPoint.java
===================================================================
--- src/org/openstreetmap/josm/data/gpx/WayPoint.java (revision 808)
+++ src/org/openstreetmap/josm/data/gpx/WayPoint.java (working copy)
@@ -34,9 +34,8 @@
/**
* Convert the time stamp of the waypoint into seconds from the epoch
*/
- public void setTime () {
+ public void setTime() {
if (! attr.containsKey("time")) {
- time = 0.0;
return;
}
SimpleDateFormat f = new
SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); // ignore timezone
@@ -41,9 +40,32 @@
}
SimpleDateFormat f = new
SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); // ignore timezone
Date d = f.parse(attr.get("time").toString(), new
ParsePosition(0));
- if (d == null /* failed to parse */) {
- time = 0.0;
- } else {
+ if (d != null /* parsing ok */) {
+ time = d.getTime() / 1000.0; /* ms => seconds */
+ }
+ }
+
+ /**
+ * Convert a time stamp of the waypoint from the <cmt> or <desc> field
+ * into seconds from the epoch. Handles the date format as it is used
by
+ * Garmin handhelds. Does not overwrite an existing timestamp (!= 0.0).
+ * A value of <time> fields overwrites values set with by method.
+ * Does nothing if specified key does not exist or text cannot be
parsed.
+ *
+ * @param key The key that contains the text to convert.
+ */
+ public void setGarminCommentTime(String key) {
+ // do not overwrite time if already set
+ if (time != 0.0) {
+ return;
+ }
+ if (! attr.containsKey(key)) {
+ return;
+ }
+ // example date format "18-AUG-08 13:33:03"
+ SimpleDateFormat f = new SimpleDateFormat("dd-MMM-yy
HH:mm:ss"); // Garmin wpts have no timezone
+ Date d = f.parse(attr.get(key).toString(), new
ParsePosition(0));
+ if (d != null /* parsing OK */) {
time = d.getTime() / 1000.0; /* ms => seconds */
}
}
Index: src/org/openstreetmap/josm/gui/layer/GpxLayer.java
===================================================================
--- src/org/openstreetmap/josm/gui/layer/GpxLayer.java (revision 808)
+++ src/org/openstreetmap/josm/gui/layer/GpxLayer.java (working copy)
@@ -793,7 +793,7 @@
{
for (WayPoint w : data.waypoints) {
if (waypoints.contains(w)) { continue; }
- WayPoint wNear = nearestPointOnTrack(w.eastNorth,
10.0e-7 /* about 25m */);
+ WayPoint wNear = nearestPointOnTrack(w.eastNorth,
1.0e-3/* 10.0e-7 too small */ /* about 25m */);
if (wNear != null) {
WayPoint wc = new WayPoint(w.latlon);
wc.time = wNear.time;
Index: src/org/openstreetmap/josm/io/GpxReader.java
===================================================================
--- src/org/openstreetmap/josm/io/GpxReader.java (revision 808)
+++ src/org/openstreetmap/josm/io/GpxReader.java (working copy)
@@ -223,10 +223,9 @@
}
break;
case wpt:
- if (qName.equals("ele") || qName.equals("desc")
- || qName.equals("magvar") ||
qName.equals("geoidheight")
- || qName.equals("name") ||
qName.equals("sym")
- || qName.equals("cmt") ||
qName.equals("type")) {
+ if (qName.equals("ele") ||
qName.equals("magvar")
+ || qName.equals("geoidheight")
|| qName.equals("name")
+ || qName.equals("sym") ||
qName.equals("type")) {
currentWayPoint.attr.put(qName,
accumulator.toString());
} else if (qName.equals("time")) {
currentWayPoint.attr.put(qName,
accumulator.toString());
@@ -231,6 +230,9 @@
} else if (qName.equals("time")) {
currentWayPoint.attr.put(qName,
accumulator.toString());
currentWayPoint.setTime();
+ } else if (qName.equals("cmt") ||
qName.equals("desc")) {
+ currentWayPoint.attr.put(qName,
accumulator.toString());
+
currentWayPoint.setGarminCommentTime(qName);
} else if (qName.equals("rtept")) {
currentState = states.pop();
currentRoute.routePoints.add(currentWayPoint);
_______________________________________________
josm-dev mailing list
[email protected]
http://lists.openstreetmap.org/listinfo/josm-dev