Changeset 2327 in josm for trunk/src/org
- Timestamp:
- 2009-10-27T01:21:32+01:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 26 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/Main.java
r2322 r2327 41 41 import org.openstreetmap.josm.data.UndoRedoHandler; 42 42 import org.openstreetmap.josm.data.coor.CoordinateFormat; 43 import org.openstreetmap.josm.data.coor.LatLon; 43 44 import org.openstreetmap.josm.data.osm.DataSet; 44 45 import org.openstreetmap.josm.data.osm.PrimitiveDeepCopy; … … 423 424 //DownloadTask osmTask = main.menu.download.downloadTasks.get(0); 424 425 DownloadTask osmTask = new DownloadOsmTask(); 425 Future<?> future = osmTask.download(main.menu.download, b .min.lat(), b.min.lon(), b.max.lat(), b.max.lon(), null);426 Future<?> future = osmTask.download(main.menu.download, b, null); 426 427 Main.worker.submit(new PostDownloadHandler(osmTask, future)); 427 428 } … … 467 468 final StringTokenizer st = new StringTokenizer(s, ","); 468 469 if (st.countTokens() == 4) { 470 Bounds b = new Bounds( 471 new LatLon(Double.parseDouble(st.nextToken()),Double.parseDouble(st.nextToken())), 472 new LatLon(Double.parseDouble(st.nextToken()),Double.parseDouble(st.nextToken())) 473 ); 469 474 try { 470 475 DownloadTask task = rawGps ? new DownloadGpsTask() : new DownloadOsmTask(); 471 476 // asynchronously launch the download task ... 472 Future<?> future = task.download(main.menu.download, Double.parseDouble(st.nextToken()), Double.parseDouble(st.nextToken()), Double.parseDouble(st.nextToken()), Double.parseDouble(st.nextToken()), null);477 Future<?> future = task.download(main.menu.download, b, null); 473 478 // ... and the continuation when the download is finished (this will wait for the download to finish) 474 479 Main.worker.execute(new PostDownloadHandler(task, future)); -
trunk/src/org/openstreetmap/josm/actions/DownloadAction.java
r2323 r2327 2 2 package org.openstreetmap.josm.actions; 3 3 4 import static org.openstreetmap.josm.gui.help.HelpUtil.ht; 4 5 import static org.openstreetmap.josm.tools.I18n.tr; 5 import static org.openstreetmap.josm.gui.help.HelpUtil.ht;6 6 7 7 import java.awt.BorderLayout; … … 15 15 16 16 import org.openstreetmap.josm.Main; 17 import org.openstreetmap.josm.actions.downloadtasks.DownloadTask; 17 import org.openstreetmap.josm.actions.downloadtasks.DownloadGpsTask; 18 import org.openstreetmap.josm.actions.downloadtasks.DownloadOsmTask; 18 19 import org.openstreetmap.josm.actions.downloadtasks.PostDownloadHandler; 19 20 import org.openstreetmap.josm.gui.ExtendedDialog; … … 31 32 */ 32 33 public class DownloadAction extends JosmAction { 34 33 35 34 36 public DownloadDialog dialog; 37 private ExtendedDialog downloadDialog; 35 38 36 39 public DownloadAction() { … … 45 48 */ 46 49 protected ExtendedDialog createUploadDialog() { 47 dialog = new DownloadDialog(); 50 if (dialog == null) 51 dialog = new DownloadDialog(); 52 dialog.restoreSettings(); 48 53 JPanel downPanel = new JPanel(new BorderLayout()); 49 54 downPanel.add(dialog, BorderLayout.CENTER); … … 53 58 new Dimension(1000,600)); 54 59 55 ExtendedDialog dialog = new ExtendedDialog(Main.parent, 60 if (downloadDialog == null) { 61 downloadDialog= new ExtendedDialog(Main.parent, 56 62 tr("Download"), 57 63 new String[] {tr("OK"), tr("Cancel")}); 58 dialog.setContent(downPanel, false /* don't use a scroll pane inside the dialog */); 59 dialog.setButtonIcons(new String[] {"ok", "cancel"}); 60 dialog.setRememberWindowGeometry(prefName, wg); 61 return dialog; 64 downloadDialog.setContent(downPanel, false /* don't use a scroll pane inside the dialog */); 65 downloadDialog.setButtonIcons(new String[] {"ok", "cancel"}); 66 downloadDialog.setRememberWindowGeometry(prefName, wg); 67 } 68 return downloadDialog; 62 69 } 63 70 … … 65 72 ExtendedDialog dlg = createUploadDialog(); 66 73 boolean finish = false; 67 while (!finish) { 74 while (!finish) { 68 75 dlg.showDialog(); 69 Main.pref.put("download.newlayer", dialog.newLayer.isSelected());70 76 if (dlg.getValue() == 1 /* OK */) { 71 Main.pref.put("download.tab", Integer.toString(dialog.getSelectedTab())); 72 for (DownloadTask task : dialog.downloadTasks) { 73 Main.pref.put("download."+task.getPreferencesSuffix(), task.getCheckBox().isSelected()); 74 if (task.getCheckBox().isSelected()) { 75 // asynchronously launch the download task ... 76 Future<?> future = task.download(this, dialog.minlat, dialog.minlon, dialog.maxlat, dialog.maxlon, null); 77 // ... and the continuation when the download task is finished 78 Main.worker.submit(new PostDownloadHandler(task, future)); 79 finish = true; 80 } 77 dialog.rememberSettings(); 78 if (dialog.isDownloadOsmData()) { 79 DownloadOsmTask task = new DownloadOsmTask(); 80 Future<?> future = task.download(this, dialog.getSelectedDownloadArea(), null); 81 Main.worker.submit(new PostDownloadHandler(task, future)); 82 finish = true; 83 } 84 if (dialog.isDownloadGpxData()) { 85 DownloadGpsTask task = new DownloadGpsTask(); 86 Future<?> future = task.download(this,dialog.getSelectedDownloadArea(), null); 87 Main.worker.submit(new PostDownloadHandler(task, future)); 88 finish = true; 81 89 } 82 90 } else { -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadGpsTask.java
r2322 r2327 7 7 import java.util.concurrent.Future; 8 8 9 import javax.swing.JCheckBox;10 11 9 import org.openstreetmap.josm.Main; 12 10 import org.openstreetmap.josm.actions.DownloadAction; 11 import org.openstreetmap.josm.data.Bounds; 13 12 import org.openstreetmap.josm.data.gpx.GpxData; 14 13 import org.openstreetmap.josm.gui.PleaseWaitRunnable; … … 22 21 public class DownloadGpsTask extends AbstractDownloadTask { 23 22 24 private JCheckBox checkBox = new JCheckBox(tr("Raw GPS data"));25 23 private DownloadTask downloadTask; 26 24 27 public Future<?> download(DownloadAction action, double minlat, double minlon, 28 double maxlat, double maxlon, ProgressMonitor progressMonitor) { 29 downloadTask = new DownloadTask(action.dialog.newLayer.isSelected(), 30 new BoundingBoxDownloader(minlat, minlon, maxlat, maxlon), progressMonitor); 25 public Future<?> download(DownloadAction action, Bounds downloadArea, ProgressMonitor progressMonitor) { 26 downloadTask = new DownloadTask(action.dialog.isNewLayerRequired(), 27 new BoundingBoxDownloader(downloadArea), progressMonitor); 31 28 // We need submit instead of execute so we can wait for it to finish and get the error 32 29 // message if necessary. If no one calls getErrorMessage() it just behaves like execute. 33 30 return Main.worker.submit(downloadTask); 34 31 } 35 36 public JCheckBox getCheckBox() { 37 return checkBox; 38 } 39 40 public String getPreferencesSuffix() { 41 return "gps"; 42 } 43 32 44 33 public Future<?> loadUrl(boolean a,java.lang.String b, ProgressMonitor progressMonitor) { 45 34 return null; -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java
r2322 r2327 8 8 import java.util.concurrent.Future; 9 9 import java.util.logging.Logger; 10 11 import javax.swing.JCheckBox;12 10 13 11 import org.openstreetmap.josm.Main; … … 38 36 private DownloadTask downloadTask; 39 37 40 private JCheckBox checkBox = new JCheckBox(tr("OpenStreetMap data"), true);41 42 38 private void rememberDownloadedData(DataSet ds) { 43 39 this.downloadedData = ds; … … 48 44 } 49 45 50 public Future<?> download(DownloadAction action, double minlat, double minlon, 51 double maxlat, double maxlon, ProgressMonitor progressMonitor) { 52 // Swap min and max if user has specified them the wrong way round 53 // (easy to do if you are crossing 0, for example) 54 // FIXME should perhaps be done in download dialog? 55 if (minlat > maxlat) { 56 double t = minlat; minlat = maxlat; maxlat = t; 57 } 58 if (minlon > maxlon) { 59 double t = minlon; minlon = maxlon; maxlon = t; 60 } 61 46 public Future<?> download(DownloadAction action, Bounds downloadArea, ProgressMonitor progressMonitor) { 47 62 48 boolean newLayer = action != null 63 && (action.dialog == null || action.dialog. newLayer.isSelected());49 && (action.dialog == null || action.dialog.isNewLayerRequired()); 64 50 65 51 downloadTask = new DownloadTask(newLayer, 66 new BoundingBoxDownloader( minlat, minlon, maxlat, maxlon), progressMonitor);67 currentBounds = new Bounds( new LatLon(minlat, minlon), new LatLon(maxlat, maxlon));52 new BoundingBoxDownloader(downloadArea), progressMonitor); 53 currentBounds = new Bounds(downloadArea); 68 54 // We need submit instead of execute so we can wait for it to finish and get the error 69 55 // message if necessary. If no one calls getErrorMessage() it just behaves like execute. … … 82 68 currentBounds = new Bounds(new LatLon(0,0), new LatLon(0,0)); 83 69 return Main.worker.submit(downloadTask); 84 }85 86 public JCheckBox getCheckBox() {87 return checkBox;88 }89 90 public String getPreferencesSuffix() {91 return "osm";92 70 } 93 71 -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTaskList.java
r2325 r2327 21 21 import org.openstreetmap.josm.Main; 22 22 import org.openstreetmap.josm.actions.UpdateSelectionAction; 23 import org.openstreetmap.josm.data.Bounds; 23 24 import org.openstreetmap.josm.data.osm.DataSet; 24 25 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 65 66 childProgress.setSilent(true); 66 67 childProgress.setCustomText(tr("Download {0} of {1} ({2} left)", i, rects.size(), rects.size() - i)); 67 Future<?> future = dt.download(null, td.getMinY(), td.getMinX(), td.getMaxY(), td.getMaxX(), childProgress);68 Future<?> future = dt.download(null, new Bounds(td), childProgress); 68 69 osmTaskFutures.add(future); 69 70 osmTasks.add(dt); -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadTask.java
r2322 r2327 5 5 import java.util.concurrent.Future; 6 6 7 import javax.swing.JCheckBox;8 9 7 import org.openstreetmap.josm.actions.DownloadAction; 8 import org.openstreetmap.josm.data.Bounds; 10 9 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 11 10 … … 16 15 * if no error messages should be popped up. 17 16 */ 18 Future<?> download(DownloadAction action, double minlat, double minlon, 19 double maxlat, double maxlon, ProgressMonitor progressMonitor); 17 Future<?> download(DownloadAction action, Bounds downloadArea, ProgressMonitor progressMonitor); 20 18 21 19 /** … … 25 23 */ 26 24 Future<?> loadUrl(boolean newLayer, String url, ProgressMonitor progressMonitor); 27 28 /**29 * @return The checkbox presented to the user30 */31 JCheckBox getCheckBox();32 33 /**34 * @return The name of the preferences suffix to use for storing the35 * selection state.36 */37 String getPreferencesSuffix();38 25 39 26 /** -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/PostDownloadHandler.java
r2322 r2327 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.util.ArrayList; 6 7 import java.util.LinkedHashSet; 8 import java.util.List; 7 9 import java.util.concurrent.Future; 8 10 … … 16 18 public class PostDownloadHandler implements Runnable { 17 19 private DownloadTask task; 18 private Future<?> future;20 private List<Future<?>> futures; 19 21 20 22 /** … … 25 27 public PostDownloadHandler(DownloadTask task, Future<?> future) { 26 28 this.task = task; 27 this.future = future; 29 this.futures = new ArrayList<Future<?>>(); 30 if (future != null) { 31 this.futures.add(future); 32 } 28 33 } 29 34 35 /** 36 * constructor 37 * @param task the asynchronous download task 38 * @param future the future on which the completion of the download task can be synchronized 39 */ 40 public PostDownloadHandler(DownloadTask task, Future<?> ... futures) { 41 this.task = task; 42 this.futures = new ArrayList<Future<?>>(); 43 if (futures == null) return; 44 for (Future<?> future: futures) { 45 this.futures.add(future); 46 } 47 } 48 49 50 /** 51 * constructor 52 * @param task the asynchronous download task 53 * @param future the future on which the completion of the download task can be synchronized 54 */ 55 public PostDownloadHandler(DownloadTask task, List<Future<?>> futures) { 56 this.task = task; 57 this.futures = new ArrayList<Future<?>>(); 58 if (futures == null) return; 59 this.futures.addAll(futures); 60 } 61 30 62 public void run() { 31 // wait for the download task to complete 63 // wait for all downloads task to finish (by waiting for the futures 64 // to return a value) 32 65 // 33 try { 34 future.get(); 35 } catch(Exception e) { 36 e.printStackTrace(); 37 return; 66 for (Future<?> future: futures) { 67 try { 68 future.get(); 69 } catch(Exception e) { 70 e.printStackTrace(); 71 return; 72 } 38 73 } 39 74 -
trunk/src/org/openstreetmap/josm/data/Bounds.java
r2017 r2327 4 4 import java.awt.geom.Rectangle2D; 5 5 6 import org.openstreetmap.josm.Main; 6 7 import org.openstreetmap.josm.data.coor.LatLon; 8 import static org.openstreetmap.josm.tools.I18n.tr; 7 9 8 10 /** … … 16 18 * The minimum and maximum coordinates. 17 19 */ 18 public LatLon min, max; 20 private LatLon min, max; 21 22 public LatLon getMin() { 23 return min; 24 } 25 26 public LatLon getMax() { 27 return max; 28 } 19 29 20 30 /** … … 30 40 this.max = b; 31 41 } 42 43 public Bounds(double minlat, double minlon, double maxlat, double maxlon) { 44 this.min = new LatLon(minlat, minlon); 45 this.max = new LatLon(maxlat, maxlon); 46 } 47 48 public Bounds(double [] coords) { 49 if (coords == null) 50 throw new IllegalArgumentException(tr("Parameter ''{0}'' must not be null", "coords")); 51 if (coords.length != 4) 52 throw new IllegalArgumentException(tr("Expected array of length 4, got {0}", coords.length)); 53 this.min = new LatLon(coords[0], coords[1]); 54 this.max = new LatLon(coords[2], coords[3]); 55 } 56 57 public Bounds(String asString, String separator) throws IllegalArgumentException { 58 if (asString == null) 59 throw new IllegalArgumentException(tr("Parameter ''{0}'' must not be null", "asString")); 60 String[] components = asString.split(separator); 61 if (components.length != 4) { 62 throw new IllegalArgumentException(tr("Exactly four doubles excpected in string, got {0}", components.length)); 63 } 64 double[] values = new double[4]; 65 for (int i=0; i<4; i++) { 66 try { 67 values[i] = Double.parseDouble(components[i]); 68 } catch(NumberFormatException e) { 69 throw new IllegalArgumentException(tr("Illegal double value ''{0}''", components[i])); 70 } 71 } 72 this.min = new LatLon(values[0], values[1]); 73 this.max = new LatLon(values[2], values[3]); 74 } 75 76 public Bounds(Bounds other) { 77 this.min = new LatLon(other.min); 78 this.max = new LatLon(other.max); 79 } 32 80 81 public Bounds(Rectangle2D rect) { 82 this.min = new LatLon(rect.getMinY(), rect.getMinX()); 83 this.max = new LatLon(rect.getMaxY(), rect.getMaxX()); 84 } 85 33 86 @Override public String toString() { 34 87 return "Bounds["+min.lat()+","+min.lon()+","+max.lat()+","+max.lon()+"]"; … … 70 123 return new Rectangle2D.Double(min.lon(), min.lat(), max.lon()-min.lon(), max.lat()-min.lat()); 71 124 } 125 126 public double getArea() { 127 return (max.lon() - min.lon()) * (max.lat() - min.lat()); 128 } 129 130 public String encodeAsString(String separator) { 131 StringBuffer sb = new StringBuffer(); 132 sb.append(min.lat()).append(separator).append(min.lon()) 133 .append(separator).append(max.lat()).append(separator) 134 .append(max.lon()); 135 return sb.toString(); 136 } 137 138 @Override 139 public int hashCode() { 140 final int prime = 31; 141 int result = 1; 142 result = prime * result + ((max == null) ? 0 : max.hashCode()); 143 result = prime * result + ((min == null) ? 0 : min.hashCode()); 144 return result; 145 } 146 147 @Override 148 public boolean equals(Object obj) { 149 if (this == obj) 150 return true; 151 if (obj == null) 152 return false; 153 if (getClass() != obj.getClass()) 154 return false; 155 Bounds other = (Bounds) obj; 156 if (max == null) { 157 if (other.max != null) 158 return false; 159 } else if (!max.equals(other.max)) 160 return false; 161 if (min == null) { 162 if (other.min != null) 163 return false; 164 } else if (!min.equals(other.min)) 165 return false; 166 return true; 167 } 72 168 73 169 } -
trunk/src/org/openstreetmap/josm/data/Preferences.java
r2224 r2327 62 62 public String name; 63 63 public double[] latlon = new double[4]; // minlat, minlon, maxlat, maxlon 64 65 public Bookmark() { 66 } 67 68 public Bookmark(Bounds b) { 69 if (b == null) { 70 latlon[0] = 0.0; 71 latlon[1] = 0.0; 72 latlon[2] = 0.0; 73 latlon[3] = 0.0; 74 } else { 75 latlon[0] = b.getMin().lat(); 76 latlon[1] = b.getMin().lon(); 77 latlon[2] = b.getMax().lat(); 78 latlon[3] = b.getMax().lon(); 79 } 80 } 81 64 82 @Override public String toString() { 65 83 return name; 66 84 } 85 67 86 public int compareTo(Bookmark b) { 68 87 return name.toLowerCase().compareTo(b.name.toLowerCase()); 88 } 89 90 public Bounds asBounds() { 91 return new Bounds(latlon[0], latlon[1], latlon[2], latlon[3]); 69 92 } 70 93 } -
trunk/src/org/openstreetmap/josm/data/coor/Coordinate.java
r1169 r2327 45 45 } 46 46 47 @Override 48 public int hashCode() { 49 final int prime = 31; 50 int result = super.hashCode(); 51 long temp; 52 temp = java.lang.Double.doubleToLongBits(x); 53 result = prime * result + (int) (temp ^ (temp >>> 32)); 54 temp = java.lang.Double.doubleToLongBits(y); 55 result = prime * result + (int) (temp ^ (temp >>> 32)); 56 return result; 57 } 58 59 @Override 60 public boolean equals(Object obj) { 61 if (this == obj) 62 return true; 63 if (!super.equals(obj)) 64 return false; 65 if (getClass() != obj.getClass()) 66 return false; 67 Coordinate other = (Coordinate) obj; 68 if (java.lang.Double.doubleToLongBits(x) != java.lang.Double.doubleToLongBits(other.x)) 69 return false; 70 if (java.lang.Double.doubleToLongBits(y) != java.lang.Double.doubleToLongBits(other.y)) 71 return false; 72 return true; 73 } 47 74 } -
trunk/src/org/openstreetmap/josm/data/coor/LatLon.java
r2174 r2327 90 90 public boolean isOutSideWorld() { 91 91 Bounds b = Main.proj.getWorldBoundsLatLon(); 92 return lat() < b. min.lat() || lat() > b.max.lat() ||93 lon() < b. min.lon() || lon() > b.max.lon();92 return lat() < b.getMin().lat() || lat() > b.getMax().lat() || 93 lon() < b.getMin().lon() || lon() > b.getMax().lon(); 94 94 } 95 95 … … 98 98 */ 99 99 public boolean isWithin(Bounds b) { 100 return lat() >= b. min.lat() && lat() <= b.max.lat() && lon() > b.min.lon() && lon() < b.max.lon();100 return lat() >= b.getMin().lat() && lat() <= b.getMax().lat() && lon() > b.getMin().lon() && lon() < b.getMax().lon(); 101 101 } 102 102 -
trunk/src/org/openstreetmap/josm/data/osm/visitor/BoundingXYVisitor.java
r1946 r2327 45 45 if(b != null) 46 46 { 47 visit(b. min);48 visit(b. max);47 visit(b.getMin()); 48 visit(b.getMax()); 49 49 } 50 50 } -
trunk/src/org/openstreetmap/josm/gui/MapView.java
r2192 r2327 369 369 tempG.setColor(Color.WHITE); 370 370 Bounds b = getProjection().getWorldBoundsLatLon(); 371 double lat = b. min.lat();372 double lon = b. min.lon();373 374 Point p = getPoint(b. min);371 double lat = b.getMin().lat(); 372 double lon = b.getMin().lon(); 373 374 Point p = getPoint(b.getMin()); 375 375 376 376 GeneralPath path = new GeneralPath(); 377 377 378 378 path.moveTo(p.x, p.y); 379 double max = b. max.lat();379 double max = b.getMax().lat(); 380 380 for(; lat <= max; lat += 1.0) 381 381 { … … 383 383 path.lineTo(p.x, p.y); 384 384 } 385 lat = max; max = b. max.lon();385 lat = max; max = b.getMax().lon(); 386 386 for(; lon <= max; lon += 1.0) 387 387 { … … 389 389 path.lineTo(p.x, p.y); 390 390 } 391 lon = max; max = b. min.lat();391 lon = max; max = b.getMin().lat(); 392 392 for(; lat >= max; lat -= 1.0) 393 393 { … … 395 395 path.lineTo(p.x, p.y); 396 396 } 397 lat = max; max = b. min.lon();397 lat = max; max = b.getMin().lon(); 398 398 for(; lon >= max; lon -= 1.0) 399 399 { -
trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java
r2273 r2327 60 60 private EastNorth calculateDefaultCenter() { 61 61 Bounds b = Main.proj.getWorldBoundsLatLon(); 62 double lat = (b. max.lat() + b.min.lat())/2;63 double lon = (b. max.lon() + b.min.lon())/2;62 double lat = (b.getMax().lat() + b.getMin().lat())/2; 63 double lon = (b.getMax().lon() + b.getMin().lon())/2; 64 64 65 65 return Main.proj.latlon2eastNorth(new LatLon(lat, lon)); … … 128 128 public ProjectionBounds getMaxProjectionBounds() { 129 129 Bounds b = getProjection().getWorldBoundsLatLon(); 130 return new ProjectionBounds(getProjection().latlon2eastNorth(b. min),131 getProjection().latlon2eastNorth(b. max));130 return new ProjectionBounds(getProjection().latlon2eastNorth(b.getMin()), 131 getProjection().latlon2eastNorth(b.getMax())); 132 132 } 133 133 … … 193 193 double lat = cl.lat(); 194 194 double lon = cl.lon(); 195 if(lat < b. min.lat()) {changed = true; lat = b.min.lat(); }196 else if(lat > b. max.lat()) {changed = true; lat = b.max.lat(); }197 if(lon < b. min.lon()) {changed = true; lon = b.min.lon(); }198 else if(lon > b. max.lon()) {changed = true; lon = b.max.lon(); }195 if(lat < b.getMin().lat()) {changed = true; lat = b.getMin().lat(); } 196 else if(lat > b.getMax().lat()) {changed = true; lat = b.getMax().lat(); } 197 if(lon < b.getMin().lon()) {changed = true; lon = b.getMin().lon(); } 198 else if(lon > b.getMax().lon()) {changed = true; lon = b.getMax().lon(); } 199 199 if(changed) { 200 200 newCenter = new CachedLatLon(lat, lon).getEastNorth(); … … 209 209 int width = getWidth()/2; 210 210 int height = getHeight()/2; 211 LatLon l1 = new LatLon(b. min.lat(), lon);212 LatLon l2 = new LatLon(b. max.lat(), lon);211 LatLon l1 = new LatLon(b.getMin().lat(), lon); 212 LatLon l2 = new LatLon(b.getMax().lat(), lon); 213 213 EastNorth e1 = getProjection().latlon2eastNorth(l1); 214 214 EastNorth e2 = getProjection().latlon2eastNorth(l2); … … 217 217 { 218 218 double newScaleH = d/height; 219 e1 = getProjection().latlon2eastNorth(new LatLon(lat, b. min.lon()));220 e2 = getProjection().latlon2eastNorth(new LatLon(lat, b. max.lon()));219 e1 = getProjection().latlon2eastNorth(new LatLon(lat, b.getMin().lon())); 220 e2 = getProjection().latlon2eastNorth(new LatLon(lat, b.getMax().lon())); 221 221 d = e2.east() - e1.east(); 222 222 if(d < width*newScale) { … … 292 292 293 293 public void zoomTo(Bounds box) { 294 zoomTo(new ProjectionBounds(getProjection().latlon2eastNorth(box. min),295 getProjection().latlon2eastNorth(box. max)));294 zoomTo(new ProjectionBounds(getProjection().latlon2eastNorth(box.getMin()), 295 getProjection().latlon2eastNorth(box.getMax()))); 296 296 } 297 297 -
trunk/src/org/openstreetmap/josm/gui/download/BookmarkSelection.java
r2142 r2327 8 8 import java.awt.event.ActionEvent; 9 9 import java.awt.event.ActionListener; 10 import java.awt.event.MouseAdapter;11 import java.awt.event.MouseEvent;12 import java.awt.event.MouseListener;13 10 14 11 import javax.swing.DefaultListModel; … … 42 39 43 40 JPanel dlg = new JPanel(new GridBagLayout()); 44 gui. tabpane.addTab(tr("Bookmarks"), dlg);41 gui.addDownloadAreaSelector(dlg, tr("Bookmarks")); 45 42 46 43 bookmarks = new BookmarkList(); … … 49 46 Preferences.Bookmark b = (Preferences.Bookmark)bookmarks.getSelectedValue(); 50 47 if (b != null) { 51 gui.minlat = b.latlon[0]; 52 gui.minlon = b.latlon[1]; 53 gui.maxlat = b.latlon[2]; 54 gui.maxlon = b.latlon[3]; 55 gui.boundingBoxChanged(BookmarkSelection.this); 48 gui.boundingBoxChanged(b.asBounds(),BookmarkSelection.this); 56 49 } 57 50 } … … 108 101 109 102 public void boundingBoxChanged(DownloadDialog gui) { 110 tempBookmark = new Preferences.Bookmark(); 111 tempBookmark.latlon[0] = gui.minlat; 112 tempBookmark.latlon[1] = gui.minlon; 113 tempBookmark.latlon[2] = gui.maxlat; 114 tempBookmark.latlon[3] = gui.maxlon; 103 tempBookmark = new Preferences.Bookmark(gui.getSelectedDownloadArea()); 115 104 bookmarks.clearSelection(); 116 105 } -
trunk/src/org/openstreetmap/josm/gui/download/BoundingBoxSelection.java
r2142 r2327 9 9 import java.awt.event.FocusEvent; 10 10 import java.awt.event.FocusListener; 11 import java.awt.event.KeyEvent;12 import java.awt.event.KeyListener;13 11 14 12 import javax.swing.JLabel; … … 56 54 double maxlat = Double.parseDouble(latlon[2].getText()); 57 55 double maxlon = Double.parseDouble(latlon[3].getText()); 58 if (minlat != gui.minlat || minlon != gui.minlon || maxlat != gui.maxlat || maxlon != gui.maxlon) {59 gui.minlat = minlat; gui.minlon = minlon;60 gui.maxlat = maxlat; gui.maxlon = maxlon;61 gui.boundingBoxChanged( BoundingBoxSelection.this);56 Bounds b = new Bounds(minlat,minlon, maxlat,maxlon); 57 if (gui.getSelectedDownloadArea() == null) return; 58 if (gui.getSelectedDownloadArea() == null || !gui.getSelectedDownloadArea().equals(new Bounds(minlat,minlon, maxlat,maxlon))) { 59 gui.boundingBoxChanged(b, BoundingBoxSelection.this); 62 60 } 63 61 } catch (NumberFormatException x) { … … 119 117 }); 120 118 121 gui. tabpane.addTab(tr("Bounding Box"), dlg);119 gui.addDownloadAreaSelector(dlg, tr("Bounding Box")); 122 120 } 123 121 … … 132 130 private boolean parseURL(DownloadDialog gui) { 133 131 Bounds b = OsmUrlToBounds.parse(osmUrl.getText()); 134 if(b == null) return false; 135 gui.minlon = b.min.lon(); 136 gui.minlat = b.min.lat(); 137 gui.maxlon = b.max.lon(); 138 gui.maxlat = b.max.lat(); 139 gui.boundingBoxChanged(BoundingBoxSelection.this); 132 if(b == null) return false; 133 gui.boundingBoxChanged(b,BoundingBoxSelection.this); 140 134 updateBboxFields(gui); 141 135 updateUrl(gui); … … 144 138 145 139 private void updateBboxFields(DownloadDialog gui) { 146 latlon[0].setText(Double.toString(gui.minlat)); 147 latlon[1].setText(Double.toString(gui.minlon)); 148 latlon[2].setText(Double.toString(gui.maxlat)); 149 latlon[3].setText(Double.toString(gui.maxlon)); 140 Bounds b = gui.getSelectedDownloadArea(); 141 if (b == null) return; 142 latlon[0].setText(Double.toString(b.getMin().lat())); 143 latlon[1].setText(Double.toString(b.getMin().lon())); 144 latlon[2].setText(Double.toString(b.getMax().lat())); 145 latlon[3].setText(Double.toString(b.getMax().lon())); 150 146 for (JTextField f : latlon) { 151 147 f.setCaretPosition(0); … … 154 150 155 151 private void updateUrl(DownloadDialog gui) { 156 showUrl.setText(OsmUrlToBounds.getURL(new Bounds(157 new LatLon(gui.minlat, gui.minlon), new LatLon(gui.maxlat, gui.maxlon))));152 if (gui.getSelectedDownloadArea() == null) return; 153 showUrl.setText(OsmUrlToBounds.getURL(gui.getSelectedDownloadArea())); 158 154 } 159 155 } -
trunk/src/org/openstreetmap/josm/gui/download/DownloadDialog.java
r2322 r2327 15 15 import java.util.ArrayList; 16 16 import java.util.List; 17 import java.util.logging.Logger; 17 18 18 19 import javax.swing.AbstractAction; … … 24 25 25 26 import org.openstreetmap.josm.Main; 26 import org.openstreetmap.josm.actions.DownloadAction;27 import org.openstreetmap.josm.actions.downloadtasks.DownloadGpsTask;28 import org.openstreetmap.josm.actions.downloadtasks.DownloadOsmTask;29 import org.openstreetmap.josm.actions.downloadtasks.DownloadTask;30 27 import org.openstreetmap.josm.data.Bounds; 31 28 import org.openstreetmap.josm.gui.MapView; 32 import org.openstreetmap.josm.gui.progress.ProgressMonitor;33 29 import org.openstreetmap.josm.plugins.PluginHandler; 34 30 import org.openstreetmap.josm.tools.GBC; … … 46 42 */ 47 43 public class DownloadDialog extends JPanel { 48 49 /** 50 * The list of download tasks. First entry should be the osm data entry 51 * and the second the gps entry. After that, plugins can register additional 52 * download possibilities. 53 */ 54 public final List<DownloadTask> downloadTasks = new ArrayList<DownloadTask>(5); 55 56 public final List<DownloadSelection> downloadSelections = new ArrayList<DownloadSelection>(); 57 public final JTabbedPane tabpane = new JTabbedPane(); 58 public final JCheckBox newLayer; 59 public final JLabel sizeCheck = new JLabel(); 60 61 public double minlon; 62 public double minlat; 63 public double maxlon; 64 public double maxlat; 44 static private final Logger logger = Logger.getLogger(DownloadDialog.class.getName()); 45 46 private final List<DownloadSelection> downloadSelections = new ArrayList<DownloadSelection>(); 47 private final JTabbedPane tpDownloadAreaSelectors = new JTabbedPane(); 48 private final JCheckBox cbNewLayer; 49 private final JLabel sizeCheck = new JLabel(); 50 51 private Bounds currentBounds = null; 52 53 private JCheckBox cbDownloadOsmData = new JCheckBox(tr("OpenStreetMap data"), true); 54 private JCheckBox cbDownloadGpxData = new JCheckBox(tr("Raw GPS data")); 65 55 66 56 … … 68 58 setLayout(new GridBagLayout()); 69 59 70 downloadTasks.add(new DownloadOsmTask());71 downloadTasks.add(new DownloadGpsTask());72 73 60 // adding the download tasks 74 61 add(new JLabel(tr("Data Sources and Types")), GBC.eol().insets(0,5,0,0)); 75 for (DownloadTask task : downloadTasks) { 76 add(task.getCheckBox(), GBC.eol().insets(20,0,0,0)); 77 // don't override defaults, if we (initially) don't have any preferences 78 if(Main.pref.hasKey("download."+task.getPreferencesSuffix())) { 79 task.getCheckBox().setSelected(Main.pref.getBoolean("download."+task.getPreferencesSuffix())); 80 } 81 } 82 62 add(cbDownloadOsmData, GBC.eol().insets(20,0,0,0)); 63 add(cbDownloadGpxData, GBC.eol().insets(20,0,0,0)); 64 83 65 // predefined download selections 84 66 downloadSelections.add(new SlippyMapChooser()); … … 97 79 s.addGui(this); 98 80 } 99 100 if (Main.map != null) { 101 MapView mv = Main.map.mapView; 102 minlon = mv.getLatLon(0, mv.getHeight()).lon(); 103 minlat = mv.getLatLon(0, mv.getHeight()).lat(); 104 maxlon = mv.getLatLon(mv.getWidth(), 0).lon(); 105 maxlat = mv.getLatLon(mv.getWidth(), 0).lat(); 106 boundingBoxChanged(null); 107 } 108 else if (Main.pref.hasKey("osm-download.bounds")) { 109 // read the bounding box from the preferences 110 try { 111 String bounds[] = Main.pref.get("osm-download.bounds").split(";"); 112 minlat = Double.parseDouble(bounds[0]); 113 minlon = Double.parseDouble(bounds[1]); 114 maxlat = Double.parseDouble(bounds[2]); 115 maxlon = Double.parseDouble(bounds[3]); 116 boundingBoxChanged(null); 117 } 118 catch (Exception e) { 119 e.printStackTrace(); 120 } 121 } 122 123 newLayer = new JCheckBox(tr("Download as new layer"), Main.pref.getBoolean("download.newlayer", false)); 124 add(newLayer, GBC.eol().insets(0,5,0,0)); 81 82 cbNewLayer = new JCheckBox(tr("Download as new layer")); 83 add(cbNewLayer, GBC.eol().insets(0,5,0,0)); 125 84 126 85 add(new JLabel(tr("Download Area")), GBC.eol().insets(0,5,0,0)); 127 add(t abpane, GBC.eol().fill());86 add(tpDownloadAreaSelectors, GBC.eol().fill()); 128 87 129 88 try { 130 t abpane.setSelectedIndex(Main.pref.getInteger("download.tab", 0));89 tpDownloadAreaSelectors.setSelectedIndex(Main.pref.getInteger("download.tab", 0)); 131 90 } catch (Exception ex) { 132 91 Main.pref.putInteger("download.tab", 0); … … 145 104 } 146 105 }); 106 107 restoreSettings(); 147 108 } 148 109 … … 163 124 Bounds b = OsmUrlToBounds.parse(result); 164 125 if (b != null) { 165 minlon = b.min.lon(); 166 minlat = b.min.lat(); 167 maxlon = b.max.lon(); 168 maxlat = b.max.lat(); 169 boundingBoxChanged(null); 126 boundingBoxChanged(new Bounds(b),null); 170 127 } 171 128 } 172 129 173 130 private void updateSizeCheck() { 174 if ((maxlon-minlon)*(maxlat-minlat) > Main.pref.getDouble("osm-server.max-request-area", 0.25)) { 131 if (currentBounds == null) { 132 sizeCheck.setText(tr("No area selected yet")); 133 sizeCheck.setForeground(Color.darkGray); 134 } else if (currentBounds.getArea() > Main.pref.getDouble("osm-server.max-request-area", 0.25)) { 175 135 sizeCheck.setText(tr("Download area too large; will probably be rejected by server")); 176 136 sizeCheck.setForeground(Color.red); … … 188 148 * @param eventSource - the DownloadSelection object that fired this notification. 189 149 */ 190 public void boundingBoxChanged(DownloadSelection eventSource) { 150 public void boundingBoxChanged(Bounds b, DownloadSelection eventSource) { 151 this.currentBounds = b; 191 152 for (DownloadSelection s : downloadSelections) { 192 153 if (s != eventSource) { … … 196 157 updateSizeCheck(); 197 158 } 198 199 /* 200 * Returns currently selected tab. 201 */ 202 public int getSelectedTab() { 203 return tabpane.getSelectedIndex(); 204 } 159 160 /** 161 * Replies true if the user selected to download OSM data 162 * 163 * @return true if the user selected to download OSM data 164 */ 165 public boolean isDownloadOsmData() { 166 return cbDownloadOsmData.isSelected(); 167 } 168 169 /** 170 * Replies true if the user selected to download GPX data 171 * 172 * @return true if the user selected to download GPX data 173 */ 174 public boolean isDownloadGpxData() { 175 return cbDownloadGpxData.isSelected(); 176 } 177 178 /** 179 * Replies true if the user requires to download into a new layer 180 * 181 * @return true if the user requires to download into a new layer 182 */ 183 public boolean isNewLayerRequired() { 184 return cbNewLayer.isSelected(); 185 } 186 187 /** 188 * Adds a new download area selector to the download dialog 189 * 190 * @param selector the download are selector 191 * @param displayName the display name of the selector 192 */ 193 public void addDownloadAreaSelector(JPanel selector, String displayName) { 194 tpDownloadAreaSelectors.add(displayName, selector); 195 } 196 197 /** 198 * Remembers the current settings in the download dialog 199 * 200 */ 201 public void rememberSettings() { 202 Main.pref.put("download.tab", Integer.toString(tpDownloadAreaSelectors.getSelectedIndex())); 203 Main.pref.put("download.osm", cbDownloadOsmData.isSelected()); 204 Main.pref.put("download.gps", cbDownloadGpxData.isSelected()); 205 Main.pref.put("download.newlayer", cbNewLayer.isSelected()); 206 if (currentBounds != null) { 207 Main.pref.put("osm-download.bounds", currentBounds.encodeAsString(";")); 208 } 209 } 210 211 public void restoreSettings() { 212 cbDownloadOsmData.setSelected(Main.pref.getBoolean("download.osm", true)); 213 cbDownloadGpxData.setSelected(Main.pref.getBoolean("download.gps", false)); 214 cbNewLayer.setSelected(Main.pref.getBoolean("download.newlayer", false)); 215 int idx = Main.pref.getInteger("download.tab", 0); 216 if (idx < 0 || idx > tpDownloadAreaSelectors.getTabCount()) { 217 idx = 0; 218 } 219 tpDownloadAreaSelectors.setSelectedIndex(idx); 220 221 if (Main.map != null) { 222 MapView mv = Main.map.mapView; 223 currentBounds = new Bounds( 224 mv.getLatLon(0, mv.getHeight()), 225 mv.getLatLon(mv.getWidth(), 0) 226 ); 227 boundingBoxChanged(currentBounds,null); 228 } 229 else if (Main.pref.hasKey("osm-download.bounds")) { 230 // read the bounding box from the preferences 231 try { 232 currentBounds = new Bounds(Main.pref.get("osm-download.bounds"), ";"); 233 boundingBoxChanged(currentBounds,null); 234 } 235 catch (Exception e) { 236 e.printStackTrace(); 237 } 238 } 239 } 240 241 /** 242 * Replies the currently selected download area. May be null, if no download area is selected 243 * yet. 244 */ 245 public Bounds getSelectedDownloadArea() { 246 return currentBounds; 247 } 248 205 249 } -
trunk/src/org/openstreetmap/josm/gui/download/PlaceSelection.java
r2017 r2327 32 32 33 33 import org.openstreetmap.josm.Main; 34 import org.openstreetmap.josm.data.Bounds; 35 import org.openstreetmap.josm.data.coor.LatLon; 34 36 import org.openstreetmap.josm.tools.GBC; 35 37 import org.xml.sax.Attributes; … … 224 226 scrollPane.setPreferredSize(new Dimension(200,200)); 225 227 panel.add(scrollPane, c); 226 gui. tabpane.add(panel, tr("Places"));228 gui.addDownloadAreaSelector(panel, tr("Places")); 227 229 228 230 scrollPane.setPreferredSize(scrollPane.getPreferredSize()); … … 298 300 { 299 301 double size = 180.0 / Math.pow(2, r.zoom); 300 gui.minlat = r.lat - size / 2; 301 gui.maxlat = r.lat + size / 2; 302 gui.minlon = r.lon - size; 303 gui.maxlon = r.lon + size; 302 Bounds b = new Bounds( 303 new LatLon( 304 r.lat - size / 2, 305 r.lat + size / 2 306 ), 307 new LatLon( 308 r.lon - size, 309 r.lon + size 310 ) 311 ); 304 312 updatingSelf = true; 305 gui.boundingBoxChanged( null);313 gui.boundingBoxChanged(b,null); 306 314 updatingSelf = false; 307 315 } -
trunk/src/org/openstreetmap/josm/gui/download/SlippyMapChooser.java
r2093 r2327 30 30 import org.openstreetmap.gui.jmapviewer.interfaces.TileSource; 31 31 import org.openstreetmap.josm.Main; 32 import org.openstreetmap.josm.data.Bounds; 33 import org.openstreetmap.josm.data.coor.LatLon; 32 34 33 35 /** … … 120 122 String labelText = tr("<b>Zoom:</b> Mousewheel, double click or Ctrl + Up/Down " 121 123 + "<b>Move map:</b> Hold right mousebutton and move mouse or use cursor keys. <b>Select:</b> Hold left mousebutton and draw a frame."); 122 slipyyMapTabPanel.add(new JLabel("<html>" + labelText + "</html>"), BorderLayout.SOUTH); 123 iGui. tabpane.add(slipyyMapTabPanel, tr("Slippy map"));124 slipyyMapTabPanel.add(new JLabel("<html>" + labelText + "</html>"), BorderLayout.SOUTH); 125 iGui.addDownloadAreaSelector(slipyyMapTabPanel, tr("Slippy map")); 124 126 new OsmMapControl(this, slipyyMapTabPanel, iSizeButton, iSourceButton); 125 127 } … … 165 167 166 168 public void boundingBoxChanged(DownloadDialog gui) { 167 169 Bounds b = gui.getSelectedDownloadArea(); 170 if (b == null) 171 return; 172 168 173 // test if a bounding box has been set set 169 if ( gui.minlat == 0.0 && gui.minlon == 0.0 && gui.maxlat == 0.0 && gui.maxlon== 0.0)174 if (b.getMin().lat() == 0.0 && b.getMin().lon() == 0.0 && b.getMax().lat() == 0.0 && b.getMax().lon() == 0.0) 170 175 return; 171 176 172 int y1 = OsmMercator.LatToY( gui.minlat, MAX_ZOOM);173 int y2 = OsmMercator.LatToY( gui.maxlat, MAX_ZOOM);174 int x1 = OsmMercator.LonToX( gui.minlon, MAX_ZOOM);175 int x2 = OsmMercator.LonToX( gui.maxlon, MAX_ZOOM);177 int y1 = OsmMercator.LatToY(b.getMin().lat(), MAX_ZOOM); 178 int y2 = OsmMercator.LatToY(b.getMax().lat(), MAX_ZOOM); 179 int x1 = OsmMercator.LonToX(b.getMin().lon(), MAX_ZOOM); 180 int x2 = OsmMercator.LonToX(b.getMax().lon(), MAX_ZOOM); 176 181 177 182 iSelectionRectStart = new Point(Math.min(x1, x2), Math.min(y1, y2)); … … 179 184 180 185 // calc the screen coordinates for the new selection rectangle 181 MapMarkerDot xmin_ymin = new MapMarkerDot( gui.minlat, gui.minlon);182 MapMarkerDot xmax_ymax = new MapMarkerDot( gui.maxlat, gui.maxlon);186 MapMarkerDot xmin_ymin = new MapMarkerDot(b.getMin()); 187 MapMarkerDot xmax_ymax = new MapMarkerDot(b.getMax()); 183 188 184 189 Vector<MapMarker> marker = new Vector<MapMarker>(2); … … 218 223 Coordinate l1 = getPosition(p_max); 219 224 Coordinate l2 = getPosition(p_min); 220 iGui.minlon = Math.min(l2.getLon(), l1.getLon()); 221 iGui.minlat = Math.min(l1.getLat(), l2.getLat()); 222 iGui.maxlon = Math.max(l2.getLon(), l1.getLon()); 223 iGui.maxlat = Math.max(l1.getLat(), l2.getLat()); 224 225 iGui.boundingBoxChanged(this); 225 Bounds b = new Bounds( 226 new LatLon( 227 Math.min(l2.getLat(), l1.getLat()), 228 Math.min(l1.getLon(), l2.getLon()) 229 ), 230 new LatLon( 231 Math.max(l2.getLat(), l1.getLat()), 232 Math.max(l1.getLon(), l2.getLon())) 233 ); 234 iGui.boundingBoxChanged(b, this); 226 235 repaint(); 227 236 } -
trunk/src/org/openstreetmap/josm/gui/download/TileSelection.java
r1169 r2327 16 16 import javax.swing.SpinnerNumberModel; 17 17 18 import org.openstreetmap.josm.data.Bounds; 19 import org.openstreetmap.josm.data.coor.LatLon; 18 20 import org.openstreetmap.josm.tools.GBC; 19 21 /** … … 65 67 if (toy<fromy) { int i = fromy; fromy=toy; toy=i; } 66 68 67 gui.minlat = tileYToLat(zoomlvl, toy+1);68 gui.minlon = tileXToLon(zoomlvl, fromx);69 gui.maxlat = tileYToLat(zoomlvl, fromy);70 gui.maxlon = tileXToLon(zoomlvl, tox+1);71 gui.boundingBoxChanged( TileSelection.this);69 Bounds b = new Bounds( 70 new LatLon(tileYToLat(zoomlvl, toy + 1), tileXToLon(zoomlvl, fromx)), 71 new LatLon(tileYToLat(zoomlvl, fromy), tileXToLon(zoomlvl, tox + 1)) 72 ); 73 gui.boundingBoxChanged(b, TileSelection.this); 72 74 //repaint(); 73 75 } catch (NumberFormatException x) { … … 82 84 } 83 85 84 gui. tabpane.addTab(tr("Tile Numbers"), smpanel);86 gui.addDownloadAreaSelector(smpanel, tr("Tile Numbers")); 85 87 } 86 88 … … 94 96 private void updateBboxFields(DownloadDialog gui) { 95 97 int z = ((Integer) tileZ.getValue()).intValue(); 96 tileX0.setText(Integer.toString(lonToTileX(z, gui.minlon))); 97 tileX1.setText(Integer.toString(lonToTileX(z, gui.maxlon-.00001))); 98 tileY0.setText(Integer.toString(latToTileY(z, gui.maxlat-.00001))); 99 tileY1.setText(Integer.toString(latToTileY(z, gui.minlat))); 98 Bounds b = gui.getSelectedDownloadArea(); 99 if (b == null) 100 return; 101 tileX0.setText(Integer.toString(lonToTileX(z, b.getMin().lon()))); 102 tileX1.setText(Integer.toString(lonToTileX(z, b.getMax().lon()-.00001))); 103 tileY0.setText(Integer.toString(latToTileY(z, b.getMax().lat()-.00001))); 104 tileY1.setText(Integer.toString(latToTileY(z, b.getMin().lat()))); 100 105 } 101 106 -
trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
r2325 r2327 226 226 // now succesively subtract downloaded areas 227 227 for (DataSource src : data.dataSources) { 228 if (src.bounds != null && !src.bounds. min.equals(src.bounds.max)) {229 EastNorth en1 = mv.getProjection().latlon2eastNorth(src.bounds. min);230 EastNorth en2 = mv.getProjection().latlon2eastNorth(src.bounds. max);228 if (src.bounds != null && !src.bounds.getMin().equals(src.bounds.getMax())) { 229 EastNorth en1 = mv.getProjection().latlon2eastNorth(src.bounds.getMin()); 230 EastNorth en2 = mv.getProjection().latlon2eastNorth(src.bounds.getMax()); 231 231 Point p1 = mv.getPoint(en1); 232 232 Point p2 = mv.getPoint(en2); -
trunk/src/org/openstreetmap/josm/gui/preferences/ProjectionPreference.java
r2272 r2327 97 97 Bounds b = Main.proj.getWorldBoundsLatLon(); 98 98 CoordinateFormat cf = CoordinateFormat.getDefaultFormat(); 99 bounds.setText(b. min.latToString(cf)+"; "+b.min.lonToString(cf)+" : "+b.max.latToString(cf)+"; "+b.max.lonToString(cf));99 bounds.setText(b.getMin().latToString(cf)+"; "+b.getMin().lonToString(cf)+" : "+b.getMax().latToString(cf)+"; "+b.getMax().lonToString(cf)); 100 100 /* TODO: Fix bugs, refresh code line and world bounds, fix design (e.g. add border around sub-prefs-stuff */ 101 101 } -
trunk/src/org/openstreetmap/josm/io/BoundingBoxDownloader.java
r2181 r2327 7 7 import java.io.InputStream; 8 8 9 import org.openstreetmap.josm. Main;9 import org.openstreetmap.josm.data.Bounds; 10 10 import org.openstreetmap.josm.data.gpx.GpxData; 11 11 import org.openstreetmap.josm.data.osm.DataSet; … … 24 24 private final double lon2; 25 25 26 public BoundingBoxDownloader(double lat1, double lon1, double lat2, double lon2) { 27 this.lat1 = lat1; 28 this.lon1 = lon1; 29 this.lat2 = lat2; 30 this.lon2 = lon2; 31 // store the bounding box in the preferences so it can be 32 // re-used across invocations of josm 33 Main.pref.put("osm-download.bounds", lat1+";"+lon1+";"+lat2+";"+lon2); 26 public BoundingBoxDownloader(Bounds downloadArea) { 27 this.lat1 = downloadArea.getMin().lat(); 28 this.lon1 = downloadArea.getMin().lon(); 29 this.lat2 = downloadArea.getMax().lat(); 30 this.lon2 = downloadArea.getMax().lon(); 34 31 } 35 32 … … 44 41 try { 45 42 progressMonitor.indeterminateSubTask(tr("Contacting OSM Server...")); 46 String url = "trackpoints?bbox="+lon1+","+lat1+","+lon2+","+lat2+"&page="; 43 String url = "trackpoints?bbox="+lon1+","+lat1+","+lon2+","+lat2+"&page="; 47 44 48 45 boolean done = false; -
trunk/src/org/openstreetmap/josm/io/GpxWriter.java
r1975 r2327 127 127 if(bounds != null) 128 128 { 129 String b = "minlat=\"" + bounds. min.lat() + "\" minlon=\"" + bounds.min.lon() +130 "\" maxlat=\"" + bounds. max.lat() + "\" maxlon=\"" + bounds.max.lon() + "\"" ;129 String b = "minlat=\"" + bounds.getMin().lat() + "\" minlon=\"" + bounds.getMin().lon() + 130 "\" maxlat=\"" + bounds.getMax().lat() + "\" maxlon=\"" + bounds.getMax().lon() + "\"" ; 131 131 inline("bounds", b); 132 132 } -
trunk/src/org/openstreetmap/josm/io/OsmWriter.java
r2291 r2327 93 93 for (DataSource s : ds.dataSources) { 94 94 out.println(" <bounds minlat='" 95 + s.bounds. min.lat()+"' minlon='"96 + s.bounds. min.lon()+"' maxlat='"97 + s.bounds. max.lat()+"' maxlon='"98 + s.bounds. max.lon()95 + s.bounds.getMin().lat()+"' minlon='" 96 + s.bounds.getMin().lon()+"' maxlat='" 97 + s.bounds.getMax().lat()+"' maxlon='" 98 + s.bounds.getMax().lon() 99 99 +"' origin='"+XmlWriter.encode(s.origin)+"' />"); 100 100 } -
trunk/src/org/openstreetmap/josm/tools/OsmUrlToBounds.java
r1797 r2327 59 59 static public int getZoom(Bounds b) { 60 60 // convert to mercator (for calculation of zoom only) 61 double latMin = Math.log(Math.tan(Math.PI/4.0+b. min.lat()/180.0*Math.PI/2.0))*180.0/Math.PI;62 double latMax = Math.log(Math.tan(Math.PI/4.0+b. max.lat()/180.0*Math.PI/2.0))*180.0/Math.PI;63 double size = Math.max(Math.abs(latMax-latMin), Math.abs(b. max.lon()-b.min.lon()));61 double latMin = Math.log(Math.tan(Math.PI/4.0+b.getMin().lat()/180.0*Math.PI/2.0))*180.0/Math.PI; 62 double latMax = Math.log(Math.tan(Math.PI/4.0+b.getMax().lat()/180.0*Math.PI/2.0))*180.0/Math.PI; 63 double size = Math.max(Math.abs(latMax-latMin), Math.abs(b.getMax().lon()-b.getMin().lon())); 64 64 int zoom = 0; 65 65 while (zoom <= 20) {
Note:
See TracChangeset
for help on using the changeset viewer.