diff --git a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/data/mapwithai/MapWithAILayerInfo.java b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/data/mapwithai/MapWithAILayerInfo.java index ed2a3ff..9d2c2c4 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/data/mapwithai/MapWithAILayerInfo.java +++ b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/data/mapwithai/MapWithAILayerInfo.java @@ -19,6 +19,7 @@ import java.util.concurrent.ExecutorService; import org.openstreetmap.josm.data.StructUtils; import org.openstreetmap.josm.data.imagery.ImageryInfo; +import org.openstreetmap.josm.gui.MainApplication; import org.openstreetmap.josm.gui.PleaseWaitRunnable; import org.openstreetmap.josm.gui.util.GuiHelper; import org.openstreetmap.josm.io.CachedFile; @@ -114,7 +115,7 @@ public class MapWithAILayerInfo { } Collections.sort(layers); } - loadDefaults(false, null, fastFail, null); + loadDefaults(false, MainApplication.worker, fastFail, null); } /** diff --git a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/io/mapwithai/MapWithAISourceReader.java b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/io/mapwithai/MapWithAISourceReader.java index 2486faa..0366bc2 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/io/mapwithai/MapWithAISourceReader.java +++ b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/io/mapwithai/MapWithAISourceReader.java @@ -160,7 +160,14 @@ public class MapWithAISourceReader implements Closeable { private static List getBounds(JsonValue countries) { if (JsonValue.ValueType.OBJECT == countries.getValueType()) { - Set codes = Territories.getKnownIso3166Codes(); + Set codes; + try { + codes = Territories.getKnownIso3166Codes(); + } catch (NullPointerException e) { + // Fix JOSM-19420 + Territories.initializeInternalData(); + codes = Territories.getKnownIso3166Codes(); + } List bounds = new ArrayList<>(); for (Map.Entry country : countries.asJsonObject().entrySet()) { if (codes.contains(country.getKey())) {