Changeset 34976 in osm
- Timestamp:
- 2019-04-13T15:12:48+02:00 (6 years ago)
- Location:
- applications/editors/josm/plugins
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/tracer2/src/org/openstreetmap/josm/plugins/tracer2/ConnectWays.java
r33700 r34976 25 25 import org.openstreetmap.josm.plugins.tracer2.preferences.ServerParam; 26 26 import org.openstreetmap.josm.tools.Pair; 27 import org.openstreetmap.josm.tools.Utils; 27 28 28 29 public final class ConnectWays { … … 70 71 private static List<Way> getWaysOfNode(Node node) { 71 72 List<Way> ways; 72 ways = OsmPrimitive.getFilteredList(node.getReferrers(), Way.class);73 ways = new LinkedList<>(Utils.filteredCollection(node.getReferrers(), Way.class)); 73 74 return ways; 74 75 } -
applications/editors/josm/plugins/turnlanes/src/org/openstreetmap/josm/plugins/turnlanes/gui/RoadGui.java
r34926 r34976 39 39 import org.openstreetmap.josm.plugins.turnlanes.model.Lane; 40 40 import org.openstreetmap.josm.plugins.turnlanes.model.Road; 41 import org.openstreetmap.josm.plugins.turnlanes.model. Utils;41 import org.openstreetmap.josm.plugins.turnlanes.model.TurnlanesUtils; 42 42 43 43 class RoadGui { … … 629 629 final Node n = end.getJunction().getNode(); 630 630 for (Way w : org.openstreetmap.josm.tools.Utils.filteredCollection(n.getReferrers(), Way.class)) { 631 if (w.getNodesCount() > 1 && !end.getWay().equals(w) && w.isFirstLastNode(n) && Utils.isRoad(w)) {631 if (w.getNodesCount() > 1 && !end.getWay().equals(w) && w.isFirstLastNode(n) && TurnlanesUtils.isRoad(w)) { 632 632 final Node nextNode = w.firstNode().equals(n) ? w.getNode(1) : w.getNode(w.getNodesCount() - 2); 633 633 final Point2D nextNodeLoc = getContainer().translateAndScale(loc(nextNode)); -
applications/editors/josm/plugins/turnlanes/src/org/openstreetmap/josm/plugins/turnlanes/model/Lane.java
r34566 r34976 69 69 70 70 static int getRegularCount(Way w, Node end) { 71 final int count = Utils.parseIntTag(w, "lanes");71 final int count = TurnlanesUtils.parseIntTag(w, "lanes"); 72 72 final boolean forward = w.lastNode().equals(end); 73 73 … … 89 89 private static int getRegularCountTwoWay(Way w, boolean forward, final int count) { 90 90 if (w.get("lanes:backward") != null) { 91 final int backwardCount = Utils.parseIntTag(w, "lanes:backward");91 final int backwardCount = TurnlanesUtils.parseIntTag(w, "lanes:backward"); 92 92 return forward ? count - backwardCount : backwardCount; 93 93 } 94 94 95 95 if (w.get("lanes:forward") != null) { 96 final int forwardCount = Utils.parseIntTag(w, "lanes:forward");96 final int forwardCount = TurnlanesUtils.parseIntTag(w, "lanes:forward"); 97 97 return forward ? forwardCount : count - forwardCount; 98 98 } … … 205 205 r.addMember(new RelationMember(Constants.TURN_ROLE_VIA, getOutgoingJunction().getNode())); 206 206 } else { 207 for (Way w : Utils.flattenVia(getOutgoingJunction().getNode(), via, to.getJunction().getNode())) {207 for (Way w : TurnlanesUtils.flattenVia(getOutgoingJunction().getNode(), via, to.getJunction().getNode())) { 208 208 r.addMember(new RelationMember(Constants.TURN_ROLE_VIA, w)); 209 209 } -
applications/editors/josm/plugins/turnlanes/src/org/openstreetmap/josm/plugins/turnlanes/model/ModelContainer.java
r34926 r34976 45 45 46 46 for (Node n : new ArrayList<>(closedNodes)) { 47 for (Way w : Utils.filterRoads(n.getReferrers())) {47 for (Way w : TurnlanesUtils.filterRoads(n.getReferrers())) { 48 48 if (w.isFirstLastNode(n)) { 49 49 closed &= close(closedNodes, closedWays, w); … … 80 80 81 81 final List<Way> via = new ArrayList<>(); 82 for (RelationMember m : Utils.getMembers(r, Constants.TURN_ROLE_VIA)) {82 for (RelationMember m : TurnlanesUtils.getMembers(r, Constants.TURN_ROLE_VIA)) { 83 83 if (m.isWay()) { 84 84 closed &= !closedWays.add(m.getWay()); … … 90 90 91 91 if (!via.isEmpty()) { 92 final Way from = Utils.getMemberWay(r, Constants.TURN_ROLE_FROM);93 final Way to = Utils.getMemberWay(r, Constants.TURN_ROLE_TO);94 95 closed &= !closedNodes.add( Utils.lineUp(from, via.get(0)));96 closed &= !closedNodes.add( Utils.lineUp(via.get(via.size() - 1), to));92 final Way from = TurnlanesUtils.getMemberWay(r, Constants.TURN_ROLE_FROM); 93 final Way to = TurnlanesUtils.getMemberWay(r, Constants.TURN_ROLE_TO); 94 95 closed &= !closedNodes.add(TurnlanesUtils.lineUp(from, via.get(0))); 96 closed &= !closedNodes.add(TurnlanesUtils.lineUp(via.get(via.size() - 1), to)); 97 97 } 98 98 … … 142 142 } 143 143 144 for (Route r : Utils.orderWays(this.primaryWays, this.primaryNodes)) {144 for (Route r : TurnlanesUtils.orderWays(this.primaryWays, this.primaryNodes)) { 145 145 addRoad(new Road(this, r)); 146 146 } … … 159 159 for (Node n : primaryNodes) { 160 160 final List<Way> ws = new ArrayList<>(); 161 for (Way w : Utils.filterRoads(n.getReferrers())) {161 for (Way w : TurnlanesUtils.filterRoads(n.getReferrers())) { 162 162 if (w.isFirstLastNode(n)) { 163 163 ws.add(w); -
applications/editors/josm/plugins/turnlanes/src/org/openstreetmap/josm/plugins/turnlanes/model/Road.java
r34566 r34976 124 124 final Relation target; 125 125 if (rel == null) { 126 if (other == null || ! Utils.getMemberNode(other, "end").equals(n)) {126 if (other == null || !TurnlanesUtils.getMemberNode(other, "end").equals(n)) { 127 127 target = createLengthsRelation(); 128 128 } else { -
applications/editors/josm/plugins/turnlanes/src/org/openstreetmap/josm/plugins/turnlanes/model/Route.java
r33085 r34976 98 98 99 99 public static Route load(Relation r) { 100 final Node end = Utils.getMemberNode(r, Constants.LENGTHS_ROLE_END);101 final List<Way> ws = Utils.getMemberWays(r, Constants.LENGTHS_ROLE_WAYS);100 final Node end = TurnlanesUtils.getMemberNode(r, Constants.LENGTHS_ROLE_END); 101 final List<Way> ws = TurnlanesUtils.getMemberWays(r, Constants.LENGTHS_ROLE_WAYS); 102 102 103 103 return create(ws, end); … … 143 143 } 144 144 145 final Node start = Utils.getOppositeEnd(w, end);145 final Node start = TurnlanesUtils.getOppositeEnd(w, end); 146 146 segments.add(0, new Segment(start, w, end)); 147 147 end = start; -
applications/editors/josm/plugins/turnlanes/src/org/openstreetmap/josm/plugins/turnlanes/model/Turn.java
r34926 r34976 54 54 55 55 private static Set<Turn> loadWithViaWays(ModelContainer c, Relation r) { 56 final Way from = Utils.getMemberWay(r, Constants.TURN_ROLE_FROM);57 final Way to = Utils.getMemberWay(r, Constants.TURN_ROLE_TO);56 final Way from = TurnlanesUtils.getMemberWay(r, Constants.TURN_ROLE_FROM); 57 final Way to = TurnlanesUtils.getMemberWay(r, Constants.TURN_ROLE_TO); 58 58 59 59 if (!c.hasRoad(from) || !c.hasRoad(to)) { … … 61 61 } 62 62 63 final List<Way> tmp = Utils.getMemberWays(r, Constants.TURN_ROLE_VIA);63 final List<Way> tmp = TurnlanesUtils.getMemberWays(r, Constants.TURN_ROLE_VIA); 64 64 final LinkedList<Road> via = new LinkedList<>(); 65 65 66 final Road.End fromRoadEnd = c.getJunction( Utils.lineUp(from, tmp.get(0))).getRoadEnd(from);66 final Road.End fromRoadEnd = c.getJunction(TurnlanesUtils.lineUp(from, tmp.get(0))).getRoadEnd(from); 67 67 68 68 Node n = fromRoadEnd.getJunction().getNode(); … … 76 76 final Road v = c.getRoad(w); 77 77 via.add(v); 78 n = Utils.getOppositeEnd(w, n);78 n = TurnlanesUtils.getOppositeEnd(w, n); 79 79 80 80 if (!v.isPrimary()) { … … 88 88 while (it2.hasNext()) { 89 89 final Way w2 = it2.next().getWay(); 90 n = Utils.getOppositeEnd(w2, n);90 n = TurnlanesUtils.getOppositeEnd(w2, n); 91 91 92 92 if (!it.hasNext() || !w2.equals(it.next())) { … … 96 96 } 97 97 final Road.End toRoadEnd = c.getJunction(n).getRoadEnd(to); 98 n = Utils.getOppositeEnd(to, n);98 n = TurnlanesUtils.getOppositeEnd(to, n); 99 99 100 100 final Set<Turn> result = new HashSet<>(); … … 124 124 125 125 private static Set<Turn> loadWithViaNode(ModelContainer c, Relation r) { 126 final Way from = Utils.getMemberWay(r, Constants.TURN_ROLE_FROM);127 final Node via = Utils.getMemberNode(r, Constants.TURN_ROLE_VIA);128 final Way to = Utils.getMemberWay(r, Constants.TURN_ROLE_TO);126 final Way from = TurnlanesUtils.getMemberWay(r, Constants.TURN_ROLE_FROM); 127 final Node via = TurnlanesUtils.getMemberNode(r, Constants.TURN_ROLE_VIA); 128 final Way to = TurnlanesUtils.getMemberWay(r, Constants.TURN_ROLE_TO); 129 129 130 130 if (!c.hasRoad(from) || !c.hasJunction(via) || !c.hasRoad(to)) { -
applications/editors/josm/plugins/turnlanes/src/org/openstreetmap/josm/plugins/turnlanes/model/Validator.java
r33085 r34976 17 17 import org.openstreetmap.josm.data.osm.DataSet; 18 18 import org.openstreetmap.josm.data.osm.Node; 19 import org.openstreetmap.josm.data.osm.OsmPrimitive;20 19 import org.openstreetmap.josm.data.osm.Relation; 21 20 import org.openstreetmap.josm.data.osm.RelationMember; 22 21 import org.openstreetmap.josm.data.osm.Way; 23 22 import org.openstreetmap.josm.plugins.turnlanes.model.Issue.QuickFix; 23 import org.openstreetmap.josm.tools.Utils; 24 24 25 25 public class Validator { … … 109 109 final List<Relation> turns = new ArrayList<>(); 110 110 111 for (Relation r : OsmPrimitive.getFilteredList(dataSet.allPrimitives(), Relation.class)) {111 for (Relation r : Utils.filteredCollection(dataSet.allPrimitives(), Relation.class)) { 112 112 if (!r.isUsable()) { 113 113 continue; … … 152 152 153 153 try { 154 final Node end = Utils.getMemberNode(r, Constants.LENGTHS_ROLE_END);154 final Node end = TurnlanesUtils.getMemberNode(r, Constants.LENGTHS_ROLE_END); 155 155 final Route route = validateLengthsWays(r, end, issues); 156 156 … … 207 207 208 208 private Route validateLengthsWays(Relation r, Node end, List<Issue> issues) { 209 final List<Way> ways = Utils.getMemberWays(r, Constants.LENGTHS_ROLE_WAYS);209 final List<Way> ways = TurnlanesUtils.getMemberWays(r, Constants.LENGTHS_ROLE_WAYS); 210 210 211 211 if (ways.isEmpty()) { … … 221 221 } 222 222 223 current = Utils.getOppositeEnd(w, current);223 current = TurnlanesUtils.getOppositeEnd(w, current); 224 224 } 225 225 … … 247 247 it.remove(); 248 248 ordered.add(w); 249 current = Utils.getOppositeEnd(w, current);249 current = TurnlanesUtils.getOppositeEnd(w, current); 250 250 continue findNext; 251 251 } … … 294 294 295 295 try { 296 final Way from = Utils.getMemberWay(r, Constants.TURN_ROLE_FROM);297 final Way to = Utils.getMemberWay(r, Constants.TURN_ROLE_TO);296 final Way from = TurnlanesUtils.getMemberWay(r, Constants.TURN_ROLE_FROM); 297 final Way to = TurnlanesUtils.getMemberWay(r, Constants.TURN_ROLE_TO); 298 298 299 299 if (from.firstNode().equals(from.lastNode())) { … … 308 308 309 309 final Node fromJunctionNode; 310 final List<RelationMember> viaMembers = Utils.getMembers(r, Constants.TURN_ROLE_VIA);310 final List<RelationMember> viaMembers = TurnlanesUtils.getMembers(r, Constants.TURN_ROLE_VIA); 311 311 if (viaMembers.isEmpty()) { 312 312 throw UnexpectedDataException.Kind.NO_MEMBER.chuck(Constants.TURN_ROLE_VIA); 313 313 } else if (viaMembers.get(0).isWay()) { 314 final List<Way> vias = Utils.getMemberWays(r, Constants.TURN_ROLE_VIA);315 316 fromJunctionNode = Utils.lineUp(from, vias.get(0));314 final List<Way> vias = TurnlanesUtils.getMemberWays(r, Constants.TURN_ROLE_VIA); 315 316 fromJunctionNode = TurnlanesUtils.lineUp(from, vias.get(0)); 317 317 Node current = fromJunctionNode; 318 318 for (Way via : vias) { … … 322 322 } 323 323 324 current = Utils.getOppositeEnd(via, current);324 current = TurnlanesUtils.getOppositeEnd(via, current); 325 325 } 326 326 } else { 327 final Node via = Utils.getMemberNode(r, Constants.TURN_ROLE_VIA);327 final Node via = TurnlanesUtils.getMemberNode(r, Constants.TURN_ROLE_VIA); 328 328 329 329 if (!from.isFirstLastNode(via)) { -
applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/TurnRestrictionBuilder.java
r32519 r34976 17 17 import org.openstreetmap.josm.plugins.turnrestrictions.editor.TurnRestrictionType; 18 18 import org.openstreetmap.josm.tools.CheckParameterUtil; 19 import org.openstreetmap.josm.tools.Utils; 19 20 20 21 /** … … 313 314 314 315 // we need exactly one node and one way in the selection ... 315 List<Node> nodes = OsmPrimitive.getFilteredList(primitives, Node.class);316 List<Way> ways = OsmPrimitive.getFilteredList(primitives, Way.class);316 List<Node> nodes = new ArrayList<>(Utils.filteredCollection(primitives, Node.class)); 317 List<Way> ways = new ArrayList<>(Utils.filteredCollection(primitives, Way.class)); 317 318 if (nodes.size() != 1 || ways.size() != 1) return null; 318 319 … … 374 375 // See initNoUTurnRestriction() for the case where we have a selected way 375 376 // and a selected node 376 List<Way> selWays = OsmPrimitive.getFilteredList(primitives, Way.class);377 List<Way> selWays = new ArrayList<>(Utils.filteredCollection(primitives, Way.class)); 377 378 if (selWays.size() != 2) return null; 378 379 w1 = selWays.get(0); … … 382 383 // if we have exactly three selected primitives, we need two ways and a 383 384 // node, which should be an acceptable via node 384 List<Way> selWays = OsmPrimitive.getFilteredList(primitives, Way.class);385 List<Node> selNodes = OsmPrimitive.getFilteredList(primitives, Node.class);385 List<Way> selWays = new ArrayList<>(Utils.filteredCollection(primitives, Way.class)); 386 List<Node> selNodes = new ArrayList<>(Utils.filteredCollection(primitives, Node.class)); 386 387 if (selWays.size() != 2) return null; 387 388 if (selNodes.size() != 1) return null; … … 449 450 case 1: 450 451 tr = initEmptyTurnRestriction(); 451 if ( OsmPrimitive.getFilteredList(primitives, Way.class).size() == 1) {452 if (Utils.filteredCollection(primitives, Way.class).size() == 1) { 452 453 // we have exactly one selected way? -> init the "from" leg 453 454 // of the turn restriction with it -
applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionLegEditor.java
r33537 r34976 20 20 import java.awt.event.MouseMotionAdapter; 21 21 import java.io.IOException; 22 import java.util.ArrayList; 22 23 import java.util.Collections; 23 24 import java.util.HashSet; … … 55 56 import org.openstreetmap.josm.tools.ImageProvider; 56 57 import org.openstreetmap.josm.tools.Shortcut; 58 import org.openstreetmap.josm.tools.Utils; 57 59 58 60 /** … … 293 295 @Override 294 296 public void actionPerformed(ActionEvent e) { 295 List<Way> selWays = OsmPrimitive.getFilteredList(model.getJosmSelectionListModel().getSelected(), Way.class);297 List<Way> selWays = new ArrayList<>(Utils.filteredCollection(model.getJosmSelectionListModel().getSelected(), Way.class)); 296 298 if (selWays.size() != 1) return; 297 299 Way w = selWays.get(0); … … 300 302 301 303 public void updateEnabledState() { 302 setEnabled( OsmPrimitive.getFilteredList(model.getJosmSelectionListModel().getSelected(), Way.class).size() == 1);304 setEnabled(Utils.filteredCollection(model.getJosmSelectionListModel().getSelected(), Way.class).size() == 1); 303 305 } 304 306 -
applications/editors/josm/plugins/waydownloader/src/org/openstreetmap/josm/plugins/waydownloader/WayDownloaderPlugin.java
r34569 r34976 38 38 import org.openstreetmap.josm.tools.Logging; 39 39 import org.openstreetmap.josm.tools.Shortcut; 40 import org.openstreetmap.josm.tools.Utils; 40 41 41 42 /** … … 271 272 */ 272 273 private List<Way> findConnectedWays(Node referenceNode) { 273 List<Way> referers = OsmPrimitive.getFilteredList(referenceNode.getReferrers(), Way.class);274 List<Way> referers = new ArrayList<>(Utils.filteredCollection(referenceNode.getReferrers(), Way.class)); 274 275 ArrayList<Way> connectedWays = new ArrayList<>(referers.size()); 275 276
Note:
See TracChangeset
for help on using the changeset viewer.