Changeset 386 in josm for trunk


Ignore:
Timestamp:
2007-10-14T21:02:49+02:00 (17 years ago)
Author:
gebner
Message:

Allow splitting multiple way segments connecting the same nodes.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java

    r375 r386  
    9999                                // Insert the node into all the nearby way segments
    100100                                List<WaySegment> wss = Main.map.mapView.getNearestWaySegments(e.getPoint());
     101                                System.out.println(wss);
    101102                                Map<Way, List<Integer>> insertPoints = new HashMap<Way, List<Integer>>();
    102103                                for (WaySegment ws : wss) {
  • trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java

    r359 r386  
    88import java.util.List;
    99import java.util.ArrayList;
     10import java.util.LinkedList;
    1011
    1112import javax.swing.JComponent;
     
    154155         */
    155156        public final List<WaySegment> getNearestWaySegments(Point p) {
    156                 TreeMap<Double, WaySegment> nearest = new TreeMap<Double, WaySegment>();
     157                TreeMap<Double, List<WaySegment>> nearest = new TreeMap<Double, List<WaySegment>>();
    157158                for (Way w : Main.ds.ways) {
    158159                        if (w.deleted)
     
    175176                                double perDist = a-(a-b+c)*(a-b+c)/4/c; // perpendicular distance squared
    176177                                if (perDist < 100 && a < c+100 && b < c+100) {
    177                                         nearest.put(perDist, new WaySegment(w, i));
     178                                        List<WaySegment> l;
     179                                        if (nearest.containsKey(perDist)) {
     180                                                l = nearest.get(perDist);
     181                                        } else {
     182                                                l = new LinkedList<WaySegment>();
     183                                                nearest.put(perDist, l);
     184                                        }
     185                                        l.add(new WaySegment(w, i));
    178186                                }
    179187
     
    181189                        }
    182190                }
    183                 return new ArrayList<WaySegment>(nearest.values());
     191                ArrayList<WaySegment> nearestList = new ArrayList<WaySegment>();
     192                for (List<WaySegment> wss : nearest.values()) {
     193                        nearestList.addAll(wss);
     194                }
     195                return nearestList;
    184196        }
    185197
Note: See TracChangeset for help on using the changeset viewer.