Changeset 3280 in josm for trunk


Ignore:
Timestamp:
2010-05-26T17:16:28+02:00 (15 years ago)
Author:
framm
Message:
  • added a selection to "download along this track" window which lets you download around waypoints only, or track and waypoints
  • fixed a bug that would erroneously record your last selection in the download area list
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java

    r3235 r3280  
    7878
    7979    private static final String PREF_DOWNLOAD_ALONG_TRACK_DISTANCE = "gpxLayer.downloadAlongTrack.distance";
    80     private static final String PREF_DOWNLOAD_ALONG_TRACK_AREA = "gpxLayer.downloadAlongTrack.distance";
     80    private static final String PREF_DOWNLOAD_ALONG_TRACK_AREA = "gpxLayer.downloadAlongTrack.area";
     81    private static final String PREF_DOWNLOAD_ALONG_TRACK_NEAR = "gpxLayer.downloadAlongTrack.near";
    8182
    8283    public GpxData data;
     
    877878            buffer.setSelectedIndex(Main.pref.getInteger(PREF_DOWNLOAD_ALONG_TRACK_DISTANCE, 0));
    878879            msg.add(buffer, GBC.eol());
     880
    879881            msg.add(new JLabel(tr("Maximum area per request:")), GBC.eol());
    880882            s = new String[area.length];
     
    885887            maxRect.setSelectedIndex(Main.pref.getInteger(PREF_DOWNLOAD_ALONG_TRACK_AREA, 0));
    886888            msg.add(maxRect, GBC.eol());
     889
     890            msg.add(new JLabel(tr("Download near:")), GBC.eol());
     891            JList downloadNear = new JList(new String[] { tr("track only"), tr("waypoints only"), tr("track and waypoints") });
     892            int NEAR_TRACK=0;
     893            int NEAR_WAYPOINTS=1;
     894            int NEAR_BOTH=2;
     895
     896            downloadNear.setSelectedIndex(Main.pref.getInteger(PREF_DOWNLOAD_ALONG_TRACK_NEAR, 0));
     897            msg.add(downloadNear, GBC.eol());
    887898
    888899            int ret = JOptionPane.showConfirmDialog(
     
    903914            Main.pref.putInteger(PREF_DOWNLOAD_ALONG_TRACK_DISTANCE, buffer.getSelectedIndex());
    904915            Main.pref.putInteger(PREF_DOWNLOAD_ALONG_TRACK_AREA, maxRect.getSelectedIndex());
     916            int near = downloadNear.getSelectedIndex();
     917            Main.pref.putInteger(PREF_DOWNLOAD_ALONG_TRACK_NEAR, near);
    905918
    906919            /*
     
    911924            int latcnt = 0;
    912925
    913             for (GpxTrack trk : data.tracks) {
    914                 for (GpxTrackSegment segment : trk.getSegments()) {
    915                     for (WayPoint p : segment.getWayPoints()) {
    916                         latsum += p.getCoor().lat();
    917                         latcnt++;
    918                     }
     926            if (near == NEAR_TRACK || near == NEAR_BOTH) {
     927                for (GpxTrack trk : data.tracks) {
     928                    for (GpxTrackSegment segment : trk.getSegments()) {
     929                        for (WayPoint p : segment.getWayPoints()) {
     930                            latsum += p.getCoor().lat();
     931                            latcnt++;
     932                        }
     933                    }
     934                }
     935            }
     936
     937            if (near == NEAR_WAYPOINTS || near == NEAR_BOTH) {
     938                for (WayPoint p : data.waypoints) {
     939                    latsum += p.getCoor().lat();
     940                    latcnt++;
    919941                }
    920942            }
     
    944966             */
    945967            LatLon previous = null;
    946             for (GpxTrack trk : data.tracks) {
    947                 for (GpxTrackSegment segment : trk.getSegments()) {
    948                     for (WayPoint p : segment.getWayPoints()) {
    949                         LatLon c = p.getCoor();
    950                         if (previous == null || c.greatCircleDistance(previous) > buffer_dist) {
    951                             // we add a buffer around the point.
    952                             r.setRect(c.lon() - buffer_x, c.lat() - buffer_y, 2 * buffer_x, 2 * buffer_y);
    953                             a.add(new Area(r));
    954                             previous = c;
    955                         }
     968            if (near == NEAR_TRACK || near == NEAR_BOTH) {
     969                for (GpxTrack trk : data.tracks) {
     970                    for (GpxTrackSegment segment : trk.getSegments()) {
     971                        for (WayPoint p : segment.getWayPoints()) {
     972                            LatLon c = p.getCoor();
     973                            if (previous == null || c.greatCircleDistance(previous) > buffer_dist) {
     974                                // we add a buffer around the point.
     975                                r.setRect(c.lon() - buffer_x, c.lat() - buffer_y, 2 * buffer_x, 2 * buffer_y);
     976                                a.add(new Area(r));
     977                                previous = c;
     978                            }
     979                        }
     980                    }
     981                }
     982            }
     983            if (near == NEAR_WAYPOINTS || near == NEAR_BOTH) {
     984                for (WayPoint p : data.waypoints) {
     985                    LatLon c = p.getCoor();
     986                    if (previous == null || c.greatCircleDistance(previous) > buffer_dist) {
     987                        // we add a buffer around the point.
     988                        r.setRect(c.lon() - buffer_x, c.lat() - buffer_y, 2 * buffer_x, 2 * buffer_y);
     989                        a.add(new Area(r));
     990                        previous = c;
    956991                    }
    957992                }
Note: See TracChangeset for help on using the changeset viewer.