- Timestamp:
- 2015-10-22T14:01:47+02:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java
r8908 r8927 47 47 48 48 protected String newLayerName; 49 50 /** This allows subclasses to ignore this warning */ 51 protected boolean warnAboutEmptyArea = true; 49 52 50 53 @Override … … 123 126 /** 124 127 * This allows subclasses to perform operations on the URL before {@link #loadUrl} is performed. 128 * @param url the original URL 129 * @return the modified URL 125 130 */ 126 131 protected String modifyUrlBeforeLoad(String url) { … … 130 135 /** 131 136 * Loads a given URL from the OSM Server 132 * @param new _layer True if the data should be saved to a new layer137 * @param newLayer True if the data should be saved to a new layer 133 138 * @param url The URL as String 134 139 */ 135 140 @Override 136 public Future<?> loadUrl(boolean new _layer, String url, ProgressMonitor progressMonitor) {137 url = modifyUrlBeforeLoad(url);138 downloadTask = new DownloadTask(new _layer,139 new OsmServerLocationReader( url),141 public Future<?> loadUrl(boolean newLayer, String url, ProgressMonitor progressMonitor) { 142 String newUrl = modifyUrlBeforeLoad(url); 143 downloadTask = new DownloadTask(newLayer, 144 new OsmServerLocationReader(newUrl), 140 145 progressMonitor); 141 146 currentBounds = null; 142 147 // Extract .osm filename from URL to set the new layer name 143 extractOsmFilename("https?://.*/(.*\\.osm)", url);148 extractOsmFilename("https?://.*/(.*\\.osm)", newUrl); 144 149 return Main.worker.submit(downloadTask); 145 150 } … … 169 174 170 175 protected final boolean newLayer; 176 protected final boolean zoomAfterDownload; 171 177 protected DataSet dataSet; 172 178 … … 179 185 * exception will be thrown directly in EDT. When this runnable is executed using executor framework 180 186 * then use false unless you read result of task (because exception will get lost if you don't) 187 * @param zoomAfterDownload If true, the map view will zoom to download area after download 181 188 */ 182 public AbstractInternalTask(boolean newLayer, String title, boolean ignoreException ) {189 public AbstractInternalTask(boolean newLayer, String title, boolean ignoreException, boolean zoomAfterDownload) { 183 190 super(title, ignoreException); 184 191 this.newLayer = newLayer; 192 this.zoomAfterDownload = zoomAfterDownload; 185 193 } 186 194 … … 194 202 * exception will be thrown directly in EDT. When this runnable is executed using executor framework 195 203 * then use false unless you read result of task (because exception will get lost if you don't) 204 * @param zoomAfterDownload If true, the map view will zoom to download area after download 196 205 */ 197 public AbstractInternalTask(boolean newLayer, String title, ProgressMonitor progressMonitor, boolean ignoreException) { 206 public AbstractInternalTask(boolean newLayer, String title, ProgressMonitor progressMonitor, boolean ignoreException, 207 boolean zoomAfterDownload) { 198 208 super(title, progressMonitor, ignoreException); 199 209 this.newLayer = newLayer; 210 this.zoomAfterDownload = zoomAfterDownload; 200 211 } 201 212 … … 206 217 207 218 protected int getNumDataLayers() { 219 if (!Main.isDisplayingMapView()) return 0; 208 220 int count = 0; 209 if (!Main.isDisplayingMapView()) return 0;210 221 Collection<Layer> layers = Main.map.mapView.getAllLayers(); 211 222 for (Layer layer : layers) { … … 276 287 } 277 288 layer.mergeFrom(dataSet); 278 computeBboxAndCenterScale(bounds); 289 if (zoomAfterDownload) { 290 computeBboxAndCenterScale(bounds); 291 } 279 292 layer.onPostDownloadFromServer(); 280 293 } … … 285 298 protected final OsmServerReader reader; 286 299 300 /** 301 * Constructs a new {@code DownloadTask}. 302 * @param newLayer if {@code true}, force download to a new layer 303 * @param reader OSM data reader 304 * @param progressMonitor progress monitor 305 */ 287 306 public DownloadTask(boolean newLayer, OsmServerReader reader, ProgressMonitor progressMonitor) { 288 super(newLayer, tr("Downloading data"), progressMonitor, false );307 super(newLayer, tr("Downloading data"), progressMonitor, false, true); 289 308 this.reader = reader; 290 309 } … … 324 343 return; // user canceled download or error occurred 325 344 if (dataSet.allPrimitives().isEmpty()) { 326 rememberErrorMessage(tr("No data found in this area.")); 345 if (warnAboutEmptyArea) { 346 rememberErrorMessage(tr("No data found in this area.")); 347 } 327 348 // need to synthesize a download bounds lest the visual indication of downloaded area doesn't work 328 349 dataSet.dataSources.add(new DataSource(currentBounds != null ? currentBounds : -
trunk/src/org/openstreetmap/josm/data/ProjectionBounds.java
r8846 r8927 89 89 } 90 90 91 /** 92 * Determines if the bounds area is not null 93 * @return {@code true} if the area is not null 94 */ 91 95 public boolean hasExtend() { 92 96 return !Utils.equalsEpsilon(minEast, maxEast) || !Utils.equalsEpsilon(minNorth, maxNorth); -
trunk/src/org/openstreetmap/josm/data/osm/visitor/BoundingXYVisitor.java
r8846 r8927 48 48 } 49 49 50 /** 51 * Visiting call for bounds. 52 * @param b bounds 53 */ 50 54 public void visit(Bounds b) { 51 55 if (b != null) { … … 55 59 } 56 60 61 /** 62 * Visiting call for projection bounds. 63 * @param b projection bounds 64 */ 57 65 public void visit(ProjectionBounds b) { 58 66 if (b != null) { … … 62 70 } 63 71 72 /** 73 * Visiting call for lat/lon. 74 * @param latlon lat/lon 75 */ 64 76 public void visit(LatLon latlon) { 65 77 if (latlon != null) { … … 72 84 } 73 85 86 /** 87 * Visiting call for east/north. 88 * @param eastNorth east/north 89 */ 74 90 public void visit(EastNorth eastNorth) { 75 91 if (eastNorth != null) { … … 82 98 } 83 99 100 /** 101 * Determines if the visitor has a non null bounds area. 102 * @return {@code true} if the visitor has a non null bounds area 103 * @see ProjectionBounds#hasExtend 104 */ 84 105 public boolean hasExtend() { 85 106 return bounds != null && bounds.hasExtend(); … … 174 195 return; 175 196 // convert size from meters to east/north units 176 double en _size = size * Main.map.mapView.getScale() / Main.map.mapView.getDist100Pixel() * 100;177 visit(bounds.getMin().add(-en _size/2, -en_size/2));178 visit(bounds.getMax().add(+en _size/2, +en_size/2));197 double enSize = size * Main.map.mapView.getScale() / Main.map.mapView.getDist100Pixel() * 100; 198 visit(bounds.getMin().add(-enSize/2, -enSize/2)); 199 visit(bounds.getMax().add(+enSize/2, +enSize/2)); 179 200 } 180 201 … … 184 205 } 185 206 207 /** 208 * Compute the bounding box of a collection of primitives. 209 * @param primitives the collection of primitives 210 */ 186 211 public void computeBoundingBox(Collection<? extends OsmPrimitive> primitives) { 187 212 if (primitives == null) return; -
trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/LoadDataHandler.java
r8304 r8927 60 60 @Override 61 61 public String[] getUsageExamples() { 62 final String data = Utils.encodeUrl("<osm version='0.6'><node id='-1' lat='1' lon='2' /></osm>");63 62 return new String[]{ 64 "/load_data?layer_name=extra_layer&new_layer=true&data=" + data}; 63 "/load_data?layer_name=extra_layer&new_layer=true&data=" + 64 Utils.encodeUrl("<osm version='0.6'><node id='-1' lat='1' lon='2' /></osm>")}; 65 65 } 66 66 … … 101 101 protected final String layerName; 102 102 103 /** 104 * Constructs a new {@code LoadDataTask}. 105 * @param newLayer if {@code true}, force download to a new layer 106 * @param dataSet data set 107 * @param layerName layer name 108 */ 103 109 public LoadDataTask(boolean newLayer, DataSet dataSet, String layerName) { 104 super(newLayer, tr("Loading data"), false );110 super(newLayer, tr("Loading data"), false, true); 105 111 this.dataSet = dataSet; 106 112 this.layerName = layerName;
Note:
See TracChangeset
for help on using the changeset viewer.