From 1e5d9d90fe6d3d783077146660551226e78f7fd6 Mon Sep 17 00:00:00 2001 From: Ian Dees Date: Mon, 9 Sep 2024 09:19:35 -0500 Subject: [PATCH] Check response from Fieldpapers request to see if it has what we need --- .../plugins/fieldpapers/FieldPapersAddLayerAction.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/org/openstreetmap/josm/plugins/fieldpapers/FieldPapersAddLayerAction.java b/src/org/openstreetmap/josm/plugins/fieldpapers/FieldPapersAddLayerAction.java index 499d935..f63a01e 100644 --- a/src/org/openstreetmap/josm/plugins/fieldpapers/FieldPapersAddLayerAction.java +++ b/src/org/openstreetmap/josm/plugins/fieldpapers/FieldPapersAddLayerAction.java @@ -70,6 +70,11 @@ public void openUrl(String url) { // fetch metadata JsonObject metadata = getMetadata(url); + if (metadata == null || metadata.getJsonString("tilejson_url") == null) { + JOptionPane.showMessageDialog(MainApplication.getMainFrame(), tr("Could not read information for \"{0}\" from fieldpapers.org", url)); + return; + } + String tileJsonUrl = metadata.getJsonString("tilejson_url").getString(); String id = metadata.getJsonString("id").getString(); @@ -86,7 +91,7 @@ public void openUrl(String url) { double east = bounds.getJsonNumber(2).doubleValue(); double north = bounds.getJsonNumber(3).doubleValue(); - // save this atlas as the + // save this atlas ID as the last used atlas FieldPapersPlugin.LAST_USED_ID.put(id); Bounds b = new Bounds(new LatLon(south, west), new LatLon(north, east)); @@ -96,7 +101,7 @@ public void openUrl(String url) { } catch (IOException ex) { Logging.error(ex); - JOptionPane.showMessageDialog(MainApplication.getMainFrame(), tr("Could not read information for the id \"{0}\" from fieldpapers.org", url)); + JOptionPane.showMessageDialog(MainApplication.getMainFrame(), tr("Could not read information for \"{0}\" from fieldpapers.org", url)); } }