Skip to content
Permalink
Browse files

see #josm17580 #josm17581 #josm17582 #josm17583 #josm17584 #josm17585…

… #josm17586 #josm17587 #josm17588 - remove deprecated api (patches by taylor.smock)
  • Loading branch information...
don-vip committed Apr 11, 2019
1 parent 29669dc commit 92d9f4be6e295bcae86ff9f1a1a1781f00d0f27b
@@ -47,6 +47,7 @@
import org.openstreetmap.josm.plugins.pt_assistant.utils.StopUtils;
import org.openstreetmap.josm.tools.Logging;
import org.openstreetmap.josm.tools.UserCancelException;
import org.openstreetmap.josm.tools.Utils;

/**
* Sorts the stop positions in a PT route according to the assigned ways
@@ -263,7 +264,7 @@ private void action() {
return refs;
}

private List<String> addRefs(String value) {
private static List<String> addRefs(String value) {
List<String> refs = new ArrayList<>();
if (new RegexValidator("\\w+([,;].+)*").isValid(value)) {
for (String ref : value.split("[,;]")) {
@@ -273,7 +274,7 @@ private void action() {
return refs;
}

private String getRefs(Set<String> refs) {
private static String getRefs(Set<String> refs) {
StringBuilder sb = new StringBuilder();
if (refs.isEmpty())
return sb.toString();
@@ -285,9 +286,9 @@ private String getRefs(Set<String> refs) {
return sb.toString().substring(0, sb.length() - 1);
}

private List<Relation> removeWayFromRelationsCommand(Way way) {
private static List<Relation> removeWayFromRelationsCommand(Way way) {
List<Command> commands = new ArrayList<>();
List<Relation> referrers = OsmPrimitive.getFilteredList(way.getReferrers(), Relation.class);
List<Relation> referrers = new ArrayList<>(Utils.filteredCollection(way.getReferrers(), Relation.class));
List<Relation> parentStopAreaRelation = new ArrayList<>();
referrers.forEach(r -> {
if (StopUtils.isStopArea(r)) {
@@ -303,10 +304,10 @@ private String getRefs(Set<String> refs) {
return parentStopAreaRelation;
}

private Map<Relation, List<Integer>> getSavedPositions(Way way) {
private static Map<Relation, List<Integer>> getSavedPositions(Way way) {

Map<Relation, List<Integer>> savedPositions = new HashMap<>();
List<Relation> referrers = OsmPrimitive.getFilteredList(way.getReferrers(), Relation.class);
List<Relation> referrers = new ArrayList<>(Utils.filteredCollection(way.getReferrers(), Relation.class));

for (Relation curr : referrers) {
for (int j = 0; j < curr.getMembersCount(); j++) {
@@ -321,11 +322,11 @@ private String getRefs(Set<String> refs) {
return savedPositions;
}

private List<Command> updateRelation(Map<Relation, List<Integer>> savedPositions, Node platformNode,
private static List<Command> updateRelation(Map<Relation, List<Integer>> savedPositions, Node platformNode,
Way platformWay, List<Relation> parentStopAreaRelation) {
Map<Relation, Relation> changingRelation = new HashMap<>();
Map<Relation, Integer> memberOffset = new HashMap<>();
List<Relation> referrers = OsmPrimitive.getFilteredList(platformNode.getReferrers(), Relation.class);
List<Relation> referrers = new ArrayList<>(Utils.filteredCollection(platformNode.getReferrers(), Relation.class));

savedPositions.forEach((r, positions) -> positions.forEach(i -> {
if (!changingRelation.containsKey(r))
@@ -32,6 +32,7 @@
import org.openstreetmap.josm.gui.Notification;
import org.openstreetmap.josm.plugins.pt_assistant.utils.StopUtils;
import org.openstreetmap.josm.tools.Shortcut;
import org.openstreetmap.josm.tools.Utils;

/**
* Extracts node from its ways and adds the public transport tags to it.
@@ -62,7 +63,7 @@ public ExtractPlatformNodeAction() {
public void actionPerformed(ActionEvent e) {
DataSet ds = getLayerManager().getEditDataSet();
Collection<OsmPrimitive> selection = ds.getSelected();
List<Node> selectedNodes = OsmPrimitive.getFilteredList(selection, Node.class);
List<Node> selectedNodes = new ArrayList<>(Utils.filteredCollection(selection, Node.class));
if (selectedNodes.size() != 1) {
new Notification(tr("This action requires single node to be selected."))
.setIcon(JOptionPane.WARNING_MESSAGE)
@@ -675,8 +675,8 @@ Way findNextWayAfterDownload(Way way, Node node1, Node node2) {
List<Relation> r1;
List<Relation> r2;
try {
r1 = OsmPrimitive.getFilteredList(current.getReferrers(), Relation.class);
r2 = OsmPrimitive.getFilteredList(next.getReferrers(), Relation.class);
r1 = new ArrayList<>(Utils.filteredCollection(current.getReferrers(), Relation.class));
r2 = new ArrayList<>(Utils.filteredCollection(next.getReferrers(), Relation.class));
} catch (Exception e) {
return list;
}
@@ -605,14 +605,14 @@ public Command getRemoveRoundaboutFromRelationsCommand(Way roundabout) {
return savedPositions;
}

private List<Relation> getPTRouteParents(Way roundabout) {
List<Relation> referrers = OsmPrimitive.getFilteredList(roundabout.getReferrers(), Relation.class);
private static List<Relation> getPTRouteParents(Way roundabout) {
List<Relation> referrers = new ArrayList<>(Utils.filteredCollection(roundabout.getReferrers(), Relation.class));
referrers.removeIf(r -> (!RouteUtils.isPTRoute(r) && !RouteUtils.isBicycleRoute(r)));
return referrers;
}

private List<Relation> getRouteParents(Way roundabout) {
List<Relation> referrers = OsmPrimitive.getFilteredList(roundabout.getReferrers(), Relation.class);
private static List<Relation> getRouteParents(Way roundabout) {
List<Relation> referrers = new ArrayList<>(Utils.filteredCollection(roundabout.getReferrers(), Relation.class));
referrers.removeIf(r -> !RouteUtils.isRoute(r));
return referrers;
}
@@ -14,6 +14,7 @@
import org.openstreetmap.josm.data.validation.Test;
import org.openstreetmap.josm.data.validation.TestError;
import org.openstreetmap.josm.plugins.pt_assistant.utils.StopUtils;
import org.openstreetmap.josm.tools.Utils;

/**
* Performs tests of the stop area relations
@@ -89,7 +90,7 @@ protected void performStopAreaRelationsTest() {
if (StopUtils.isStopPosition(member)) {

// Create a list of assigned route relations
for (Relation referrer : OsmPrimitive.getFilteredList(member.getReferrers(), Relation.class)) {
for (Relation referrer : Utils.filteredCollection(member.getReferrers(), Relation.class)) {
if (referrer.get("type") == "route") {
stopPositionRelationIds.put(referrer.getId(), referrer.getId());
}
@@ -98,7 +99,7 @@ protected void performStopAreaRelationsTest() {
} else if (StopUtils.verifyStopAreaPlatform(member)) {

// Create a list of assigned route relations
for (Relation referrer : OsmPrimitive.getFilteredList(member.getReferrers(), Relation.class)) {
for (Relation referrer : Utils.filteredCollection(member.getReferrers(), Relation.class)) {
if (referrer.get("type") == "route") {
platformRelationIds.put(referrer.getId(), referrer.getId());
}
@@ -431,5 +431,4 @@ protected static Command fixErrorByRemovingWay(TestError testError) {

return new ChangeCommand(originalRelation, modifiedRelation);
}

}

0 comments on commit 92d9f4b

Please sign in to comment.
You can’t perform that action at this time.