Changeset 805 in josm for trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java
- Timestamp:
- 18.08.2008 01:27:58 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java
r794 r805 32 32 public class NavigatableComponent extends JComponent implements Helpful { 33 33 34 35 34 public static final EastNorth world = Main.proj.latlon2eastNorth(new LatLon(Projection.MAX_LAT, Projection.MAX_LON)); 36 35 public static final int snapDistance = sqr(Main.pref.getInteger("node.snap-distance", 10)); 36 37 private static int sqr(int a) { return a*a;} 37 38 /** 38 39 * The scale factor in x or y-units per pixel. This means, if scale = 10, … … 141 142 Point sp = getPoint(n.eastNorth); 142 143 double dist = p.distanceSq(sp); 143 if (minDistanceSq > dist && dist < 100) {144 if (minDistanceSq > dist && dist < snapDistance) { 144 145 minDistanceSq = p.distanceSq(sp); 145 146 minPrimitive = n; … … 180 181 double b = p.distanceSq(A); 181 182 double perDist = a-(a-b+c)*(a-b+c)/4/c; // perpendicular distance squared 182 if (perDist < 100 && a < c+100 && b < c+100) {183 if (perDist < snapDistance && a < c+snapDistance && b < c+snapDistance) { 183 184 List<WaySegment> l; 184 185 if (nearest.containsKey(perDist)) { … … 228 229 WaySegment nearestWaySeg = getNearestWaySegment(p); 229 230 return nearestWaySeg == null ? null : nearestWaySeg.way; 230 }231 } 231 232 232 233 /** … … 240 241 * If nothing is found, return <code>null</code>. 241 242 * 242 * @param p The point on screen.243 * @return The primitive that is nearest to the point p.243 * @param p The point on screen. 244 * @return The primitive that is nearest to the point p. 244 245 */ 245 246 public OsmPrimitive getNearest(Point p) { 246 247 OsmPrimitive osm = getNearestNode(p); 247 248 if (osm == null) 249 { 248 250 osm = getNearestWay(p); 251 } 249 252 return osm; 250 253 } … … 258 261 return Collections.emptySet(); 259 262 return Collections.singleton(osm); 260 }261 262 @Deprecated263 public OsmPrimitive getNearest(Point p, boolean segmentInsteadWay) {264 return getNearest(p);265 263 } 266 264 … … 290 288 double b = p.distanceSq(A); 291 289 double perDist = a-(a-b+c)*(a-b+c)/4/c; // perpendicular distance squared 292 if (perDist < 100 && a < c+100 && b < c+100) {290 if (perDist < snapDistance && a < c+snapDistance && b < c+snapDistance) { 293 291 nearest.add(w); 294 292 break; … … 299 297 for (Node n : Main.ds.nodes) { 300 298 if (!n.deleted && !n.incomplete 301 && getPoint(n.eastNorth).distanceSq(p) < 100) {299 && getPoint(n.eastNorth).distanceSq(p) < snapDistance) { 302 300 nearest.add(n); 303 301 } … … 318 316 for (Node n : Main.ds.nodes) { 319 317 if (!n.deleted && !n.incomplete 320 && getPoint(n.eastNorth).distanceSq(p) < 100) {318 && getPoint(n.eastNorth).distanceSq(p) < snapDistance) { 321 319 nearest.add(n); 322 320 }
Note: See TracChangeset
for help on using the changeset viewer.
