Ticket #1555: Add reverse function.patch

File Add reverse function.patch, 1.8 KB (added by xeen, 17 years ago)
  • src/org/openstreetmap/josm/actions/downloadtasks/DownloadGpsTask.java

     
    3838            if (rawData == null)
    3939                return;
    4040            rawData.recalculateBounds();
     41            if(Main.pref.getBoolean("download.gps.fixDirection", false))
     42                rawData.reverse();
    4143            String name = tr("Downloaded GPX Data");
    4244            GpxLayer layer = new GpxLayer(rawData, name);
    4345            Layer x = findMergeLayer();
  • src/org/openstreetmap/josm/data/gpx/GpxData.java

     
    44
    55import java.io.File;
    66import java.util.Collection;
     7import java.util.Collections;
    78import java.util.LinkedList;
     9import java.util.List;
    810import java.util.Map;
    911
    1012import org.openstreetmap.josm.data.Bounds;
     
    2628    public Collection<WayPoint> waypoints = new LinkedList<WayPoint>();
    2729
    2830    public Bounds bounds;
     31   
     32    public void reverse() {
     33        for(GpxTrack x : tracks) {
     34           for(Collection<WayPoint> y : x.trackSegs)
     35               Collections.reverse((List<WayPoint>) y);
     36        }
     37       
     38        for(GpxRoute x : routes) {
     39            Collections.reverse((List<WayPoint>) x.routePoints);
     40        }
     41       
     42        Collections.reverse((List<WayPoint>) waypoints);
     43    }
    2944
    3045    public void mergeFrom(GpxData other) {
    3146        if (storageFile == null && other.storageFile != null) {