From 7a3a633fe8a86639e9a6e75b9b7df38762b014d7 Mon Sep 17 00:00:00 2001 From: Taylor Smock Date: Mon, 17 Jun 2024 07:45:00 -0600 Subject: [PATCH] Fix #23676: Mapillary still has some non-numeric ids in their tiles Signed-off-by: Taylor Smock --- .../mapillary/utils/MapillaryImageUtils.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/openstreetmap/josm/plugins/mapillary/utils/MapillaryImageUtils.java b/src/main/java/org/openstreetmap/josm/plugins/mapillary/utils/MapillaryImageUtils.java index 6120ddc2b..6513cb0f0 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/mapillary/utils/MapillaryImageUtils.java +++ b/src/main/java/org/openstreetmap/josm/plugins/mapillary/utils/MapillaryImageUtils.java @@ -255,12 +255,17 @@ public static long getKey(@Nullable IPrimitive image, boolean ignoreId) { } // This should always be a parseable integer according to API docs. By not checking that all characters are // digits, we save 55.6 MB of allocations in the test area during download. - if (image.hasKey(ImageProperties.ID.toString())) { - final var id = Long.parseLong(image.get(ImageProperties.ID.toString())); - if (id > 0) { - image.setOsmId(id, 1); + try { + if (image.hasKey(ImageProperties.ID.toString())) { + final var id = Long.parseLong(image.get(ImageProperties.ID.toString())); + if (id > 0) { + image.setOsmId(id, 1); + } + return id; } - return id; + } catch (NumberFormatException numberFormatException) { + // This does actually happen; see #23734 + Logging.error(numberFormatException); } } return 0;