Skip to content

Commit

Permalink
see #josm17580 #josm17581 #josm17582 #josm17583 #josm17584 #josm17585…
Browse files Browse the repository at this point in the history
… #josm17586 #josm17587 #josm17588 - remove deprecated api (patches by taylor.smock)
  • Loading branch information
don-vip committed Apr 11, 2019
1 parent 29669dc commit 92d9f4b
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 18 deletions.
Expand Up @@ -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
Expand Down Expand Up @@ -263,7 +264,7 @@ public List<String> populateMap(OsmPrimitive prim) {
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("[,;]")) {
Expand All @@ -273,7 +274,7 @@ private List<String> addRefs(String value) {
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();
Expand All @@ -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)) {
Expand All @@ -303,10 +304,10 @@ private List<Relation> removeWayFromRelationsCommand(Way way) {
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++) {
Expand All @@ -321,11 +322,11 @@ private Map<Relation, List<Integer>> getSavedPositions(Way way) {
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))
Expand Down
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down
Expand Up @@ -675,8 +675,8 @@ List<List<Way>> getDirectRouteBetweenWays(Way current, Way next) {
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;
}
Expand Down
Expand Up @@ -605,14 +605,14 @@ public Map<Relation, List<Integer>> getSavedPositions(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;
}
Expand Down
Expand Up @@ -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
Expand Down Expand Up @@ -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());
}
Expand All @@ -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());
}
Expand Down
Expand Up @@ -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.