- Timestamp:
- 2007-05-08T23:01:07+02:00 (18 years ago)
- Location:
- src/org/openstreetmap/josm/actions
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/actions/ReorderAction.java
r229 r235 77 77 */ 78 78 public static Command reorderWay(Way way) { 79 final LinkedList<Segment> sel = new LinkedList<Segment>(sortSegments(new LinkedList<Segment>(way.segments))); 79 final LinkedList<Segment> sel = new LinkedList<Segment>(sortSegments(new LinkedList<Segment>(way.segments), false)); 80 80 81 81 Collection<Command> c = new LinkedList<Command>(); … … 160 160 161 161 /** 162 * This sort is based on the sort in the old ReorderAction, but it works162 * This sort is based on the sort in the old ReorderAction, but it can work 163 163 * irresepective of the direction of the segments. This produces a sort 164 164 * that can be useful even if the segments are facing the wrong direction. 165 * 166 * @param segments list of segments to be sorted 167 * @param strict true if segment direction should be observed, false if not 165 168 */ 166 public static LinkedList<Segment> sortSegments(LinkedList<Segment> segments) { 169 public static LinkedList<Segment> sortSegments(LinkedList<Segment> segments, boolean strict) { 167 170 168 171 LinkedList<Segment> sortedSegments = new LinkedList<Segment>(); … … 179 182 if (ls.incomplete) 180 183 continue; // incomplete segments are never added to a new way 181 if (ls.from == pivotList.getLast().to || ls.to == pivotList.getLast().to || ls.from == pivotList.getLast().from || ls.to == pivotList.getLast().from) { 184 if (ls.from == pivotList.getLast().to || (!strict && (ls.to == pivotList.getLast().to || ls.from == pivotList.getLast().from || ls.to == pivotList.getLast().from))) { 182 185 pivotList.addLast(ls); 183 186 it.remove(); 184 187 found = true; 185 } else if (ls.to == pivotList.getFirst().from || ls.from == pivotList.getFirst().from || ls.to == pivotList.getFirst().to || ls.from == pivotList.getFirst().to) { 188 } else if (ls.to == pivotList.getFirst().from || (!strict && (ls.from == pivotList.getFirst().from || ls.to == pivotList.getFirst().to || ls.from == pivotList.getFirst().to))) { 186 189 pivotList.addFirst(ls); 187 190 it.remove(); -
src/org/openstreetmap/josm/actions/mapmode/AddWayAction.java
r222 r235 189 189 190 190 LinkedList<Segment> rawSegments = new LinkedList<Segment>(segmentSet); 191 LinkedList<Segment> sortedSegments = ReorderAction.sortSegments(rawSegments); 191 LinkedList<Segment> sortedSegments = ReorderAction.sortSegments(rawSegments, true); 192 192 193 193 if (wayToAdd != null) {
Note:
See TracChangeset
for help on using the changeset viewer.