Changeset 1497 in josm


Ignore:
Timestamp:
2009-03-17T19:28:03+01:00 (10 years ago)
Author:
stoecker
Message:

fix #287 - prefer new nodes over old ones

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java

    r1430 r1497  
    150150    /**
    151151     * Return the nearest point to the screen point given.
    152      * If a node within 10 pixel is found, the nearest node is returned.
     152     * If a node within snapDistance pixel is found, the nearest node is returned.
    153153     */
    154154    public final Node getNearestNode(Point p) {
    155         double minDistanceSq = Double.MAX_VALUE;
     155        double minDistanceSq = snapDistance;
    156156        Node minPrimitive = null;
    157157        for (Node n : getData().nodes) {
     
    160160            Point sp = getPoint(n.eastNorth);
    161161            double dist = p.distanceSq(sp);
    162             if (minDistanceSq > dist && dist < snapDistance) {
    163                 minDistanceSq = p.distanceSq(sp);
     162            if (dist < minDistanceSq) {
     163                minDistanceSq = dist;
    164164                minPrimitive = n;
    165165            }
    166             // prefer already selected node when multiple nodes on one point
    167             else if(minDistanceSq == dist && n.selected && !minPrimitive.selected)
    168             {
     166            // when multiple nodes on one point, prefer new or selected nodes
     167            else if(dist == minDistanceSq && ((n.id == 0 && n.selected)
     168            || (!minPrimitive.selected && (n.selected || n.id == 0))))
    169169                minPrimitive = n;
    170             }
    171170        }
    172171        return minPrimitive;
Note: See TracChangeset for help on using the changeset viewer.