MapWithAIPreferences: Increase default max add and thus absolute max add

Signed-off-by: Taylor Smock <tsmock@fb.com>
pull/1/head
Taylor Smock 2020-11-24 16:32:53 +00:00
rodzic f53c8220c4
commit 793af99bf8
9 zmienionych plików z 18 dodań i 18 usunięć

Wyświetl plik

@ -8,6 +8,7 @@ import java.awt.event.ActionEvent;
import java.io.File;
import java.io.IOException;
import java.io.Serializable;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@ -356,7 +357,7 @@ public class MapWithAILayer extends OsmDataLayer implements ActiveLayerChangeLis
@Override
public boolean autosave(File file) throws IOException {
// Consider a deletetion a "successful" save.
return file.delete();
// Consider a deletion a "successful" save.
return Files.deleteIfExists(file.toPath());
}
}

Wyświetl plik

@ -15,7 +15,7 @@ import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAILayerInf
import org.openstreetmap.josm.spi.preferences.Config;
public final class MapWithAIPreferenceHelper {
private static final int DEFAULT_MAXIMUM_ADDITION = 5;
private static final int DEFAULT_MAXIMUM_ADDITION = 20;
private static final String AUTOSWITCHLAYERS = MapWithAIPlugin.NAME.concat(".autoswitchlayers");
private static final String MERGEBUILDINGADDRESSES = MapWithAIPlugin.NAME.concat(".mergebuildingaddresses");
private static final String MAXIMUMSELECTION = MapWithAIPlugin.NAME.concat(".maximumselection");

Wyświetl plik

@ -181,7 +181,7 @@ public class MergeDuplicateWays extends Command {
final Set<Map.Entry<Pair<Integer, Node>, Map<Integer, Node>>> duplicateEntrySet = duplicateNodes.entrySet();
final Set<Pair<Pair<Integer, Node>, Pair<Integer, Node>>> compressed = duplicateNodes.entrySet().stream()
.map(entry -> new Pair<Pair<Integer, Node>, Pair<Integer, Node>>(entry.getKey(),
new Pair<Integer, Node>(entry.getValue().entrySet().iterator().next().getKey(),
new Pair<>(entry.getValue().entrySet().iterator().next().getKey(),
entry.getValue().entrySet().iterator().next().getValue())))
.sorted((pair1, pair2) -> pair1.a.a - pair2.a.a).collect(Collectors.toSet());
if (compressed.parallelStream().anyMatch(entry -> entry.a.b.isDeleted() || entry.b.b.isDeleted())) {
@ -367,8 +367,8 @@ public class MergeDuplicateWays extends Command {
@Override
public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted,
Collection<OsmPrimitive> added) {
for (final Command command : commands) {
command.fillModifiedData(modified, deleted, added);
for (final Command currentCommand : commands) {
currentCommand.fillModifiedData(modified, deleted, added);
}
}
}

Wyświetl plik

@ -154,12 +154,6 @@ public class StreetAddressOrder extends Test {
Way way = new Way();
way.setNodes(centroids);
/*
* if (primitives.get(0) instanceof OsmPrimitive) { DataSet ds = ((OsmPrimitive)
* primitives.get(0)).getDataSet(); // TODO remove after finishing debug
* way.getNodes().stream().filter(p -> p.getDataSet() == null &&
* !p.isDeleted()).forEach(ds::addPrimitive); ds.addPrimitive(way); }
*/
double maxDistance = 100;
Node previousCentroid = centroids.get(0);
for (Node centroid : centroids) {

Wyświetl plik

@ -71,7 +71,7 @@ public class MapWithAIDownloadSourceType implements IDownloadSourceType, LayerCh
@Override
public void changeEvent(MapWithAIInfo modified) {
if (Stream.of(Thread.currentThread().getStackTrace()).map(p -> p.getClassName())
if (Stream.of(Thread.currentThread().getStackTrace()).map(StackTraceElement::getClassName)
.noneMatch(p -> p.contains("PreferenceDialog"))) {
if (MapWithAILayerInfo.getInstance().getLayers().contains(modified)) {
this.cbDownloadMapWithAIData.setSelected(true);

Wyświetl plik

@ -261,7 +261,8 @@ public class MapWithAIProvidersPanel extends JPanel {
extends MapWithAIProvidersPanel.MapWithAITableCellRenderer<List<String>> {
MapWithAITypeTableCellRenderer() {
super(list -> joinList(list), i -> null, list -> joinList(list), null, false);
super(MapWithAITypeTableCellRenderer::joinList, i -> null, MapWithAITypeTableCellRenderer::joinList, null,
false);
}
private static String joinList(List<String> list) {

Wyświetl plik

@ -146,6 +146,7 @@ class MapWithAILayerTest {
getData.setMaximumDimensions(5_000);
getData.fork().join();
assertTrue(ds.getSelected().isEmpty());
MapWithAIPreferenceHelper.setMaximumAddition(5, false);
SwingUtilities.invokeAndWait(() -> ds.setSelected(ds.allNonDeletedCompletePrimitives()));
assertEquals(1, ds.getSelected().size());
OsmPrimitive prim = ds.getSelected().iterator().next();

Wyświetl plik

@ -106,7 +106,7 @@ class MapWithAIMoveActionTest {
moveAction.actionPerformed(null);
Awaitility.await().atMost(Durations.ONE_SECOND).until(() -> ds.getPrimitiveById(way1) != null);
assertTrue(((Way) ds.getPrimitiveById(way1)).lastNode().equals(((Way) ds.getPrimitiveById(way2)).lastNode()),
assertEquals(((Way) ds.getPrimitiveById(way1)).lastNode(), ((Way) ds.getPrimitiveById(way2)).lastNode(),
"The duplicate node should have been replaced");
assertFalse(((Way) ds.getPrimitiveById(way2)).lastNode().hasKey(DuplicateCommand.KEY),
"The dupe key should no longer exist");

Wyświetl plik

@ -109,14 +109,16 @@ class MapWithAIUploadHookTest {
assertTrue(split.contains("version=".concat(info.localversion)), "The version should match the local version");
assertTrue(split.contains("url_ids=false-url"), "The false-url should be shown in the changeset tag");
MapWithAIPreferenceHelper.setMaximumAddition(20, false);
final int newMaxAdd = MapWithAIPreferenceHelper.getDefaultMaximumAddition() + 1;
MapWithAIPreferenceHelper.setMaximumAddition(newMaxAdd, false);
tags.clear();
hook.modifyChangesetTags(tags);
split = Arrays.asList(tags.get("mapwithai:options").split(";"));
assertEquals(3, split.size(), "There should be three ; in mapwithai:options");
assertTrue(split.contains("version=".concat(info.localversion)), "The version should match the local version");
assertTrue(split.contains("url_ids=false-url"), "The false-url should be shown in the changeset tag");
assertTrue(split.contains("maxadd=20"), "The maxadd should be 20");
assertTrue(split.contains("maxadd=" + Integer.toString(newMaxAdd)),
"The maxadd should be " + Integer.toString(newMaxAdd));
Bounds tBounds = new Bounds(0, 1, 1, 0);
MainApplication.getLayerManager()
@ -129,7 +131,8 @@ class MapWithAIUploadHookTest {
assertEquals(4, split.size(), "There should be four ; in mapwithai:options");
assertTrue(split.contains("version=".concat(info.localversion)), "The version should match the local version");
assertTrue(split.contains("url_ids=false-url"), "The false-url should be shown in the changeset tag");
assertTrue(split.contains("maxadd=20"), "The maxadd should be 20");
assertTrue(split.contains("maxadd=" + Integer.toString(newMaxAdd)),
"The maxadd should be " + Integer.toString(newMaxAdd));
assertTrue(split.contains("task=".concat(tBounds.toBBox().toStringCSV(","))),
"There should be a task in the mapwithai:options");
}