Index: /trunk/src/org/openstreetmap/josm/data/gpx/GpxData.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/gpx/GpxData.java	(revision 14450)
+++ /trunk/src/org/openstreetmap/josm/data/gpx/GpxData.java	(revision 14451)
@@ -840,5 +840,5 @@
      * over all routes
      */
-    public Iterable<Collection<WayPoint>> getLinesIterable(final boolean... trackVisibility) {
+    public Iterable<Line> getLinesIterable(final boolean... trackVisibility) {
         return () -> new LinesIterator(this, trackVisibility);
     }
@@ -863,5 +863,5 @@
      * Iterates over all track segments and then over all routes.
      */
-    public static class LinesIterator implements Iterator<Collection<WayPoint>> {
+    public static class LinesIterator implements Iterator<Line> {
 
         private Iterator<GpxTrack> itTracks;
@@ -870,6 +870,7 @@
         private final Iterator<GpxRoute> itRoutes;
 
-        private Collection<WayPoint> next;
+        private Line next;
         private final boolean[] trackVisibility;
+        private Map<String, Object> trackAttributes;
 
         /**
@@ -893,20 +894,21 @@
 
         @Override
-        public Collection<WayPoint> next() {
+        public Line next() {
             if (!hasNext()) {
                 throw new NoSuchElementException();
             }
-            Collection<WayPoint> current = next;
+            Line current = next;
             next = getNext();
             return current;
         }
 
-        private Collection<WayPoint> getNext() {
+        private Line getNext() {
             if (itTracks != null) {
                 if (itTrackSegments != null && itTrackSegments.hasNext()) {
-                    return itTrackSegments.next().getWayPoints();
+                    return new Line(itTrackSegments.next(), trackAttributes);
                 } else {
                     while (itTracks.hasNext()) {
                         GpxTrack nxtTrack = itTracks.next();
+                        trackAttributes = nxtTrack.getAttributes();
                         idxTracks++;
                         if (trackVisibility != null && !trackVisibility[idxTracks])
@@ -914,13 +916,14 @@
                         itTrackSegments = nxtTrack.getSegments().iterator();
                         if (itTrackSegments.hasNext()) {
-                            return itTrackSegments.next().getWayPoints();
+                            return new Line(itTrackSegments.next(), trackAttributes);
                         }
                     }
                     // if we get here, all the Tracks are finished; Continue with Routes
+                    trackAttributes = null;
                     itTracks = null;
                 }
             }
             if (itRoutes.hasNext()) {
-                return itRoutes.next().routePoints;
+                return new Line(itRoutes.next());
             }
             return null;
Index: /trunk/src/org/openstreetmap/josm/data/gpx/Line.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/gpx/Line.java	(revision 14451)
+++ /trunk/src/org/openstreetmap/josm/data/gpx/Line.java	(revision 14451)
@@ -0,0 +1,116 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.data.gpx;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * Line represents a linear collection of GPX waypoints with the ordered/unordered distinction.
+ * @since 14451
+ */
+public class Line implements Collection<WayPoint> {
+    private final Collection<WayPoint> waypoints;
+    private final boolean unordered;
+
+    /**
+     * Constructs a new {@code Line}.
+     * @param waypoints collection of waypoints
+     * @param attributes track/route attributes
+     */
+    public Line(Collection<WayPoint> waypoints, Map<String, Object> attributes) {
+        this.waypoints = Objects.requireNonNull(waypoints);
+        unordered = attributes.isEmpty() && waypoints.stream().allMatch(x -> x.get(GpxConstants.PT_TIME) == null);
+    }
+
+    /**
+     * Constructs a new {@code Line}.
+     * @param trackSegment track segment
+     * @param trackAttributes track attributes
+     */
+    public Line(GpxTrackSegment trackSegment, Map<String, Object> trackAttributes) {
+        this(trackSegment.getWayPoints(), trackAttributes);
+    }
+
+    /**
+     * Constructs a new {@code Line}.
+     * @param route route
+     */
+    public Line(GpxRoute route) {
+        this(route.routePoints, route.attr);
+    }
+
+    /**
+     * Determines if waypoints are ordered.
+     * @return {@code true} if waypoints are ordered
+     */
+    public boolean isUnordered() {
+        return unordered;
+    }
+
+    @Override
+    public int size() {
+        return waypoints.size();
+    }
+
+    @Override
+    public boolean isEmpty() {
+        return waypoints.isEmpty();
+    }
+
+    @Override
+    public boolean contains(Object o) {
+        return waypoints.contains(o);
+    }
+
+    @Override
+    public Iterator<WayPoint> iterator() {
+        return waypoints.iterator();
+    }
+
+    @Override
+    public Object[] toArray() {
+        return waypoints.toArray();
+    }
+
+    @Override
+    public <T> T[] toArray(T[] a) {
+        return waypoints.toArray(a);
+    }
+
+    @Override
+    public boolean add(WayPoint e) {
+        return waypoints.add(e);
+    }
+
+    @Override
+    public boolean remove(Object o) {
+        return waypoints.remove(o);
+    }
+
+    @Override
+    public boolean containsAll(Collection<?> c) {
+        return waypoints.containsAll(c);
+    }
+
+    @Override
+    public boolean addAll(Collection<? extends WayPoint> c) {
+        return waypoints.addAll(c);
+    }
+
+    @Override
+    public boolean removeAll(Collection<?> c) {
+        return waypoints.removeAll(c);
+    }
+
+    @Override
+    public boolean retainAll(Collection<?> c) {
+        return waypoints.retainAll(c);
+    }
+
+    @Override
+    public void clear() {
+        waypoints.clear();
+    }
+}
Index: /trunk/src/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelper.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelper.java	(revision 14450)
+++ /trunk/src/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelper.java	(revision 14451)
@@ -24,5 +24,4 @@
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.Date;
@@ -42,4 +41,5 @@
 import org.openstreetmap.josm.data.gpx.GpxData.GpxDataChangeEvent;
 import org.openstreetmap.josm.data.gpx.GpxData.GpxDataChangeListener;
+import org.openstreetmap.josm.data.gpx.Line;
 import org.openstreetmap.josm.data.gpx.WayPoint;
 import org.openstreetmap.josm.data.preferences.NamedColorProperty;
@@ -365,5 +365,5 @@
 
         ensureTrackVisibilityLength();
-        for (Collection<WayPoint> segment : data.getLinesIterable(layer.trackVisibility)) {
+        for (Line segment : data.getLinesIterable(layer.trackVisibility)) {
 
             for (WayPoint pt : segment) {
@@ -501,5 +501,5 @@
             if (colored == ColorMode.VELOCITY) {
                 final List<Double> velocities = new ArrayList<>();
-                for (Collection<WayPoint> segment : data.getLinesIterable(null)) {
+                for (Line segment : data.getLinesIterable(null)) {
                     if (!forceLines) {
                         oldWp = null;
@@ -526,5 +526,5 @@
                 }
             } else if (colored == ColorMode.HDOP) {
-                for (Collection<WayPoint> segment : data.getLinesIterable(null)) {
+                for (Line segment : data.getLinesIterable(null)) {
                     for (WayPoint trkPnt : segment) {
                         Object val = trkPnt.get(GpxConstants.PT_HDOP);
@@ -565,5 +565,5 @@
 
         // Now the colors for all the points will be assigned
-        for (Collection<WayPoint> segment : data.getLinesIterable(null)) {
+        for (Line segment : data.getLinesIterable(null)) {
             if (!forceLines) { // don't draw lines between segments, unless forced to
                 oldWp = null;
@@ -609,5 +609,5 @@
                     default: // Do nothing
                     }
-                    if (!noDraw && (maxLineLength == -1 || dist <= maxLineLength)) {
+                    if (!noDraw && !segment.isUnordered() && (maxLineLength == -1 || dist <= maxLineLength)) {
                         trkPnt.drawLine = true;
                         double bearing = oldWp.getCoor().bearing(trkPnt.getCoor());
