Changeset 14451 in josm


Ignore:
Timestamp:
2018-11-25T17:51:39+01:00 (6 years ago)
Author:
Don-vip
Message:

fix #16963 - do not draw lines for GPX unordered tracks

Location:
trunk/src/org/openstreetmap/josm
Files:
1 added
2 edited

Legend:

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

    r14341 r14451  
    840840     * over all routes
    841841     */
    842     public Iterable<Collection<WayPoint>> getLinesIterable(final boolean... trackVisibility) {
     842    public Iterable<Line> getLinesIterable(final boolean... trackVisibility) {
    843843        return () -> new LinesIterator(this, trackVisibility);
    844844    }
     
    863863     * Iterates over all track segments and then over all routes.
    864864     */
    865     public static class LinesIterator implements Iterator<Collection<WayPoint>> {
     865    public static class LinesIterator implements Iterator<Line> {
    866866
    867867        private Iterator<GpxTrack> itTracks;
     
    870870        private final Iterator<GpxRoute> itRoutes;
    871871
    872         private Collection<WayPoint> next;
     872        private Line next;
    873873        private final boolean[] trackVisibility;
     874        private Map<String, Object> trackAttributes;
    874875
    875876        /**
     
    893894
    894895        @Override
    895         public Collection<WayPoint> next() {
     896        public Line next() {
    896897            if (!hasNext()) {
    897898                throw new NoSuchElementException();
    898899            }
    899             Collection<WayPoint> current = next;
     900            Line current = next;
    900901            next = getNext();
    901902            return current;
    902903        }
    903904
    904         private Collection<WayPoint> getNext() {
     905        private Line getNext() {
    905906            if (itTracks != null) {
    906907                if (itTrackSegments != null && itTrackSegments.hasNext()) {
    907                     return itTrackSegments.next().getWayPoints();
     908                    return new Line(itTrackSegments.next(), trackAttributes);
    908909                } else {
    909910                    while (itTracks.hasNext()) {
    910911                        GpxTrack nxtTrack = itTracks.next();
     912                        trackAttributes = nxtTrack.getAttributes();
    911913                        idxTracks++;
    912914                        if (trackVisibility != null && !trackVisibility[idxTracks])
     
    914916                        itTrackSegments = nxtTrack.getSegments().iterator();
    915917                        if (itTrackSegments.hasNext()) {
    916                             return itTrackSegments.next().getWayPoints();
     918                            return new Line(itTrackSegments.next(), trackAttributes);
    917919                        }
    918920                    }
    919921                    // if we get here, all the Tracks are finished; Continue with Routes
     922                    trackAttributes = null;
    920923                    itTracks = null;
    921924                }
    922925            }
    923926            if (itRoutes.hasNext()) {
    924                 return itRoutes.next().routePoints;
     927                return new Line(itRoutes.next());
    925928            }
    926929            return null;
  • trunk/src/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelper.java

    r13206 r14451  
    2424import java.util.ArrayList;
    2525import java.util.Arrays;
    26 import java.util.Collection;
    2726import java.util.Collections;
    2827import java.util.Date;
     
    4241import org.openstreetmap.josm.data.gpx.GpxData.GpxDataChangeEvent;
    4342import org.openstreetmap.josm.data.gpx.GpxData.GpxDataChangeListener;
     43import org.openstreetmap.josm.data.gpx.Line;
    4444import org.openstreetmap.josm.data.gpx.WayPoint;
    4545import org.openstreetmap.josm.data.preferences.NamedColorProperty;
     
    365365
    366366        ensureTrackVisibilityLength();
    367         for (Collection<WayPoint> segment : data.getLinesIterable(layer.trackVisibility)) {
     367        for (Line segment : data.getLinesIterable(layer.trackVisibility)) {
    368368
    369369            for (WayPoint pt : segment) {
     
    501501            if (colored == ColorMode.VELOCITY) {
    502502                final List<Double> velocities = new ArrayList<>();
    503                 for (Collection<WayPoint> segment : data.getLinesIterable(null)) {
     503                for (Line segment : data.getLinesIterable(null)) {
    504504                    if (!forceLines) {
    505505                        oldWp = null;
     
    526526                }
    527527            } else if (colored == ColorMode.HDOP) {
    528                 for (Collection<WayPoint> segment : data.getLinesIterable(null)) {
     528                for (Line segment : data.getLinesIterable(null)) {
    529529                    for (WayPoint trkPnt : segment) {
    530530                        Object val = trkPnt.get(GpxConstants.PT_HDOP);
     
    565565
    566566        // Now the colors for all the points will be assigned
    567         for (Collection<WayPoint> segment : data.getLinesIterable(null)) {
     567        for (Line segment : data.getLinesIterable(null)) {
    568568            if (!forceLines) { // don't draw lines between segments, unless forced to
    569569                oldWp = null;
     
    609609                    default: // Do nothing
    610610                    }
    611                     if (!noDraw && (maxLineLength == -1 || dist <= maxLineLength)) {
     611                    if (!noDraw && !segment.isUnordered() && (maxLineLength == -1 || dist <= maxLineLength)) {
    612612                        trkPnt.drawLine = true;
    613613                        double bearing = oldWp.getCoor().bearing(trkPnt.getCoor());
Note: See TracChangeset for help on using the changeset viewer.