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

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

File:
1 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;
Note: See TracChangeset for help on using the changeset viewer.