Fix issue with some testing variables and methods

Signed-off-by: Taylor Smock <taylor.smock@kaart.com>
pull/1/head
Taylor Smock 2020-01-15 11:09:51 -07:00
rodzic 80bd7daa87
commit 2ac3edc1f0
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 625F6A74A3E4311A
2 zmienionych plików z 17 dodań i 4 usunięć

Wyświetl plik

@ -69,13 +69,14 @@ public class MapWithAIMoveAction extends JosmAction {
.collect(Collectors.toList());
ds.clearSelection(nodes);
nodes.stream().map(Node::getReferrers).forEach(ds::addSelected);
if (ds.getSelected().size() > maxAddition) {
if (ds.getSelected().size() > maxAddition && !(maxAddition == 0 && ExpertToggleAction.isExpert())) {
createMaxAddedDialog(maxAddition, ds.getSelected().size());
}
final Collection<OsmPrimitive> selected = limitCollection(ds, maxAddition);
final OsmDataLayer editLayer = getOsmDataLayer();
if (editLayer != null && !selected.isEmpty()
&& MapWithAIDataUtils.getAddedObjects() < maxAddition * MAX_ADD_MULTIPLIER) {
&& (MapWithAIDataUtils.getAddedObjects() < maxAddition * MAX_ADD_MULTIPLIER)
|| (maxAddition == 0 && ExpertToggleAction.isExpert())) {
final MapWithAIAddCommand command = new MapWithAIAddCommand(mapWithAI, editLayer, selected);
UndoRedoHandler.getInstance().add(command);
if (MapWithAIPreferenceHelper.isSwitchLayers()) {
@ -103,7 +104,12 @@ public class MapWithAIMoveAction extends JosmAction {
: ds.getSelected();
}
private static OsmDataLayer getOsmDataLayer() {
/**
* Get the OSM Data Layer to add MapWithAI data to
*
* @return An OSM data layer that data can be added to
*/
public static OsmDataLayer getOsmDataLayer() {
return MainApplication.getLayerManager().getLayersOfType(OsmDataLayer.class).stream()
.filter(OsmDataLayer::isVisible).filter(OsmDataLayer::isUploadable)
.filter(osmLayer -> !osmLayer.isLocked() && osmLayer.getClass().equals(OsmDataLayer.class)).findFirst()

Wyświetl plik

@ -6,6 +6,7 @@ import static org.openstreetmap.josm.tools.I18n.tr;
import java.awt.EventQueue;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@ -17,7 +18,9 @@ import org.openstreetmap.josm.command.Command;
import org.openstreetmap.josm.command.SequenceCommand;
import org.openstreetmap.josm.data.UndoRedoHandler;
import org.openstreetmap.josm.data.osm.DataSet;
import org.openstreetmap.josm.data.osm.Node;
import org.openstreetmap.josm.data.osm.OsmPrimitive;
import org.openstreetmap.josm.data.osm.Way;
import org.openstreetmap.josm.gui.layer.OsmDataLayer;
import org.openstreetmap.josm.plugins.mapwithai.MapWithAIPlugin;
import org.openstreetmap.josm.plugins.mapwithai.backend.GetDataRunnable;
@ -58,7 +61,11 @@ public class MapWithAIAddCommand extends Command implements Runnable {
super(mapWithAI);
this.mapWithAI = mapWithAI;
this.editable = editable;
this.primitives = selection;
Collection<Way> nodeReferrers = selection.parallelStream().filter(Node.class::isInstance).map(Node.class::cast)
.map(Node::getReferrers).flatMap(List::stream).filter(Way.class::isInstance).map(Way.class::cast)
.collect(Collectors.toList());
this.primitives = new HashSet<>(selection);
this.primitives.addAll(nodeReferrers);
sources = selection.parallelStream()
.map(prim -> new Pair<OsmPrimitive, String>(prim, prim.get(GetDataRunnable.MAPWITHAI_SOURCE_TAG_KEY)))
.filter(pair -> pair.b != null).collect(Collectors.toMap(pair -> pair.a, pair -> pair.b));