List<Way> selectedWays = OsmPrimitive.getFilteredList(selection, Way.class);
List<Relation> selectedRelations = OsmPrimitive.getFilteredList(selection, Relation.class);
List<Way> applicableWays = getApplicableWays(selectedWays, selectedNodes);
if (applicableWays == null) {
new Notification(
tr("The current selection cannot be used for splitting - no node is selected."))
.setIcon(JOptionPane.WARNING_MESSAGE)
.show();
return;
} else if (applicableWays.isEmpty()) {
new Notification(
tr("The selected nodes do not share the same way."))
.setIcon(JOptionPane.WARNING_MESSAGE)
.show();
return;
}
// If several ways have been found, remove ways that doesn't have selected node in the middle
if (applicableWays.size() > 1) {
WAY_LOOP:
for (Iterator<Way> it = applicableWays.iterator(); it.hasNext();) {
Way w = it.next();
for (Node n : selectedNodes) {
if (!w.isInnerNode(n)) {
it.remove();
continue WAY_LOOP;
}
}
}
}
if (applicableWays.isEmpty()) {
new Notification(
trn("The selected node is not in the middle of any way.",
"The selected nodes are not in the middle of any way.",
selectedNodes.size()))
.setIcon(JOptionPane.WARNING_MESSAGE)
.show();
return;
} else if (applicableWays.size() > 1) {
new Notification(
trn("There is more than one way using the node you selected. Please select the way also.",
"There is more than one way using the nodes you selected. Please select the way also.",
selectedNodes.size()))
.setIcon(JOptionPane.WARNING_MESSAGE)
.show();