Decrease max download sizes due to timeout issues

Signed-off-by: Taylor Smock <taylor.smock@kaart.com>
pull/1/head
Taylor Smock 2020-01-09 15:33:05 -07:00
rodzic 7d3ccb2247
commit 3686407b18
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 625F6A74A3E4311A
8 zmienionych plików z 198 dodań i 30 usunięć

Wyświetl plik

@ -49,7 +49,8 @@ import org.openstreetmap.josm.tools.Utils;
*/ */
public final class MapWithAIDataUtils { public final class MapWithAIDataUtils {
/** THe maximum dimensions for MapWithAI data (in kilometers) */ /** THe maximum dimensions for MapWithAI data (in kilometers) */
public static final int MAXIMUM_SIDE_DIMENSIONS = 10_000; // RapiD is about 1km, max is 10km public static final int MAXIMUM_SIDE_DIMENSIONS = 5_000; // RapiD is about 1km, max is 10km, but 10km causes
// timeouts
private static final int TOO_MANY_BBOXES = 4; private static final int TOO_MANY_BBOXES = 4;
private static ForkJoinPool forkJoinPool; private static ForkJoinPool forkJoinPool;
static final Object LAYER_LOCK = new Object(); static final Object LAYER_LOCK = new Object();
@ -73,7 +74,7 @@ public final class MapWithAIDataUtils {
"https://gitlab.com/smocktaylor/rapid/raw/master/src/resources/styles/standard/rapid.mapcss", "https://gitlab.com/smocktaylor/rapid/raw/master/src/resources/styles/standard/rapid.mapcss",
"resource://styles/standard/mapwithai.mapcss"); "resource://styles/standard/mapwithai.mapcss");
new ArrayList<>(MapPaintStyles.getStyles().getStyleSources()).parallelStream() new ArrayList<>(MapPaintStyles.getStyles().getStyleSources()).parallelStream()
.filter(style -> oldUrls.contains(style.url)).forEach(MapPaintStyles::removeStyle); .filter(style -> oldUrls.contains(style.url)).forEach(MapPaintStyles::removeStyle);
if (!checkIfMapWithAIPaintStyleExists()) { if (!checkIfMapWithAIPaintStyleExists()) {
final MapCSSStyleSource style = new MapCSSStyleSource(paintStyleResourceUrl, MapWithAIPlugin.NAME, final MapCSSStyleSource style = new MapCSSStyleSource(paintStyleResourceUrl, MapWithAIPlugin.NAME,
@ -95,8 +96,8 @@ public final class MapWithAIDataUtils {
*/ */
public static void removeMapWithAIPaintStyles() { public static void removeMapWithAIPaintStyles() {
new ArrayList<>(MapPaintStyles.getStyles().getStyleSources()).parallelStream() new ArrayList<>(MapPaintStyles.getStyles().getStyleSources()).parallelStream()
.filter(source -> paintStyleResourceUrl.equals(source.url)) .filter(source -> paintStyleResourceUrl.equals(source.url))
.forEach(style -> SwingUtilities.invokeLater(() -> MapPaintStyles.removeStyle(style))); .forEach(style -> SwingUtilities.invokeLater(() -> MapPaintStyles.removeStyle(style)));
} }
/** /**
@ -163,8 +164,7 @@ public final class MapWithAIDataUtils {
final List<BBox> realBBoxes = bbox.stream().filter(BBox::isValid).distinct().collect(Collectors.toList()); final List<BBox> realBBoxes = bbox.stream().filter(BBox::isValid).distinct().collect(Collectors.toList());
final List<Bounds> realBounds = realBBoxes.stream() final List<Bounds> realBounds = realBBoxes.stream()
.flatMap(tBBox -> MapWithAIDataUtils.reduceBBoxSize(tBBox).stream()) .flatMap(tBBox -> MapWithAIDataUtils.reduceBBoxSize(tBBox).stream())
.map(MapWithAIDataUtils::bboxToBounds) .map(MapWithAIDataUtils::bboxToBounds).collect(Collectors.toList());
.collect(Collectors.toList());
if (MapWithAIPreferenceHelper.getMapWithAIUrl().parallelStream() if (MapWithAIPreferenceHelper.getMapWithAIUrl().parallelStream()
.anyMatch(map -> Boolean.valueOf(map.getOrDefault("enabled", "false")))) { .anyMatch(map -> Boolean.valueOf(map.getOrDefault("enabled", "false")))) {
if ((realBBoxes.size() < TOO_MANY_BBOXES) || ConditionalOptionPaneUtil.showConfirmationDialog( if ((realBBoxes.size() < TOO_MANY_BBOXES) || ConditionalOptionPaneUtil.showConfirmationDialog(
@ -175,35 +175,35 @@ public final class MapWithAIDataUtils {
final PleaseWaitProgressMonitor monitor = new PleaseWaitProgressMonitor(); final PleaseWaitProgressMonitor monitor = new PleaseWaitProgressMonitor();
monitor.beginTask(tr("Downloading {0} Data", MapWithAIPlugin.NAME), realBounds.size()); monitor.beginTask(tr("Downloading {0} Data", MapWithAIPlugin.NAME), realBounds.size());
realBounds.parallelStream() realBounds.parallelStream()
.forEach(bound -> MapWithAIPreferenceHelper.getMapWithAIUrl().parallelStream() .forEach(bound -> MapWithAIPreferenceHelper.getMapWithAIUrl().parallelStream()
.filter(map -> map.containsKey("url")).map(MapWithAIDataUtils::getUrl) .filter(map -> map.containsKey("url")).map(MapWithAIDataUtils::getUrl)
.filter(string -> !string.trim().isEmpty()).forEach(url -> { .filter(string -> !string.trim().isEmpty()).forEach(url -> {
BoundingBoxMapWithAIDownloader downloader = new BoundingBoxMapWithAIDownloader( BoundingBoxMapWithAIDownloader downloader = new BoundingBoxMapWithAIDownloader(
bound, url, DetectTaskingManagerUtils.hasTaskingManagerLayer()); bound, url, DetectTaskingManagerUtils.hasTaskingManagerLayer());
try { try {
DataSet ds = downloader.parseOsm(monitor.createSubTaskMonitor(1, false)); DataSet ds = downloader.parseOsm(monitor.createSubTaskMonitor(1, false));
synchronized (MapWithAIDataUtils.class) { synchronized (MapWithAIDataUtils.class) {
dataSet.mergeFrom(ds); dataSet.mergeFrom(ds);
} }
} catch (OsmTransferException e) { } catch (OsmTransferException e) {
Logging.error(e); Logging.error(e);
} }
})); }));
monitor.finishTask(); monitor.finishTask();
monitor.close(); monitor.close();
} }
} else { } else {
final Notification noUrls = MapWithAIPreferenceHelper.getMapWithAIURLs().isEmpty() final Notification noUrls = MapWithAIPreferenceHelper.getMapWithAIURLs().isEmpty()
? new Notification(tr("There are no defined URLs. To get the defaults, restart JOSM")) ? new Notification(tr("There are no defined URLs. To get the defaults, restart JOSM"))
: new Notification(tr("No URLS are enabled")); : new Notification(tr("No URLS are enabled"));
noUrls.setDuration(Notification.TIME_DEFAULT); noUrls.setDuration(Notification.TIME_DEFAULT);
noUrls.setIcon(JOptionPane.INFORMATION_MESSAGE); noUrls.setIcon(JOptionPane.INFORMATION_MESSAGE);
noUrls.setHelpTopic(ht("Plugin/MapWithAI#Preferences")); noUrls.setHelpTopic(ht("Plugin/MapWithAI#Preferences"));
if (SwingUtilities.isEventDispatchThread()) { if (SwingUtilities.isEventDispatchThread()) {
noUrls.show(); noUrls.show();
} else { } else {
SwingUtilities.invokeLater(noUrls::show); SwingUtilities.invokeLater(noUrls::show);
} }
} }
return dataSet; return dataSet;
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Wyświetl plik

@ -38,7 +38,7 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
public class MapWithAIUploadHookTest { public class MapWithAIUploadHookTest {
@Rule @Rule
@SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") @SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
public JOSMTestRules test = new JOSMTestRules().main().projection(); public JOSMTestRules test = new JOSMTestRules().main().projection().preferences();
/** /**
* Test method for {@link MapWithAIUploadHook#modifyChangesetTags(Map)}. * Test method for {@link MapWithAIUploadHook#modifyChangesetTags(Map)}.