- Timestamp:
- 2009-01-04T23:44:07+01:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java
r1206 r1210 12 12 import java.awt.GridBagLayout; 13 13 import java.awt.Point; 14 import java.awt.Rectangle;15 14 import java.awt.event.ActionEvent; 16 15 import java.awt.event.ActionListener; … … 58 57 import org.openstreetmap.josm.actions.downloadtasks.DownloadOsmTask; 59 58 import org.openstreetmap.josm.data.coor.EastNorth; 59 import org.openstreetmap.josm.data.coor.LatLon; 60 60 import org.openstreetmap.josm.data.gpx.GpxData; 61 61 import org.openstreetmap.josm.data.gpx.GpxRoute; … … 780 780 JOptionPane.OK_CANCEL_OPTION) == JOptionPane.CANCEL_OPTION) { 781 781 return; 782 783 782 } 784 783 … … 803 802 804 803 /* 805 * Compute buffer zone extents and maximum bounding box size. Note howthe804 * Compute buffer zone extents and maximum bounding box size. Note that the 806 805 * maximum we ever offer is a bbox area of 0.002, while the API theoretically 807 806 * supports 0.25, but as soon as you touch any built-up area, that kind of … … 810 809 */ 811 810 Integer i = buffer.getSelectedIndex(); 812 double buffer_y = dist[i < 0 ? 0 : i] / 1000.0; 811 int buffer_dist = dist[i < 0 ? 0 : i]; 812 double buffer_y = buffer_dist / 100000.0; 813 813 double buffer_x = buffer_y / scale; 814 814 i = maxRect.getSelectedIndex(); 815 815 double max_area = area[i < 0 ? 0 : i] / 10000.0 / scale; 816 817 816 Area a = new Area(); 818 817 Rectangle2D r = new Rectangle2D.Double(); … … 820 819 /* 821 820 * Collect the combined area of all gpx points plus buffer zones around them. 822 * This is rather inefficient (may take 20 seconds and more for large tracks); 823 * maybe it could be improved by disregarding points that lie really close to 824 * the previous point. 821 * We ignore points that lie closer to the previous point than the given buffer 822 * size because otherwise this operation takes ages. 825 823 */ 824 LatLon previous = null; 826 825 for (GpxTrack trk : data.tracks) { 827 826 for (Collection<WayPoint> segment : trk.trackSegs) { 828 827 for (WayPoint p : segment) { 829 // we add a buffer around the point. 830 r.setRect(p.latlon.lon()-buffer_x, p.latlon.lat()-buffer_y, 2*buffer_x, 2*buffer_y); 831 a.add(new Area(r)); 828 if (previous == null || p.latlon.greatCircleDistance(previous) > buffer_dist) { 829 // we add a buffer around the point. 830 r.setRect(p.latlon.lon()-buffer_x, p.latlon.lat()-buffer_y, 2*buffer_x, 2*buffer_y); 831 a.add(new Area(r)); 832 previous = p.latlon; 833 } 832 834 } 833 835 } … … 836 838 /* 837 839 * Area "a" now contains the hull that we would like to download data for. 838 * however we can only download rectangles, so the following is an attem t at840 * however we can only download rectangles, so the following is an attempt at 839 841 * finding a number of rectangles to download. 840 842 *
Note:
See TracChangeset
for help on using the changeset viewer.