Changeset 235 in josm for src


Ignore:
Timestamp:
2007-05-08T23:01:07+02:00 (18 years ago)
Author:
framm
Message:

Properly sort newly added ways; bug had been introduced with 222.
Fixes (sorta) #137.

Location:
src/org/openstreetmap/josm/actions
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/org/openstreetmap/josm/actions/ReorderAction.java

    r229 r235  
    7777     */
    7878    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));       
    8080
    8181            Collection<Command> c = new LinkedList<Command>();
     
    160160
    161161        /**
    162          * This sort is based on the sort in the old ReorderAction, but it works
     162         * This sort is based on the sort in the old ReorderAction, but it can work
    163163         * irresepective of the direction of the segments. This produces a sort
    164164         * 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
    165168         */
    166         public static LinkedList<Segment> sortSegments(LinkedList<Segment> segments) {
     169        public static LinkedList<Segment> sortSegments(LinkedList<Segment> segments, boolean strict) {
    167170               
    168171                LinkedList<Segment> sortedSegments = new LinkedList<Segment>();
     
    179182                                        if (ls.incomplete)
    180183                                                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))) {
    182185                                                pivotList.addLast(ls);
    183186                                                it.remove();
    184187                                                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))) {
    186189                                                pivotList.addFirst(ls);
    187190                                                it.remove();
  • src/org/openstreetmap/josm/actions/mapmode/AddWayAction.java

    r222 r235  
    189189
    190190                LinkedList<Segment> rawSegments = new LinkedList<Segment>(segmentSet);
    191                 LinkedList<Segment> sortedSegments = ReorderAction.sortSegments(rawSegments);
     191                LinkedList<Segment> sortedSegments = ReorderAction.sortSegments(rawSegments, true);
    192192
    193193                if (wayToAdd != null) {
Note: See TracChangeset for help on using the changeset viewer.