Changeset 5729 in josm for trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java
- Timestamp:
- 2013-02-19T10:04:40+01:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java
r5691 r5729 7 7 import java.io.IOException; 8 8 import java.net.URL; 9 import java.util.ArrayList;10 9 import java.util.Collection; 11 import java.util.HashSet;12 import java.util.Iterator;13 import java.util.List;14 import java.util.Set;15 10 import java.util.concurrent.Future; 16 11 import java.util.regex.Matcher; 17 12 import java.util.regex.Pattern; 18 13 19 import javax.swing.JOptionPane;14 import org.xml.sax.SAXException; 20 15 21 16 import org.openstreetmap.josm.Main; 22 17 import org.openstreetmap.josm.data.Bounds; 23 18 import org.openstreetmap.josm.data.coor.LatLon; 24 import org.openstreetmap.josm.data.imagery.ImageryInfo;25 import org.openstreetmap.josm.data.imagery.ImageryLayerInfo;26 import org.openstreetmap.josm.data.imagery.Shape;27 19 import org.openstreetmap.josm.data.osm.DataSet; 28 20 import org.openstreetmap.josm.data.osm.DataSource; 29 21 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 30 import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil;31 22 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 32 23 import org.openstreetmap.josm.gui.layer.Layer; … … 39 30 import org.openstreetmap.josm.io.OsmTransferCanceledException; 40 31 import org.openstreetmap.josm.io.OsmTransferException; 41 import org.openstreetmap.josm.tools.Utils;42 import org.xml.sax.SAXException;43 32 44 33 /** … … 283 272 targetLayer.onPostDownloadFromServer(); 284 273 } 285 286 // Suggest potential imagery data, except if the data is downloaded after a "data update" command (see #8307)287 if (!isUpdateData) {288 suggestImageryLayers();289 }290 274 } 291 275 … … 304 288 if (reader != null) { 305 289 reader.cancel(); 306 }307 }308 309 protected void suggestImageryLayers() {310 if (currentBounds != null) {311 final LatLon center = currentBounds.getCenter();312 final Set<ImageryInfo> layers = new HashSet<ImageryInfo>();313 314 for (ImageryInfo i : ImageryLayerInfo.instance.getDefaultLayers()) {315 if (i.getBounds() != null && i.getBounds().contains(center)) {316 layers.add(i);317 }318 }319 // Do not suggest layers already in use320 layers.removeAll(ImageryLayerInfo.instance.getLayers());321 // For layers containing complex shapes, check that center is in one of its shapes (fix #7910)322 for (Iterator<ImageryInfo> iti = layers.iterator(); iti.hasNext(); ) {323 List<Shape> shapes = iti.next().getBounds().getShapes();324 if (shapes != null && !shapes.isEmpty()) {325 boolean found = false;326 for (Iterator<Shape> its = shapes.iterator(); its.hasNext() && !found; ) {327 found = its.next().contains(center);328 }329 if (!found) {330 iti.remove();331 }332 }333 }334 335 if (layers.isEmpty()) {336 return;337 }338 339 final List<String> layerNames = new ArrayList<String>();340 for (ImageryInfo i : layers) {341 layerNames.add(i.getName());342 }343 344 if (!ConditionalOptionPaneUtil.showConfirmationDialog(345 "download.suggest-imagery-layer",346 Main.parent,347 tr("<html>For the downloaded area, the following additional imagery layers are available: {0}" +348 "Do you want to add those layers to the <em>Imagery</em> menu?" +349 "<br>(If needed, you can remove those entries in the <em>Preferences</em>.)",350 Utils.joinAsHtmlUnorderedList(layerNames)),351 tr("Add imagery layers?"),352 JOptionPane.YES_NO_OPTION,353 JOptionPane.QUESTION_MESSAGE,354 JOptionPane.YES_OPTION)) {355 return;356 }357 358 ImageryLayerInfo.addLayers(layers);359 290 } 360 291 }
Note:
See TracChangeset
for help on using the changeset viewer.