kopia lustrzana https://github.com/JOSM/MapWithAI
More checkstyle and error prone fixes
Signed-off-by: Taylor Smock <taylor.smock@kaart.com>pull/1/head
rodzic
c9f2201a16
commit
f1d2e064c6
|
@ -39,7 +39,7 @@ public class RapiDPreferences implements SubPreferenceSetting {
|
||||||
final JLabel switchLayer = new JLabel(tr("Automatically switch layers"));
|
final JLabel switchLayer = new JLabel(tr("Automatically switch layers"));
|
||||||
final JLabel maximumAddition = new JLabel(tr("Maximum features (add)"));
|
final JLabel maximumAddition = new JLabel(tr("Maximum features (add)"));
|
||||||
final JPanel container = new JPanel(new GridBagLayout());
|
final JPanel container = new JPanel(new GridBagLayout());
|
||||||
container.setAlignmentY(JPanel.TOP_ALIGNMENT);
|
container.setAlignmentY(Component.TOP_ALIGNMENT);
|
||||||
final GridBagConstraints constraints = new GridBagConstraints();
|
final GridBagConstraints constraints = new GridBagConstraints();
|
||||||
|
|
||||||
possibleRapidApiUrl.setEditable(true);
|
possibleRapidApiUrl.setEditable(true);
|
||||||
|
@ -53,7 +53,7 @@ public class RapiDPreferences implements SubPreferenceSetting {
|
||||||
}
|
}
|
||||||
possibleRapidApiUrl.setSelectedItem(RapiDDataUtils.getRapiDURL());
|
possibleRapidApiUrl.setSelectedItem(RapiDDataUtils.getRapiDURL());
|
||||||
|
|
||||||
switchLayerCheckBox.setSelected(RapiDDataUtils.getSwitchLayers());
|
switchLayerCheckBox.setSelected(RapiDDataUtils.isSwitchLayers());
|
||||||
|
|
||||||
constraints.gridx = 0;
|
constraints.gridx = 0;
|
||||||
constraints.gridy = 0;
|
constraints.gridy = 0;
|
||||||
|
|
|
@ -86,45 +86,58 @@ public final class RapiDDataUtils {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
final DataSet temporaryDataSet = getDataReal(bbox);
|
final DataSet temporaryDataSet = getDataReal(getBbox());
|
||||||
synchronized (RapiDDataUtils.GetDataRunnable.class) {
|
synchronized (RapiDDataUtils.GetDataRunnable.class) {
|
||||||
dataSet.mergeFrom(temporaryDataSet);
|
getDataSet().mergeFrom(temporaryDataSet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
/**
|
||||||
|
* @return The {@code BBox} associated with this object
|
||||||
|
*/
|
||||||
|
public BBox getBbox() {
|
||||||
|
return bbox;
|
||||||
|
}
|
||||||
|
|
||||||
private static DataSet getDataReal(BBox bbox) {
|
/**
|
||||||
InputStream inputStream = null;
|
* @return The {@code DataSet} associated with this object
|
||||||
final DataSet dataSet = new DataSet();
|
*/
|
||||||
final String urlString = getRapiDURL();
|
public DataSet getDataSet() {
|
||||||
try {
|
return dataSet;
|
||||||
final URL url = new URL(urlString.replace("{bbox}", bbox.toStringCSV(",")));
|
}
|
||||||
final HttpClient client = HttpClient.create(url);
|
|
||||||
final StringBuilder defaultUserAgent = new StringBuilder();
|
private static DataSet getDataReal(BBox bbox) {
|
||||||
defaultUserAgent.append(client.getHeaders().get("User-Agent"));
|
InputStream inputStream = null;
|
||||||
if (defaultUserAgent.toString().trim().length() == 0) {
|
final DataSet dataSet = new DataSet();
|
||||||
defaultUserAgent.append("JOSM");
|
final String urlString = getRapiDURL();
|
||||||
}
|
try {
|
||||||
defaultUserAgent.append(tr("/ {0} {1}", RapiDPlugin.NAME, RapiDPlugin.getVersionInfo()));
|
final URL url = new URL(urlString.replace("{bbox}", bbox.toStringCSV(",")));
|
||||||
client.setHeader("User-Agent", defaultUserAgent.toString());
|
final HttpClient client = HttpClient.create(url);
|
||||||
Logging.debug("{0}: Getting {1}", RapiDPlugin.NAME, client.getURL().toString());
|
final StringBuilder defaultUserAgent = new StringBuilder();
|
||||||
final Response response = client.connect();
|
defaultUserAgent.append(client.getHeaders().get("User-Agent"));
|
||||||
inputStream = response.getContent();
|
if (defaultUserAgent.toString().trim().length() == 0) {
|
||||||
dataSet.mergeFrom(OsmReader.parseDataSet(inputStream, null));
|
defaultUserAgent.append("JOSM");
|
||||||
response.disconnect();
|
}
|
||||||
} catch (UnsupportedOperationException | IllegalDataException | IOException e) {
|
defaultUserAgent.append(tr("/ {0} {1}", RapiDPlugin.NAME, RapiDPlugin.getVersionInfo()));
|
||||||
Logging.debug(e);
|
client.setHeader("User-Agent", defaultUserAgent.toString());
|
||||||
} finally {
|
Logging.debug("{0}: Getting {1}", RapiDPlugin.NAME, client.getURL().toString());
|
||||||
if (inputStream != null) {
|
final Response response = client.connect();
|
||||||
try {
|
inputStream = response.getContent();
|
||||||
inputStream.close();
|
dataSet.mergeFrom(OsmReader.parseDataSet(inputStream, null));
|
||||||
} catch (final IOException e) {
|
response.disconnect();
|
||||||
Logging.debug(e);
|
} catch (UnsupportedOperationException | IllegalDataException | IOException e) {
|
||||||
|
Logging.debug(e);
|
||||||
|
} finally {
|
||||||
|
if (inputStream != null) {
|
||||||
|
try {
|
||||||
|
inputStream.close();
|
||||||
|
} catch (final IOException e) {
|
||||||
|
Logging.debug(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return dataSet;
|
||||||
}
|
}
|
||||||
return dataSet;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -263,7 +276,7 @@ public final class RapiDDataUtils {
|
||||||
/**
|
/**
|
||||||
* @return {@code true} if we want to automatically switch layers
|
* @return {@code true} if we want to automatically switch layers
|
||||||
*/
|
*/
|
||||||
public static boolean getSwitchLayers() {
|
public static boolean isSwitchLayers() {
|
||||||
return Config.getPref().getBoolean(RapiDPlugin.NAME.concat(".autoswitchlayers"), true);
|
return Config.getPref().getBoolean(RapiDPlugin.NAME.concat(".autoswitchlayers"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class RapiDMoveAction extends JosmAction {
|
||||||
if (editLayer != null) {
|
if (editLayer != null) {
|
||||||
final RapiDAddCommand command = new RapiDAddCommand(rapid, editLayer, selected);
|
final RapiDAddCommand command = new RapiDAddCommand(rapid, editLayer, selected);
|
||||||
UndoRedoHandler.getInstance().add(command);
|
UndoRedoHandler.getInstance().add(command);
|
||||||
if (RapiDDataUtils.getSwitchLayers()) {
|
if (RapiDDataUtils.isSwitchLayers()) {
|
||||||
MainApplication.getLayerManager().setActiveLayer(editLayer);
|
MainApplication.getLayerManager().setActiveLayer(editLayer);
|
||||||
final DataSet editable = editLayer.getDataSet();
|
final DataSet editable = editLayer.getDataSet();
|
||||||
editable.setSelected(
|
editable.setSelected(
|
||||||
|
|
|
@ -14,35 +14,36 @@ import org.openstreetmap.josm.data.osm.Way;
|
||||||
public class AddNodeToWayCommand extends Command {
|
public class AddNodeToWayCommand extends Command {
|
||||||
private final Node toAddNode;
|
private final Node toAddNode;
|
||||||
private final Way way;
|
private final Way way;
|
||||||
private final Node first;
|
private final Node firstNode;
|
||||||
private final Node second;
|
private final Node secondNode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a node to a way in an undoable manner
|
* Add a node to a way in an undoable manner
|
||||||
*
|
*
|
||||||
* @param toAddNode The node to add
|
* @param toAddNode The node to add
|
||||||
* @param way The way to add the node to
|
* @param way The way to add the node to
|
||||||
* @param first The node that comes before the node to add
|
* @param firstNode The node that comes before the node to add
|
||||||
* @param second The node that comes after the node to add
|
* @param secondNode The node that comes after the node to add
|
||||||
*/
|
*/
|
||||||
public AddNodeToWayCommand(Node toAddNode, Way way, Node first, Node second) {
|
public AddNodeToWayCommand(Node toAddNode, Way way, Node first, Node second) {
|
||||||
super(way.getDataSet());
|
super(way.getDataSet());
|
||||||
this.toAddNode = toAddNode;
|
this.toAddNode = toAddNode;
|
||||||
this.way = way;
|
this.way = way;
|
||||||
this.first = first;
|
this.firstNode = first;
|
||||||
this.second = second;
|
this.secondNode = second;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean executeCommand() {
|
public boolean executeCommand() {
|
||||||
final int index = Math.max(way.getNodes().indexOf(first), way.getNodes().indexOf(second));
|
final int index = Math.max(getWay().getNodes().indexOf(getFirstNode()),
|
||||||
way.addNode(index, toAddNode);
|
getWay().getNodes().indexOf(getSecondNode()));
|
||||||
|
getWay().addNode(index, getToAddNode());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void undoCommand() {
|
public void undoCommand() {
|
||||||
way.removeNode(toAddNode);
|
getWay().removeNode(getToAddNode());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -53,6 +54,34 @@ public class AddNodeToWayCommand 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) {
|
||||||
modified.addAll(Arrays.asList(toAddNode, way));
|
modified.addAll(Arrays.asList(getToAddNode(), getWay()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {@link Node} to add to {@link Way}
|
||||||
|
*/
|
||||||
|
public Node getToAddNode() {
|
||||||
|
return toAddNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {@link Way} that we are adding a {@link Node} to
|
||||||
|
*/
|
||||||
|
public Way getWay() {
|
||||||
|
return way;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {@link Node} that we are adding another {@link Node} after.
|
||||||
|
*/
|
||||||
|
public Node getFirstNode() {
|
||||||
|
return firstNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {@link Node} that we are adding another {@link Node} before.
|
||||||
|
*/
|
||||||
|
public Node getSecondNode() {
|
||||||
|
return secondNode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,11 +150,11 @@ public class CreateConnectionsCommand extends Command {
|
||||||
missingPrimitives.put(i, new Pair<>(id, type));
|
missingPrimitives.put(i, new Pair<>(id, type));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
getMissingPrimitives(dataSet, primitiveConnections, missingPrimitives);
|
obtainMissingPrimitives(dataSet, primitiveConnections, missingPrimitives);
|
||||||
return primitiveConnections;
|
return primitiveConnections;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void getMissingPrimitives(DataSet dataSet, OsmPrimitive[] primitiveConnections,
|
private static void obtainMissingPrimitives(DataSet dataSet, OsmPrimitive[] primitiveConnections,
|
||||||
Map<Integer, Pair<Long, OsmPrimitiveType>> missingPrimitives) {
|
Map<Integer, Pair<Long, OsmPrimitiveType>> missingPrimitives) {
|
||||||
final Map<PrimitiveId, Integer> ids = missingPrimitives.entrySet().stream().collect(Collectors
|
final Map<PrimitiveId, Integer> ids = missingPrimitives.entrySet().stream().collect(Collectors
|
||||||
.toMap(entry -> new SimplePrimitiveId(entry.getValue().a, entry.getValue().b), Entry::getKey));
|
.toMap(entry -> new SimplePrimitiveId(entry.getValue().a, entry.getValue().b), Entry::getKey));
|
||||||
|
|
|
@ -25,14 +25,13 @@ public class MovePrimitiveDataSetCommand extends Command {
|
||||||
private final DataSet to;
|
private final DataSet to;
|
||||||
private final DataSet from;
|
private final DataSet from;
|
||||||
private final Collection<OsmPrimitive> primitives;
|
private final Collection<OsmPrimitive> primitives;
|
||||||
private SequenceCommand command;
|
private SequenceCommand command = null;
|
||||||
|
|
||||||
public MovePrimitiveDataSetCommand(DataSet to, DataSet from, Collection<OsmPrimitive> primitives) {
|
public MovePrimitiveDataSetCommand(DataSet to, DataSet from, Collection<OsmPrimitive> primitives) {
|
||||||
super(to);
|
super(to);
|
||||||
this.to = to;
|
this.to = to;
|
||||||
this.from = from;
|
this.from = from;
|
||||||
this.primitives = primitives;
|
this.primitives = primitives;
|
||||||
command = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -52,22 +51,23 @@ public class MovePrimitiveDataSetCommand extends Command {
|
||||||
* @param selection The primitives to move
|
* @param selection The primitives to move
|
||||||
*/
|
*/
|
||||||
public SequenceCommand moveCollection(DataSet from, DataSet to, Collection<OsmPrimitive> selection) {
|
public SequenceCommand moveCollection(DataSet from, DataSet to, Collection<OsmPrimitive> selection) {
|
||||||
|
SequenceCommand returnCommand = null;
|
||||||
if (from == null || to.isLocked() || from.isLocked() || to.equals(from)) {
|
if (from == null || to.isLocked() || from.isLocked() || to.equals(from)) {
|
||||||
Logging.error("{0}: Cannot move primitives from {1} to {2}", RapiDPlugin.NAME, from, to);
|
Logging.error("{0}: Cannot move primitives from {1} to {2}", RapiDPlugin.NAME, from, to);
|
||||||
return null;
|
} else {
|
||||||
|
final List<Command> commands = new ArrayList<>();
|
||||||
|
|
||||||
|
final Collection<OsmPrimitive> allNeededPrimitives = new ArrayList<>();
|
||||||
|
RapiDDataUtils.addPrimitivesToCollection(allNeededPrimitives, selection);
|
||||||
|
|
||||||
|
commands.add(new DeletePrimitivesCommand(from, selection, true));
|
||||||
|
final AddPrimitivesCommand addPrimitivesCommand = new AddPrimitivesCommand(to, allNeededPrimitives, selection);
|
||||||
|
commands.add(addPrimitivesCommand);
|
||||||
|
|
||||||
|
returnCommand = new SequenceCommand(trn("Move {0} OSM Primitive between data sets",
|
||||||
|
"Move {0} OSM Primitives between data sets", selection.size(), selection.size()), commands);
|
||||||
}
|
}
|
||||||
|
return returnCommand;
|
||||||
final List<Command> commands = new ArrayList<>();
|
|
||||||
|
|
||||||
final Collection<OsmPrimitive> allNeededPrimitives = new ArrayList<>();
|
|
||||||
RapiDDataUtils.addPrimitivesToCollection(allNeededPrimitives, selection);
|
|
||||||
|
|
||||||
commands.add(new DeletePrimitivesCommand(from, selection, true));
|
|
||||||
final AddPrimitivesCommand addPrimitivesCommand = new AddPrimitivesCommand(to, allNeededPrimitives, selection);
|
|
||||||
commands.add(addPrimitivesCommand);
|
|
||||||
|
|
||||||
return new SequenceCommand(trn("Move {0} OSM Primitive between data sets",
|
|
||||||
"Move {0} OSM Primitives between data sets", selection.size(), selection.size()), commands);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -43,16 +43,16 @@ public class RapiDPreferencesTest {
|
||||||
Assert.assertEquals(tabs + 1, pane.getPluginPreference().getTabPane().getTabCount());
|
Assert.assertEquals(tabs + 1, pane.getPluginPreference().getTabPane().getTabCount());
|
||||||
Assert.assertEquals(pane.getPluginPreference(), preferences.getTabPreferenceSetting(pane));
|
Assert.assertEquals(pane.getPluginPreference(), preferences.getTabPreferenceSetting(pane));
|
||||||
|
|
||||||
final boolean switchLayers = RapiDDataUtils.getSwitchLayers();
|
final boolean switchLayers = RapiDDataUtils.isSwitchLayers();
|
||||||
|
|
||||||
Assert.assertEquals(switchLayers, preferences.getSwitchLayerCheckBox().isSelected());
|
Assert.assertEquals(switchLayers, preferences.getSwitchLayerCheckBox().isSelected());
|
||||||
preferences.ok();
|
preferences.ok();
|
||||||
Assert.assertEquals(switchLayers, RapiDDataUtils.getSwitchLayers());
|
Assert.assertEquals(switchLayers, RapiDDataUtils.isSwitchLayers());
|
||||||
|
|
||||||
preferences.getSwitchLayerCheckBox().setSelected(!switchLayers);
|
preferences.getSwitchLayerCheckBox().setSelected(!switchLayers);
|
||||||
Assert.assertNotEquals(!switchLayers, RapiDDataUtils.getSwitchLayers());
|
Assert.assertNotEquals(!switchLayers, RapiDDataUtils.isSwitchLayers());
|
||||||
preferences.ok();
|
preferences.ok();
|
||||||
Assert.assertEquals(!switchLayers, RapiDDataUtils.getSwitchLayers());
|
Assert.assertEquals(!switchLayers, RapiDDataUtils.isSwitchLayers());
|
||||||
|
|
||||||
final Object tmp = preferences.getMaximumAdditionSpinner().getModel();
|
final Object tmp = preferences.getMaximumAdditionSpinner().getModel();
|
||||||
SpinnerNumberModel spinnerModel = null;
|
SpinnerNumberModel spinnerModel = null;
|
||||||
|
|
|
@ -22,7 +22,7 @@ public class RapiDMoveActionTest {
|
||||||
public JOSMTestRules test = new JOSMTestRules().preferences().main().projection();
|
public JOSMTestRules test = new JOSMTestRules().preferences().main().projection();
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setUp() {
|
||||||
moveAction = new RapiDMoveAction();
|
moveAction = new RapiDMoveAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ import org.openstreetmap.josm.data.osm.DataSet;
|
||||||
import org.openstreetmap.josm.data.osm.Node;
|
import org.openstreetmap.josm.data.osm.Node;
|
||||||
import org.openstreetmap.josm.data.osm.OsmPrimitive;
|
import org.openstreetmap.josm.data.osm.OsmPrimitive;
|
||||||
import org.openstreetmap.josm.data.osm.Way;
|
import org.openstreetmap.josm.data.osm.Way;
|
||||||
import org.openstreetmap.josm.testutils.JOSMTestRules;;
|
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
||||||
|
|
||||||
public class AddNodeToWayCommandTest {
|
public class AddNodeToWayCommandTest {
|
||||||
private Node toAdd;
|
private Node toAdd;
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class MovePrimitiveDataSetCommandTest {
|
||||||
from.addPrimitive(way1);
|
from.addPrimitive(way1);
|
||||||
from.addPrimitive(new Node(new LatLon(-0.1, 0.1)));
|
from.addPrimitive(new Node(new LatLon(-0.1, 0.1)));
|
||||||
|
|
||||||
MovePrimitiveDataSetCommand move = new MovePrimitiveDataSetCommand(to, from, Collections.singleton(way1));
|
final MovePrimitiveDataSetCommand move = new MovePrimitiveDataSetCommand(to, from, Collections.singleton(way1));
|
||||||
Assert.assertEquals(0, to.allPrimitives().size());
|
Assert.assertEquals(0, to.allPrimitives().size());
|
||||||
Assert.assertEquals(4, from.allPrimitives().size());
|
Assert.assertEquals(4, from.allPrimitives().size());
|
||||||
|
|
||||||
|
@ -51,6 +51,22 @@ public class MovePrimitiveDataSetCommandTest {
|
||||||
Assert.assertEquals(0, to.allPrimitives().size());
|
Assert.assertEquals(0, to.allPrimitives().size());
|
||||||
Assert.assertEquals(4, from.allPrimitives().size());
|
Assert.assertEquals(4, from.allPrimitives().size());
|
||||||
Assert.assertEquals(from, way1.getDataSet());
|
Assert.assertEquals(from, way1.getDataSet());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMovePrimitivesAdditionalData() {
|
||||||
|
final Collection<OsmPrimitive> added = new ArrayList<>();
|
||||||
|
final Collection<OsmPrimitive> modified = new ArrayList<>();
|
||||||
|
final Collection<OsmPrimitive> deleted = new ArrayList<>();
|
||||||
|
final DataSet to = new DataSet();
|
||||||
|
final DataSet from = new DataSet();
|
||||||
|
final Way way1 = TestUtils.newWay("highway=tertiary", new Node(new LatLon(0, 0)),
|
||||||
|
new Node(new LatLon(0.1, 0.1)));
|
||||||
|
way1.getNodes().stream().forEach(node -> from.addPrimitive(node));
|
||||||
|
from.addPrimitive(way1);
|
||||||
|
from.addPrimitive(new Node(new LatLon(-0.1, 0.1)));
|
||||||
|
|
||||||
|
MovePrimitiveDataSetCommand move = new MovePrimitiveDataSetCommand(to, from, Collections.singleton(way1));
|
||||||
|
|
||||||
way1.firstNode().put("highway", "stop");
|
way1.firstNode().put("highway", "stop");
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,8 @@ import org.openstreetmap.josm.data.osm.Way;
|
||||||
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
||||||
|
|
||||||
public class RapiDAddComandTest {
|
public class RapiDAddComandTest {
|
||||||
|
private final static String HIGHWAY_RESIDENTIAL = "highway=residential";
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public JOSMTestRules test = new JOSMTestRules();
|
public JOSMTestRules test = new JOSMTestRules();
|
||||||
|
|
||||||
|
@ -23,10 +25,10 @@ public class RapiDAddComandTest {
|
||||||
public void testMoveCollection() {
|
public void testMoveCollection() {
|
||||||
final DataSet ds1 = new DataSet();
|
final DataSet ds1 = new DataSet();
|
||||||
final DataSet ds2 = new DataSet();
|
final DataSet ds2 = new DataSet();
|
||||||
final Way way1 = TestUtils.newWay("highway=residential", new Node(new LatLon(0, 0)),
|
final Way way1 = TestUtils.newWay(HIGHWAY_RESIDENTIAL, new Node(new LatLon(0, 0)),
|
||||||
new Node(new LatLon(0, 0.1)));
|
new Node(new LatLon(0, 0.1)));
|
||||||
final Way way2 = TestUtils.newWay("highway=residential", new Node(new LatLon(-0.1, -0.2)), way1.firstNode());
|
final Way way2 = TestUtils.newWay(HIGHWAY_RESIDENTIAL, new Node(new LatLon(-0.1, -0.2)), way1.firstNode());
|
||||||
final Way way3 = TestUtils.newWay("highway=residential", new Node(new LatLon(65, 65)),
|
final Way way3 = TestUtils.newWay(HIGHWAY_RESIDENTIAL, new Node(new LatLon(65, 65)),
|
||||||
new Node(new LatLon(66, 66)));
|
new Node(new LatLon(66, 66)));
|
||||||
for (final Way way : Arrays.asList(way1, way2, way3)) {
|
for (final Way way : Arrays.asList(way1, way2, way3)) {
|
||||||
for (final Node node : way.getNodes()) {
|
for (final Node node : way.getNodes()) {
|
||||||
|
@ -68,14 +70,14 @@ public class RapiDAddComandTest {
|
||||||
@Test
|
@Test
|
||||||
public void testCreateConnections() {
|
public void testCreateConnections() {
|
||||||
final DataSet ds1 = new DataSet();
|
final DataSet ds1 = new DataSet();
|
||||||
final Way way1 = TestUtils.newWay("highway=residential", new Node(new LatLon(0, 0)),
|
final Way way1 = TestUtils.newWay(HIGHWAY_RESIDENTIAL, new Node(new LatLon(0, 0)),
|
||||||
new Node(new LatLon(0, 0.15)));
|
new Node(new LatLon(0, 0.15)));
|
||||||
final Way way2 = TestUtils.newWay("highway=residential", new Node(new LatLon(0, 0.05)),
|
final Way way2 = TestUtils.newWay(HIGHWAY_RESIDENTIAL, new Node(new LatLon(0, 0.05)),
|
||||||
new Node(new LatLon(0.05, 0.2)));
|
new Node(new LatLon(0.05, 0.2)));
|
||||||
way2.firstNode().put("conn",
|
way2.firstNode().put("conn",
|
||||||
"w".concat(Long.toString(way1.getUniqueId())).concat(",n")
|
"w".concat(Long.toString(way1.getUniqueId())).concat(",n")
|
||||||
.concat(Long.toString(way1.firstNode().getUniqueId())).concat(",n")
|
.concat(Long.toString(way1.firstNode().getUniqueId())).concat(",n")
|
||||||
.concat(Long.toString(way1.lastNode().getUniqueId())));
|
.concat(Long.toString(way1.lastNode().getUniqueId())));
|
||||||
way1.getNodes().forEach(node -> ds1.addPrimitive(node));
|
way1.getNodes().forEach(node -> ds1.addPrimitive(node));
|
||||||
way2.getNodes().forEach(node -> ds1.addPrimitive(node));
|
way2.getNodes().forEach(node -> ds1.addPrimitive(node));
|
||||||
ds1.addPrimitive(way2);
|
ds1.addPrimitive(way2);
|
||||||
|
@ -84,7 +86,7 @@ public class RapiDAddComandTest {
|
||||||
Assert.assertEquals(3, way1.getNodesCount());
|
Assert.assertEquals(3, way1.getNodesCount());
|
||||||
Assert.assertFalse(way1.isFirstLastNode(way2.firstNode()));
|
Assert.assertFalse(way1.isFirstLastNode(way2.firstNode()));
|
||||||
|
|
||||||
final Way way3 = TestUtils.newWay("highway=residential", new Node(new LatLon(0, 0)),
|
final Way way3 = TestUtils.newWay(HIGHWAY_RESIDENTIAL, new Node(new LatLon(0, 0)),
|
||||||
new Node(new LatLon(-0.1, -0.1)));
|
new Node(new LatLon(-0.1, -0.1)));
|
||||||
way3.firstNode().put("dupe", "n".concat(Long.toString(way1.firstNode().getUniqueId())));
|
way3.firstNode().put("dupe", "n".concat(Long.toString(way1.firstNode().getUniqueId())));
|
||||||
way3.getNodes().forEach(node -> ds1.addPrimitive(node));
|
way3.getNodes().forEach(node -> ds1.addPrimitive(node));
|
||||||
|
@ -100,9 +102,9 @@ public class RapiDAddComandTest {
|
||||||
public void testCreateConnectionsUndo() {
|
public void testCreateConnectionsUndo() {
|
||||||
final DataSet osmData = new DataSet();
|
final DataSet osmData = new DataSet();
|
||||||
final DataSet rapidData = new DataSet();
|
final DataSet rapidData = new DataSet();
|
||||||
final Way way1 = TestUtils.newWay("highway=residential", new Node(new LatLon(0, 0)),
|
final Way way1 = TestUtils.newWay(HIGHWAY_RESIDENTIAL, new Node(new LatLon(0, 0)),
|
||||||
new Node(new LatLon(0.1, 0.1)));
|
new Node(new LatLon(0.1, 0.1)));
|
||||||
final Way way2 = TestUtils.newWay("highway=residential", new Node(new LatLon(-0.1, -0.1)),
|
final Way way2 = TestUtils.newWay(HIGHWAY_RESIDENTIAL, new Node(new LatLon(-0.1, -0.1)),
|
||||||
new Node(new LatLon(0.1, 0.1)));
|
new Node(new LatLon(0.1, 0.1)));
|
||||||
way1.getNodes().forEach(node -> rapidData.addPrimitive(node));
|
way1.getNodes().forEach(node -> rapidData.addPrimitive(node));
|
||||||
way2.getNodes().forEach(node -> osmData.addPrimitive(node));
|
way2.getNodes().forEach(node -> osmData.addPrimitive(node));
|
||||||
|
|
Ładowanie…
Reference in New Issue