kopia lustrzana https://github.com/JOSM/MapWithAI
MapWithAIPreferences: Increase default max add and thus absolute max add
Signed-off-by: Taylor Smock <tsmock@fb.com>pull/1/head
rodzic
f53c8220c4
commit
793af99bf8
|
@ -8,6 +8,7 @@ import java.awt.event.ActionEvent;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.nio.file.Files;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -356,7 +357,7 @@ public class MapWithAILayer extends OsmDataLayer implements ActiveLayerChangeLis
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean autosave(File file) throws IOException {
|
public boolean autosave(File file) throws IOException {
|
||||||
// Consider a deletetion a "successful" save.
|
// Consider a deletion a "successful" save.
|
||||||
return file.delete();
|
return Files.deleteIfExists(file.toPath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAILayerInf
|
||||||
import org.openstreetmap.josm.spi.preferences.Config;
|
import org.openstreetmap.josm.spi.preferences.Config;
|
||||||
|
|
||||||
public final class MapWithAIPreferenceHelper {
|
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 AUTOSWITCHLAYERS = MapWithAIPlugin.NAME.concat(".autoswitchlayers");
|
||||||
private static final String MERGEBUILDINGADDRESSES = MapWithAIPlugin.NAME.concat(".mergebuildingaddresses");
|
private static final String MERGEBUILDINGADDRESSES = MapWithAIPlugin.NAME.concat(".mergebuildingaddresses");
|
||||||
private static final String MAXIMUMSELECTION = MapWithAIPlugin.NAME.concat(".maximumselection");
|
private static final String MAXIMUMSELECTION = MapWithAIPlugin.NAME.concat(".maximumselection");
|
||||||
|
|
|
@ -181,7 +181,7 @@ public class MergeDuplicateWays extends Command {
|
||||||
final Set<Map.Entry<Pair<Integer, Node>, Map<Integer, Node>>> duplicateEntrySet = duplicateNodes.entrySet();
|
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()
|
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(),
|
.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())))
|
entry.getValue().entrySet().iterator().next().getValue())))
|
||||||
.sorted((pair1, pair2) -> pair1.a.a - pair2.a.a).collect(Collectors.toSet());
|
.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())) {
|
if (compressed.parallelStream().anyMatch(entry -> entry.a.b.isDeleted() || entry.b.b.isDeleted())) {
|
||||||
|
@ -367,8 +367,8 @@ public class MergeDuplicateWays extends Command {
|
||||||
@Override
|
@Override
|
||||||
public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted,
|
public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted,
|
||||||
Collection<OsmPrimitive> added) {
|
Collection<OsmPrimitive> added) {
|
||||||
for (final Command command : commands) {
|
for (final Command currentCommand : commands) {
|
||||||
command.fillModifiedData(modified, deleted, added);
|
currentCommand.fillModifiedData(modified, deleted, added);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,12 +154,6 @@ public class StreetAddressOrder extends Test {
|
||||||
|
|
||||||
Way way = new Way();
|
Way way = new Way();
|
||||||
way.setNodes(centroids);
|
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;
|
double maxDistance = 100;
|
||||||
Node previousCentroid = centroids.get(0);
|
Node previousCentroid = centroids.get(0);
|
||||||
for (Node centroid : centroids) {
|
for (Node centroid : centroids) {
|
||||||
|
|
|
@ -71,7 +71,7 @@ public class MapWithAIDownloadSourceType implements IDownloadSourceType, LayerCh
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void changeEvent(MapWithAIInfo modified) {
|
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"))) {
|
.noneMatch(p -> p.contains("PreferenceDialog"))) {
|
||||||
if (MapWithAILayerInfo.getInstance().getLayers().contains(modified)) {
|
if (MapWithAILayerInfo.getInstance().getLayers().contains(modified)) {
|
||||||
this.cbDownloadMapWithAIData.setSelected(true);
|
this.cbDownloadMapWithAIData.setSelected(true);
|
||||||
|
|
|
@ -261,7 +261,8 @@ public class MapWithAIProvidersPanel extends JPanel {
|
||||||
extends MapWithAIProvidersPanel.MapWithAITableCellRenderer<List<String>> {
|
extends MapWithAIProvidersPanel.MapWithAITableCellRenderer<List<String>> {
|
||||||
|
|
||||||
MapWithAITypeTableCellRenderer() {
|
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) {
|
private static String joinList(List<String> list) {
|
||||||
|
|
|
@ -146,6 +146,7 @@ class MapWithAILayerTest {
|
||||||
getData.setMaximumDimensions(5_000);
|
getData.setMaximumDimensions(5_000);
|
||||||
getData.fork().join();
|
getData.fork().join();
|
||||||
assertTrue(ds.getSelected().isEmpty());
|
assertTrue(ds.getSelected().isEmpty());
|
||||||
|
MapWithAIPreferenceHelper.setMaximumAddition(5, false);
|
||||||
SwingUtilities.invokeAndWait(() -> ds.setSelected(ds.allNonDeletedCompletePrimitives()));
|
SwingUtilities.invokeAndWait(() -> ds.setSelected(ds.allNonDeletedCompletePrimitives()));
|
||||||
assertEquals(1, ds.getSelected().size());
|
assertEquals(1, ds.getSelected().size());
|
||||||
OsmPrimitive prim = ds.getSelected().iterator().next();
|
OsmPrimitive prim = ds.getSelected().iterator().next();
|
||||||
|
|
|
@ -106,7 +106,7 @@ class MapWithAIMoveActionTest {
|
||||||
|
|
||||||
moveAction.actionPerformed(null);
|
moveAction.actionPerformed(null);
|
||||||
Awaitility.await().atMost(Durations.ONE_SECOND).until(() -> ds.getPrimitiveById(way1) != 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");
|
"The duplicate node should have been replaced");
|
||||||
assertFalse(((Way) ds.getPrimitiveById(way2)).lastNode().hasKey(DuplicateCommand.KEY),
|
assertFalse(((Way) ds.getPrimitiveById(way2)).lastNode().hasKey(DuplicateCommand.KEY),
|
||||||
"The dupe key should no longer exist");
|
"The dupe key should no longer exist");
|
||||||
|
|
|
@ -109,14 +109,16 @@ class MapWithAIUploadHookTest {
|
||||||
assertTrue(split.contains("version=".concat(info.localversion)), "The version should match the local version");
|
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("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();
|
tags.clear();
|
||||||
hook.modifyChangesetTags(tags);
|
hook.modifyChangesetTags(tags);
|
||||||
split = Arrays.asList(tags.get("mapwithai:options").split(";"));
|
split = Arrays.asList(tags.get("mapwithai:options").split(";"));
|
||||||
assertEquals(3, split.size(), "There should be three ; in mapwithai:options");
|
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("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("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);
|
Bounds tBounds = new Bounds(0, 1, 1, 0);
|
||||||
MainApplication.getLayerManager()
|
MainApplication.getLayerManager()
|
||||||
|
@ -129,7 +131,8 @@ class MapWithAIUploadHookTest {
|
||||||
assertEquals(4, split.size(), "There should be four ; in mapwithai:options");
|
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("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("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(","))),
|
assertTrue(split.contains("task=".concat(tBounds.toBBox().toStringCSV(","))),
|
||||||
"There should be a task in the mapwithai:options");
|
"There should be a task in the mapwithai:options");
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue