Index: trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java	(revision 3279)
+++ trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java	(revision 3280)
@@ -78,5 +78,6 @@
 
     private static final String PREF_DOWNLOAD_ALONG_TRACK_DISTANCE = "gpxLayer.downloadAlongTrack.distance";
-    private static final String PREF_DOWNLOAD_ALONG_TRACK_AREA = "gpxLayer.downloadAlongTrack.distance";
+    private static final String PREF_DOWNLOAD_ALONG_TRACK_AREA = "gpxLayer.downloadAlongTrack.area";
+    private static final String PREF_DOWNLOAD_ALONG_TRACK_NEAR = "gpxLayer.downloadAlongTrack.near";
 
     public GpxData data;
@@ -877,4 +878,5 @@
             buffer.setSelectedIndex(Main.pref.getInteger(PREF_DOWNLOAD_ALONG_TRACK_DISTANCE, 0));
             msg.add(buffer, GBC.eol());
+
             msg.add(new JLabel(tr("Maximum area per request:")), GBC.eol());
             s = new String[area.length];
@@ -885,4 +887,13 @@
             maxRect.setSelectedIndex(Main.pref.getInteger(PREF_DOWNLOAD_ALONG_TRACK_AREA, 0));
             msg.add(maxRect, GBC.eol());
+
+            msg.add(new JLabel(tr("Download near:")), GBC.eol());
+            JList downloadNear = new JList(new String[] { tr("track only"), tr("waypoints only"), tr("track and waypoints") });
+            int NEAR_TRACK=0;
+            int NEAR_WAYPOINTS=1;
+            int NEAR_BOTH=2;
+
+            downloadNear.setSelectedIndex(Main.pref.getInteger(PREF_DOWNLOAD_ALONG_TRACK_NEAR, 0));
+            msg.add(downloadNear, GBC.eol());
 
             int ret = JOptionPane.showConfirmDialog(
@@ -903,4 +914,6 @@
             Main.pref.putInteger(PREF_DOWNLOAD_ALONG_TRACK_DISTANCE, buffer.getSelectedIndex());
             Main.pref.putInteger(PREF_DOWNLOAD_ALONG_TRACK_AREA, maxRect.getSelectedIndex());
+            int near = downloadNear.getSelectedIndex();
+            Main.pref.putInteger(PREF_DOWNLOAD_ALONG_TRACK_NEAR, near);
 
             /*
@@ -911,10 +924,19 @@
             int latcnt = 0;
 
-            for (GpxTrack trk : data.tracks) {
-                for (GpxTrackSegment segment : trk.getSegments()) {
-                    for (WayPoint p : segment.getWayPoints()) {
-                        latsum += p.getCoor().lat();
-                        latcnt++;
-                    }
+            if (near == NEAR_TRACK || near == NEAR_BOTH) {
+                for (GpxTrack trk : data.tracks) {
+                    for (GpxTrackSegment segment : trk.getSegments()) {
+                        for (WayPoint p : segment.getWayPoints()) {
+                            latsum += p.getCoor().lat();
+                            latcnt++;
+                        }
+                    }
+                }
+            }
+
+            if (near == NEAR_WAYPOINTS || near == NEAR_BOTH) {
+                for (WayPoint p : data.waypoints) {
+                    latsum += p.getCoor().lat();
+                    latcnt++;
                 }
             }
@@ -944,14 +966,27 @@
              */
             LatLon previous = null;
-            for (GpxTrack trk : data.tracks) {
-                for (GpxTrackSegment segment : trk.getSegments()) {
-                    for (WayPoint p : segment.getWayPoints()) {
-                        LatLon c = p.getCoor();
-                        if (previous == null || c.greatCircleDistance(previous) > buffer_dist) {
-                            // we add a buffer around the point.
-                            r.setRect(c.lon() - buffer_x, c.lat() - buffer_y, 2 * buffer_x, 2 * buffer_y);
-                            a.add(new Area(r));
-                            previous = c;
-                        }
+            if (near == NEAR_TRACK || near == NEAR_BOTH) {
+                for (GpxTrack trk : data.tracks) {
+                    for (GpxTrackSegment segment : trk.getSegments()) {
+                        for (WayPoint p : segment.getWayPoints()) {
+                            LatLon c = p.getCoor();
+                            if (previous == null || c.greatCircleDistance(previous) > buffer_dist) {
+                                // we add a buffer around the point.
+                                r.setRect(c.lon() - buffer_x, c.lat() - buffer_y, 2 * buffer_x, 2 * buffer_y);
+                                a.add(new Area(r));
+                                previous = c;
+                            }
+                        }
+                    }
+                }
+            }
+            if (near == NEAR_WAYPOINTS || near == NEAR_BOTH) {
+                for (WayPoint p : data.waypoints) {
+                    LatLon c = p.getCoor();
+                    if (previous == null || c.greatCircleDistance(previous) > buffer_dist) {
+                        // we add a buffer around the point.
+                        r.setRect(c.lon() - buffer_x, c.lat() - buffer_y, 2 * buffer_x, 2 * buffer_y);
+                        a.add(new Area(r));
+                        previous = c;
                     }
                 }
