Changeset 33404 in osm for applications/editors/josm
- Timestamp:
- 2017-06-16T19:01:54+02:00 (8 years ago)
- Location:
- applications/editors/josm/plugins/pt_assistant
- Files:
-
- 3 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/actions/SplitRoundaboutAction.java
r33403 r33404 4 4 5 5 import java.awt.event.ActionEvent; 6 import java.util.ArrayList; 6 7 import java.util.Collection; 7 8 import java.util.HashMap; 9 import java.util.HashSet; 8 10 import java.util.List; 9 11 import java.util.Map; 12 import java.util.Set; 10 13 import java.util.concurrent.ExecutionException; 11 14 import java.util.concurrent.Future; … … 33 36 34 37 private static final String actionName = "Split Roundabout"; 35 36 38 private static final long serialVersionUID = 8912249304286025356L; 37 39 … … 42 44 @Override 43 45 public void actionPerformed(ActionEvent e) { 46 44 47 Way roundabout = (Way) getLayerManager().getEditDataSet().getSelected().iterator().next(); 45 48 … … 70 73 { 71 74 //make the roundabout round, if requested 72 int result = JOptionPane.showOptionDialog(Main.parent, 75 if(Main.pref.getBoolean("pt_assistant.roundabout-splitter.alignalways") || 76 JOptionPane.YES_OPTION == JOptionPane.showOptionDialog(Main.parent, 73 77 tr("Do you want to make the roundabout round?"), tr("Roundabout round"), 74 78 JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, 75 null, null, null); 76 77 if(result == JOptionPane.YES_OPTION) { 79 null, null, null)) { 78 80 new AlignInCircleAction().actionPerformed(null); 79 81 } … … 86 88 getLayerManager().getEditDataSet().setSelected(splitNodes); 87 89 new SplitWayAction().actionPerformed(null); 88 Collection< OsmPrimitive> splitWays = getLayerManager().getEditDataSet().getSelected();90 Collection<Way> splitWays = getLayerManager().getEditDataSet().getSelectedWays(); 89 91 90 92 //update the relations. 93 updateRelations(savedPositions, splitNodes, splitWays); 94 } 95 96 public void updateRelations(Map<Relation, Integer> savedPositions, 97 List<Node> splitNodes, Collection<Way> splitWays) { 91 98 savedPositions.forEach((r, i) -> { 92 99 Way previous = r.getMember(i-1).getWay(); … … 137 144 //split only on the nodes which might be the 138 145 //entry or exit point for some public transport route 139 private List<Node> getSplitNodes(Way roundabout) { 140 List<Node> splitNodes = roundabout.getNodes(); 146 public List<Node> getSplitNodes(Way roundabout) { 147 Set<Node> noDuplicateSplitNodes = new HashSet<>(roundabout.getNodes()); 148 List<Node> splitNodes = new ArrayList<>(noDuplicateSplitNodes); 149 141 150 splitNodes.removeIf(n -> { 142 151 List<Way> parents = n.getParentWays(); … … 159 168 //save the position of the roundabout inside each public transport route 160 169 //it is contained in 161 p rivateMap<Relation, Integer> getSavedPositions(Way roundabout) {170 public Map<Relation, Integer> getSavedPositions(Way roundabout) { 162 171 163 172 Map<Relation, Integer> savedPositions = new HashMap<>(); -
applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/AbstractTest.java
r33055 r33404 37 37 public static final String PATH_TO_PLATFORM_AS_WAY = "test/data/route-with-platform-as-way.osm"; 38 38 39 public static final String PATH_TO_ROUNDABOUT = "test/data/roundabout.osm"; 39 40 public static final String PATH_TO_ROUNDABOUT_ONEWAY = "test/data/duesseldorf_roundabout.osm"; 40 41 … … 55 56 public static final String PATH_TO_STOP_AREA_MANY_PLATFORMS = "test/data/stop-area-many-platforms.osm"; 56 57 57 58 58 public static final String PATH_TO_SEGMENT_TEST = "test/data/segment-test.osm"; 59 59
Note:
See TracChangeset
for help on using the changeset viewer.