Changeset 19289 in josm
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/AddImageryLayerAction.java
r19050 r19289 169 169 if (infoToAdd != null) { 170 170 layer = ImageryLayer.create(infoToAdd); 171 getLayerManager().addLayer(layer); 171 getLayerManager().addLayer(layer, false); 172 172 AlignImageryPanel.addNagPanelIfNeeded(infoToAdd); 173 173 } -
trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java
r19280 r19289 27 27 import java.io.IOException; 28 28 import java.net.MalformedURLException; 29 import java.net.URL; 29 import java.net.URI; 30 import java.net.URISyntaxException; 30 31 import java.time.Instant; 31 32 import java.util.ArrayList; … … 292 293 293 294 try { 294 if ("file".equalsIgnoreCase(new UR L(tileSource.getBaseUrl()).getProtocol())) {295 if ("file".equalsIgnoreCase(new URI(tileSource.getBaseUrl()).toURL().getProtocol())) { 295 296 tileLoader = new OsmTileLoader(this); 296 297 } 297 } catch (MalformedURLException e) { 298 } catch (URISyntaxException | MalformedURLException e) { 298 299 // ignore, assume that this is not a file 299 300 Logging.log(Logging.LEVEL_DEBUG, e); … … 515 516 if (tile != null) { 516 517 try { 517 new Notification(HttpClient.create(new UR L(tile.getUrl() + '/' + request))518 new Notification(HttpClient.create(new URI(tile.getUrl() + '/' + request).toURL()) 518 519 .connect().fetchContent()).setIcon(JOptionPane.INFORMATION_MESSAGE).show(); 519 } catch (IOException ex) { 520 } catch (URISyntaxException | IOException ex) { 520 521 Logging.error(ex); 521 522 } … … 1874 1875 @Override 1875 1876 public void visitBoundingBox(BoundingXYVisitor v) { 1877 if (this.getInfo() != null) { 1878 v.visit(this.getInfo().getBounds()); 1879 } 1876 1880 } 1877 1881 -
trunk/test/unit/org/openstreetmap/josm/actions/AddImageryLayerActionTest.java
r19155 r19289 8 8 import static org.junit.jupiter.api.Assertions.assertTrue; 9 9 10 import java.util.Arrays; 10 11 import java.util.List; 11 12 … … 13 14 import org.junit.jupiter.api.Test; 14 15 import org.openstreetmap.gui.jmapviewer.FeatureAdapter; 16 import org.openstreetmap.josm.data.Bounds; 15 17 import org.openstreetmap.josm.data.imagery.ImageryInfo; 18 import org.openstreetmap.josm.data.osm.DataSet; 19 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 16 20 import org.openstreetmap.josm.gui.MainApplication; 21 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 17 22 import org.openstreetmap.josm.gui.layer.TMSLayer; 18 23 import org.openstreetmap.josm.gui.layer.WMSLayer; 24 import org.openstreetmap.josm.gui.util.GuiHelper; 19 25 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 20 26 import org.openstreetmap.josm.testutils.annotations.BasicWiremock; 27 import org.openstreetmap.josm.testutils.annotations.Main; 21 28 import org.openstreetmap.josm.testutils.annotations.OsmApi; 22 29 import org.openstreetmap.josm.testutils.annotations.Projection; … … 99 106 assertTrue(MainApplication.getLayerManager().getLayersOfType(TMSLayer.class).isEmpty()); 100 107 } 108 109 110 /** 111 * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/24097">#24097</a>: Zoom to imagery layer 112 * This tests two things: 113 * <ul> 114 * <li>Imagery layer zoom to action works properly</li> 115 * <li>Imagery layer bounds is not zoomed to on layer add</li> 116 * </ul> 117 */ 118 @Main 119 @Test 120 void testNonRegression24097() { 121 // First, add a new data layer 122 MainApplication.getLayerManager().addLayer(new OsmDataLayer(new DataSet(), 123 "AddImageryLayerActionTest#testNonRegression24097", null)); 124 // Now zoom to a random area 125 MainApplication.getMap().mapView.zoomTo(new Bounds(39.0665807, -108.5212326, 39.0793079, -108.4986591)); 126 // Initialize the zoom actions 127 MainApplication.getMenu().initialize(); 128 final Bounds startingBounds = MainApplication.getMap().mapView.getRealBounds(); 129 ImageryInfo testInfo = new ImageryInfo("Test", "https://127.0.0.1/{zoom}/{x}/{y}.png", "tms", null, null, "Test"); 130 testInfo.setBounds(new ImageryInfo.ImageryBounds("-0.001,-0.001,0.001,0.001", ",")); 131 new AddImageryLayerAction(testInfo).actionPerformed(null); 132 GuiHelper.runInEDTAndWait(() -> { /* Sync GUI thread */ }); 133 // There is a bit of zooming done during the load of the imagery 134 assertTrue(startingBounds.toBBox().bboxIsFunctionallyEqual(MainApplication.getMap().mapView.getRealBounds().toBBox(), 0.001), 135 "Adding an imagery layer should not zoom to the imagery layer bounds"); 136 assertEquals(1, MainApplication.getLayerManager().getLayersOfType(TMSLayer.class).size()); 137 final TMSLayer tmsLayer = MainApplication.getLayerManager().getLayersOfType(TMSLayer.class).get(0); 138 final AutoScaleAction autoScaleAction = Arrays.stream(tmsLayer.getMenuEntries()).filter(AutoScaleAction.class::isInstance) 139 .map(AutoScaleAction.class::cast).findFirst().orElseThrow(); 140 autoScaleAction.actionPerformed(null); 141 // We can't check the bbox here, since the mapView doesn't have any actual width/height. 142 // So we just check the center. 143 assertTrue(new Bounds(-0.001, -0.001, 0.001, 0.001) 144 .contains(ProjectionRegistry.getProjection().eastNorth2latlon( 145 MainApplication.getMap().mapView.getCenter())), 146 "The action should have zoomed to the bbox for the imagery layer"); 147 } 101 148 }
Note:
See TracChangeset
for help on using the changeset viewer.