source: josm/trunk/src/org/openstreetmap/josm/data/gpx/GpxTrack.java@ 2151

Last change on this file since 2151 was 2151, checked in by Gubaer, 15 years ago

applied #3526: patch by glebius@...: be more verbose about available traces in GPX layer

  • Property svn:eol-style set to native
File size: 822 bytes
Line 
1//License: GPLv2 or later
2//Copyright 2007 by Raphael Mack and others
3
4package org.openstreetmap.josm.data.gpx;
5
6import java.util.Collection;
7import java.util.LinkedList;
8
9public class GpxTrack extends WithAttributes {
10 public Collection<Collection<WayPoint>> trackSegs
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 }
33}
Note: See TracBrowser for help on using the repository browser.