Skip to content

Commit

Permalink
Fix MapWithAI layer switching with ctrl+r
Browse files Browse the repository at this point in the history
Signed-off-by: Taylor Smock <[email protected]>
  • Loading branch information
tsmock committed Oct 2, 2023
1 parent bac594e commit 9c3e9c0
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

import org.openstreetmap.josm.actions.ExpertToggleAction;
import org.openstreetmap.josm.data.Bounds;
import org.openstreetmap.josm.data.DataSource;
import org.openstreetmap.josm.data.osm.DataSet;
import org.openstreetmap.josm.data.osm.DownloadPolicy;
import org.openstreetmap.josm.data.osm.Node;
Expand Down Expand Up @@ -255,6 +256,9 @@ public Icon getIcon() {
public void onPostDownloadFromServer(Bounds bounds) {
super.onPostDownloadFromServer();
GetDataRunnable.cleanup(getDataSet(), bounds, null);
if (!this.data.getDataSourceBounds().contains(bounds)) {
this.data.addDataSource(new DataSource(bounds, null));
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"response" : {
"status" : 200,
"body" : "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<osm generator=\"NS_ROADS_SERVICE\" version=\"0.6\">\n <bounds maxlat=\"-1.0E-5\" maxlon=\"-1.0000000000381E-5\" minlat=\"-0.00099\" minlon=\"-0.00098999999999962\"/>\n</osm>\n",
"body" : "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<osm generator=\"NS_ROADS_SERVICE\" version=\"0.6\">\n <bounds maxlat=\"0.0\" maxlon=\"0.0\" minlat=\"-0.001\" minlon=\"-0.001\"/>\n</osm>\n",
"headers" : {
"Content-Type" : "text/xml; charset=UTF-8",
"Strict-Transport-Security" : "max-age=15552000; preload",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"response" : {
"status" : 200,
"body" : "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<osm generator=\"NS_ROADS_SERVICE\" version=\"0.6\"><bounds maxlat=\"0.00099\" maxlon=\"0.00098999999999962\" minlat=\"1.0E-5\" minlon=\"1.0000000000381E-5\"/></osm>\n",
"body" : "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<osm generator=\"NS_ROADS_SERVICE\" version=\"0.6\"><bounds maxlat=\"0.001\" maxlon=\"0.001\" minlat=\"0.0\" minlon=\"0.0\"/></osm>\n",
"headers" : {
"Content-Type" : "text/xml; charset=UTF-8",
"X-XSS-Protection" : "0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"response" : {
"status" : 200,
"body" : "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<osm generator=\"NS_ROADS_SERVICE\" version=\"0.6\">\n <bounds maxlat=\"0.00099\" maxlon=\"0.00098999999999962\" minlat=\"1.0E-5\" minlon=\"1.0000000000381E-5\"/>\n</osm>\n",
"body" : "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<osm generator=\"NS_ROADS_SERVICE\" version=\"0.6\">\n <bounds maxlat=\"0.001\" maxlon=\"0.001\" minlat=\"0.0\" minlon=\"0.0\"/>\n</osm>\n",
"headers" : {
"Content-Type" : "text/xml; charset=UTF-8",
"Strict-Transport-Security" : "max-age=15552000; preload",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.openstreetmap.josm.TestUtils;
import org.openstreetmap.josm.data.Bounds;
import org.openstreetmap.josm.data.DataSource;
Expand All @@ -46,19 +45,16 @@
import org.openstreetmap.josm.plugins.mapwithai.commands.MapWithAIAddCommand;
import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAIInfo;
import org.openstreetmap.josm.plugins.mapwithai.testutils.MapWithAIPluginMock;
import org.openstreetmap.josm.plugins.mapwithai.testutils.MapWithAITestRules;
import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.MapWithAISources;
import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Wiremock;
import org.openstreetmap.josm.plugins.mapwithai.tools.MapPaintUtils;
import org.openstreetmap.josm.spi.preferences.Config;
import org.openstreetmap.josm.testutils.JOSMTestRules;
import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
import org.openstreetmap.josm.testutils.annotations.Main;
import org.openstreetmap.josm.testutils.annotations.OsmApi;
import org.openstreetmap.josm.testutils.annotations.Projection;
import org.openstreetmap.josm.testutils.annotations.Territories;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

/**
* Test class for {@link MapWithAILayer}
*
Expand All @@ -67,14 +63,11 @@
@BasicPreferences
@Main
@MapWithAISources
@OsmApi(OsmApi.APIType.FAKE)
@Projection
@Territories(Territories.Initialize.ALL)
@Wiremock
class MapWithAILayerTest {
@RegisterExtension
@SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
static JOSMTestRules test = new MapWithAITestRules().main().fakeAPI();

MapWithAILayer layer;

@BeforeAll
Expand Down

0 comments on commit 9c3e9c0

Please sign in to comment.