Changeset 386 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2007-10-14T21:02:49+02:00 (17 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java
r375 r386 99 99 // Insert the node into all the nearby way segments 100 100 List<WaySegment> wss = Main.map.mapView.getNearestWaySegments(e.getPoint()); 101 System.out.println(wss); 101 102 Map<Way, List<Integer>> insertPoints = new HashMap<Way, List<Integer>>(); 102 103 for (WaySegment ws : wss) { -
trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java
r359 r386 8 8 import java.util.List; 9 9 import java.util.ArrayList; 10 import java.util.LinkedList; 10 11 11 12 import javax.swing.JComponent; … … 154 155 */ 155 156 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>>(); 157 158 for (Way w : Main.ds.ways) { 158 159 if (w.deleted) … … 175 176 double perDist = a-(a-b+c)*(a-b+c)/4/c; // perpendicular distance squared 176 177 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)); 178 186 } 179 187 … … 181 189 } 182 190 } 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; 184 196 } 185 197
Note:
See TracChangeset
for help on using the changeset viewer.