Ignore:
Timestamp:
2015-06-03T00:06:52+02:00 (9 years ago)
Author:
Don-vip
Message:

fix #11508 - fix bad behaviour of Move Node onto way with overlapping ways

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/command/MoveCommand.java

    r8285 r8447  
    6666     * Constructs a new {@code MoveCommand} to move a node.
    6767     * @param node The node to move
     68     * @param position The new location (lat/lon)
    6869     */
    6970    public MoveCommand(Node node, LatLon position) {
     
    9798    }
    9899
     100    /**
     101     * Constructs a new {@code MoveCommand} to move a collection of primitives.
     102     * @param objects The primitives to move
     103     * @param start The starting position (northern/eastern)
     104     * @param end The ending position (northern/eastern)
     105     */
    99106    public MoveCommand(Collection<OsmPrimitive> objects, EastNorth start, EastNorth end) {
    100107        this(objects, end.getX()-start.getX(), end.getY()-start.getY());
     
    102109    }
    103110
     111    /**
     112     * Constructs a new {@code MoveCommand} to move a primitive.
     113     * @param p The primitive to move
     114     * @param start The starting position (northern/eastern)
     115     * @param end The ending position (northern/eastern)
     116     */
    104117    public MoveCommand(OsmPrimitive p, EastNorth start, EastNorth end) {
    105118        this(Collections.singleton(p), end.getX()-start.getX(), end.getY()-start.getY());
     
    223236        return nodes;
    224237    }
     238
     239    @Override
     240    public int hashCode() {
     241        final int prime = 31;
     242        int result = super.hashCode();
     243        long temp;
     244        temp = Double.doubleToLongBits(backupX);
     245        result = prime * result + (int) (temp ^ (temp >>> 32));
     246        temp = Double.doubleToLongBits(backupY);
     247        result = prime * result + (int) (temp ^ (temp >>> 32));
     248        result = prime * result + ((nodes == null) ? 0 : nodes.hashCode());
     249        result = prime * result + ((oldState == null) ? 0 : oldState.hashCode());
     250        result = prime * result + ((startEN == null) ? 0 : startEN.hashCode());
     251        temp = Double.doubleToLongBits(x);
     252        result = prime * result + (int) (temp ^ (temp >>> 32));
     253        temp = Double.doubleToLongBits(y);
     254        result = prime * result + (int) (temp ^ (temp >>> 32));
     255        return result;
     256    }
     257
     258    @Override
     259    public boolean equals(Object obj) {
     260        if (this == obj)
     261            return true;
     262        if (!super.equals(obj))
     263            return false;
     264        if (getClass() != obj.getClass())
     265            return false;
     266        MoveCommand other = (MoveCommand) obj;
     267        if (Double.doubleToLongBits(backupX) != Double.doubleToLongBits(other.backupX))
     268            return false;
     269        if (Double.doubleToLongBits(backupY) != Double.doubleToLongBits(other.backupY))
     270            return false;
     271        if (nodes == null) {
     272            if (other.nodes != null)
     273                return false;
     274        } else if (!nodes.equals(other.nodes))
     275            return false;
     276        if (oldState == null) {
     277            if (other.oldState != null)
     278                return false;
     279        } else if (!oldState.equals(other.oldState))
     280            return false;
     281        if (startEN == null) {
     282            if (other.startEN != null)
     283                return false;
     284        } else if (!startEN.equals(other.startEN))
     285            return false;
     286        if (Double.doubleToLongBits(x) != Double.doubleToLongBits(other.x))
     287            return false;
     288        if (Double.doubleToLongBits(y) != Double.doubleToLongBits(other.y))
     289            return false;
     290        return true;
     291    }
    225292}
Note: See TracChangeset for help on using the changeset viewer.