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 {
/** 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 ForkJoinPool forkJoinPool;
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",
"resource://styles/standard/mapwithai.mapcss");
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()) {
final MapCSSStyleSource style = new MapCSSStyleSource(paintStyleResourceUrl, MapWithAIPlugin.NAME,
@ -95,8 +96,8 @@ public final class MapWithAIDataUtils {
*/
public static void removeMapWithAIPaintStyles() {
new ArrayList<>(MapPaintStyles.getStyles().getStyleSources()).parallelStream()
.filter(source -> paintStyleResourceUrl.equals(source.url))
.forEach(style -> SwingUtilities.invokeLater(() -> MapPaintStyles.removeStyle(style)));
.filter(source -> paintStyleResourceUrl.equals(source.url))
.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<Bounds> realBounds = realBBoxes.stream()
.flatMap(tBBox -> MapWithAIDataUtils.reduceBBoxSize(tBBox).stream())
.map(MapWithAIDataUtils::bboxToBounds)
.collect(Collectors.toList());
.map(MapWithAIDataUtils::bboxToBounds).collect(Collectors.toList());
if (MapWithAIPreferenceHelper.getMapWithAIUrl().parallelStream()
.anyMatch(map -> Boolean.valueOf(map.getOrDefault("enabled", "false")))) {
if ((realBBoxes.size() < TOO_MANY_BBOXES) || ConditionalOptionPaneUtil.showConfirmationDialog(
@ -175,35 +175,35 @@ public final class MapWithAIDataUtils {
final PleaseWaitProgressMonitor monitor = new PleaseWaitProgressMonitor();
monitor.beginTask(tr("Downloading {0} Data", MapWithAIPlugin.NAME), realBounds.size());
realBounds.parallelStream()
.forEach(bound -> MapWithAIPreferenceHelper.getMapWithAIUrl().parallelStream()
.filter(map -> map.containsKey("url")).map(MapWithAIDataUtils::getUrl)
.filter(string -> !string.trim().isEmpty()).forEach(url -> {
BoundingBoxMapWithAIDownloader downloader = new BoundingBoxMapWithAIDownloader(
bound, url, DetectTaskingManagerUtils.hasTaskingManagerLayer());
try {
DataSet ds = downloader.parseOsm(monitor.createSubTaskMonitor(1, false));
synchronized (MapWithAIDataUtils.class) {
dataSet.mergeFrom(ds);
}
} catch (OsmTransferException e) {
Logging.error(e);
}
}));
.forEach(bound -> MapWithAIPreferenceHelper.getMapWithAIUrl().parallelStream()
.filter(map -> map.containsKey("url")).map(MapWithAIDataUtils::getUrl)
.filter(string -> !string.trim().isEmpty()).forEach(url -> {
BoundingBoxMapWithAIDownloader downloader = new BoundingBoxMapWithAIDownloader(
bound, url, DetectTaskingManagerUtils.hasTaskingManagerLayer());
try {
DataSet ds = downloader.parseOsm(monitor.createSubTaskMonitor(1, false));
synchronized (MapWithAIDataUtils.class) {
dataSet.mergeFrom(ds);
}
} catch (OsmTransferException e) {
Logging.error(e);
}
}));
monitor.finishTask();
monitor.close();
}
} else {
final Notification noUrls = MapWithAIPreferenceHelper.getMapWithAIURLs().isEmpty()
? new Notification(tr("There are no defined URLs. To get the defaults, restart JOSM"))
: new Notification(tr("No URLS are enabled"));
noUrls.setDuration(Notification.TIME_DEFAULT);
noUrls.setIcon(JOptionPane.INFORMATION_MESSAGE);
noUrls.setHelpTopic(ht("Plugin/MapWithAI#Preferences"));
if (SwingUtilities.isEventDispatchThread()) {
noUrls.show();
} else {
SwingUtilities.invokeLater(noUrls::show);
}
: new Notification(tr("No URLS are enabled"));
noUrls.setDuration(Notification.TIME_DEFAULT);
noUrls.setIcon(JOptionPane.INFORMATION_MESSAGE);
noUrls.setHelpTopic(ht("Plugin/MapWithAI#Preferences"));
if (SwingUtilities.isEventDispatchThread()) {
noUrls.show();
} else {
SwingUtilities.invokeLater(noUrls::show);
}
}
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 {
@Rule
@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)}.