Changeset 8276 in josm for trunk/src/org
- Timestamp:
- 2015-04-26T15:33:50+02:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/SplitWayAction.java
r7534 r8276 125 125 List<Node> selectedNodes = OsmPrimitive.getFilteredList(selection, Node.class); 126 126 List<Way> selectedWays = OsmPrimitive.getFilteredList(selection, Way.class); 127 List<Relation> selectedRelations = OsmPrimitive.getFilteredList(selection, Relation.class); 127 List<Relation> selectedRelations = 128 OsmPrimitive.getFilteredList( selection, Relation.class); 128 129 List<Way> applicableWays = getApplicableWays(selectedWays, selectedNodes); 129 130 … … 142 143 } 143 144 144 // If several ways have been found, remove ways that doesn't have selected node in the middle 145 // If several ways have been found, remove ways that doesn't have selected 146 // node in the middle 145 147 if (applicableWays.size() > 1) { 146 WAY_LOOP: 147 for (Iterator<Way> it = applicableWays.iterator(); it.hasNext();) { 148 Way w = it.next(); 149 for (Node n : selectedNodes) { 150 if (!w.isInnerNode(n)) { 151 it.remove(); 152 continue WAY_LOOP; 153 } 148 for (Iterator<Way> it = applicableWays.iterator(); it.hasNext();) { 149 Way w = it.next(); 150 for (Node n : selectedNodes) { 151 if (!w.isInnerNode(n)) { 152 it.remove(); 153 break; 154 154 } 155 155 } 156 } 156 157 } 157 158 … … 188 189 } 189 190 191 /** 192 * Determine witch ways to split. 193 * @param selectedWays List of user selected ways. 194 * @param selectedNodes List of user selected nodes. 195 * @return List of ways to split 196 */ 190 197 private List<Way> getApplicableWays(List<Way> selectedWays, List<Node> selectedNodes) { 191 198 if (selectedNodes.isEmpty()) 192 199 return null; 193 200 194 // Special case - one of the selected ways touches (not cross) way that we want to split 201 // Special case - one of the selected ways touches (not cross) way that we 202 // want to split 195 203 if (selectedNodes.size() == 1) { 196 204 Node n = selectedNodes.get(0); 197 List<Way> referedWays = OsmPrimitive.getFilteredList(n.getReferrers(), Way.class); 205 List<Way> referedWays = 206 OsmPrimitive.getFilteredList(n.getReferrers(), Way.class); 198 207 Way inTheMiddle = null; 199 boolean foundSelected = false;200 208 for (Way w: referedWays) { 201 if (selectedWays.contains(w)) { 202 foundSelected = true; 203 } 204 if (w.getNode(0) != n && w.getNode(w.getNodesCount() - 1) != n) { 209 // Need to look at all nodes see #11184 for a case where node n is 210 // firstNode, lastNode and also in the middle 211 if (selectedWays.contains(w) && w.isInnerNode(n)) { 205 212 if (inTheMiddle == null) { 206 213 inTheMiddle = w; … … 211 218 } 212 219 } 213 if ( foundSelected &&inTheMiddle != null)220 if (inTheMiddle != null) 214 221 return Collections.singletonList(inTheMiddle); 215 222 } 216 223 217 224 // List of ways shared by all nodes 218 List<Way> result = new ArrayList<>(OsmPrimitive.getFilteredList(selectedNodes.get(0).getReferrers(), Way.class)); 225 List<Way> result = 226 new ArrayList<>(OsmPrimitive.getFilteredList(selectedNodes.get(0).getReferrers(), 227 Way.class)); 219 228 for (int i=1; i<selectedNodes.size(); i++) { 220 229 List<OsmPrimitive> ref = selectedNodes.get(i).getReferrers();
Note:
See TracChangeset
for help on using the changeset viewer.