From 5178fbeacc49f68a6961c0794d30894f966a01ec Mon Sep 17 00:00:00 2001 From: Taylor Smock Date: Wed, 13 Nov 2019 09:20:31 -0700 Subject: [PATCH] Fix an issue where a bbox was downloaded twice Signed-off-by: Taylor Smock --- .../josm/plugins/mapwithai/backend/GetDataRunnable.java | 2 +- .../josm/plugins/mapwithai/backend/MapWithAIDataUtils.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/GetDataRunnable.java b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/GetDataRunnable.java index fc714a2..4ea7969 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/GetDataRunnable.java +++ b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/GetDataRunnable.java @@ -79,7 +79,7 @@ public class GetDataRunnable extends RecursiveTask implements CancelLis */ public GetDataRunnable(List bbox, DataSet dataSet, ProgressMonitor monitor) { super(); - this.bbox = new ArrayList<>(bbox); + this.bbox = bbox.stream().distinct().collect(Collectors.toList()); this.dataSet = dataSet; this.monitor = Optional.ofNullable(monitor).orElse(NullProgressMonitor.INSTANCE); this.monitor.addCancelListener(this); diff --git a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIDataUtils.java b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIDataUtils.java index e8beab9..2abc927 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIDataUtils.java +++ b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIDataUtils.java @@ -370,7 +370,7 @@ public final class MapWithAIDataUtils { returnBounds.add(new BBox(lowerLeft, upperRight)); } } - return returnBounds; + return returnBounds.stream().distinct().collect(Collectors.toList()); } /** @@ -381,7 +381,7 @@ public final class MapWithAIDataUtils { public static List reduceBBoxSize(List bboxes) { final List returnBBoxes = new ArrayList<>(); bboxes.forEach(bbox -> returnBBoxes.addAll(reduceBBoxSize(bbox))); - return returnBBoxes; + return returnBBoxes.stream().distinct().collect(Collectors.toList()); } /**