- Timestamp:
- 2009-09-16T21:40:57+02:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/gpx/GpxData.java
r2017 r2151 119 119 WayPoint last = null; 120 120 121 for (GpxTrack trk : tracks) { 122 for (Collection<WayPoint> trkseg : trk.trackSegs) { 123 for (WayPoint tpt : trkseg) { 124 if(last != null){ 125 Double d = last.getCoor().greatCircleDistance(tpt.getCoor()); 126 if(!d.isNaN() && !d.isInfinite()) 127 result += d; 128 } 129 last = tpt; 130 } 131 last = null; // restart for each track segment 132 } 133 } 121 for (GpxTrack trk : tracks) 122 result += trk.length(); 123 134 124 return result; 135 125 } -
trunk/src/org/openstreetmap/josm/data/gpx/GpxTrack.java
r1169 r2151 10 10 public Collection<Collection<WayPoint>> trackSegs 11 11 = new LinkedList<Collection<WayPoint>>(); 12 13 /** 14 * calculates the length of the track 15 */ 16 public double length(){ 17 double result = 0.0; // in meters 18 WayPoint last = null; 19 20 for (Collection<WayPoint> trkseg : trackSegs) { 21 for (WayPoint tpt : trkseg) { 22 if(last != null){ 23 Double d = last.getCoor().greatCircleDistance(tpt.getCoor()); 24 if(!d.isNaN() && !d.isInfinite()) 25 result += d; 26 } 27 last = tpt; 28 } 29 last = null; // restart for each track segment 30 } 31 return result; 32 } 12 33 } -
trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java
r2146 r2151 337 337 StringBuilder info = new StringBuilder().append("<html>"); 338 338 339 info.append(trn("{0} track, ", "{0} tracks, ", data.tracks.size(), data.tracks.size())).append(340 trn("{0} route, ", "{0} routes, ", data.routes.size(), data.routes.size())).append(341 trn("{0} waypoint", "{0} waypoints", data.waypoints.size(), data.waypoints.size())).append("<br>");342 343 339 if (data.attr.containsKey("name")) { 344 340 info.append(tr("Name: {0}", data.attr.get(GpxData.META_NAME))).append("<br>"); … … 350 346 351 347 if (data.tracks.size() > 0) { 352 boolean first = true; 353 WayPoint earliest = null, latest = null; 348 info.append("<table><thead align=\"center\"><tr><td colspan=\"5\">" 349 + trn("{0} track", "{0} tracks", data.tracks.size(), data.tracks.size()) 350 + "</td></tr><tr><td>" + tr("Name") + "</td><td>" 351 + tr("Description") + "</td><td>" + tr("Timespan") 352 + "</td><td>" + tr("Length") + "</td><td>" + tr("URL") 353 + "</td></tr></thead>"); 354 354 355 355 for (GpxTrack trk : data.tracks) { 356 WayPoint earliest = null, latest = null; 357 358 info.append("<tr><td>"); 359 if (trk.attr.containsKey("name")) 360 info.append(trk.attr.get("name")); 361 info.append("</td><td>"); 362 if (trk.attr.containsKey("desc")) 363 info.append(" ").append(trk.attr.get("desc")); 364 info.append("</td><td>"); 365 356 366 for (Collection<WayPoint> seg : trk.trackSegs) { 357 367 for (WayPoint pnt : seg) { 358 if ( first) {368 if (latest == null) { 359 369 latest = earliest = pnt; 360 first = false;361 370 } else { 362 371 if (pnt.compareTo(earliest) < 0) { … … 368 377 } 369 378 } 370 } 371 372 373 info.append(tr("Timespan: ") +df.format(new Date((long) (earliest.time * 1000))) + " - "379 380 if (earliest != null && latest != null) { 381 DateFormat df = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT); 382 info.append(df.format(new Date((long) (earliest.time * 1000))) + " - " 374 383 + df.format(new Date((long) (latest.time * 1000)))); 375 int diff = (int) (latest.time - earliest.time); 376 info.append(" (" + (diff / 3600) + ":" + ((diff % 3600) / 60) + ")"); 377 info.append("<br>"); 378 } 379 } 384 int diff = (int) (latest.time - earliest.time); 385 info.append(" (" + (diff / 3600) + ":" + ((diff % 3600) / 60) + ")"); 386 } 387 388 info.append("</td><td>"); 389 info.append(new DecimalFormat("#0.00").format(trk.length() / 1000) + "km"); 390 info.append("</td><td>"); 391 if (trk.attr.containsKey("url")) 392 info.append(trk.attr.get("url")); 393 info.append("</td></tr>"); 394 } 395 396 info.append("</table><br><br>"); 397 398 } 399 380 400 info.append(tr("Length: ") + new DecimalFormat("#0.00").format(data.length() / 1000) + "km"); 381 401 info.append("<br>"); 402 403 info.append(trn("{0} route, ", "{0} routes, ", data.routes.size(), data.routes.size())).append( 404 trn("{0} waypoint", "{0} waypoints", data.waypoints.size(), data.waypoints.size())).append("<br>"); 382 405 383 406 return info.append("</html>").toString(); -
trunk/src/org/openstreetmap/josm/io/GpxReader.java
r1724 r2151 286 286 } else if (qName.equals("name") || qName.equals("cmt") 287 287 || qName.equals("desc") || qName.equals("src") 288 || qName.equals("type") || qName.equals("number")) { 288 || qName.equals("type") || qName.equals("number") 289 || qName.equals("url")) { 289 290 currentTrack.attr.put(qName, accumulator.toString()); 290 291 }
Note:
See TracChangeset
for help on using the changeset viewer.