Changeset 8447 in josm for trunk/src/org/openstreetmap/josm


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

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

Legend:

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

    r8378 r8447  
    140140                                                                            w.getNode(segmentIndex+1).getEastNorth(),
    141141                                                                            node.getEastNorth());
    142                         cmds.add(new MoveCommand(node, Projections.inverseProject(newPosition)));
     142                        MoveCommand c = new MoveCommand(node, Projections.inverseProject(newPosition));
     143                        // Avoid moving a given node several times at the same position in case of overlapping ways
     144                        if (!cmds.contains(c)) {
     145                            cmds.add(c);
     146                        }
    143147                    }
    144148                }
  • trunk/src/org/openstreetmap/josm/command/Command.java

    r8378 r8447  
    100100            return modified;
    101101        }
     102
     103        @Override
     104        public int hashCode() {
     105            final int prime = 31;
     106            int result = 1;
     107            result = prime * result + ((eastNorth == null) ? 0 : eastNorth.hashCode());
     108            result = prime * result + ((latlon == null) ? 0 : latlon.hashCode());
     109            result = prime * result + (modified ? 1231 : 1237);
     110            return result;
     111        }
     112
     113        @Override
     114        public boolean equals(Object obj) {
     115            if (this == obj)
     116                return true;
     117            if (obj == null)
     118                return false;
     119            if (getClass() != obj.getClass())
     120                return false;
     121            OldNodeState other = (OldNodeState) obj;
     122            if (eastNorth == null) {
     123                if (other.eastNorth != null)
     124                    return false;
     125            } else if (!eastNorth.equals(other.eastNorth))
     126                return false;
     127            if (latlon == null) {
     128                if (other.latlon != null)
     129                    return false;
     130            } else if (!latlon.equals(other.latlon))
     131                return false;
     132            if (modified != other.modified)
     133                return false;
     134            return true;
     135        }
    102136    }
    103137
     
    266300    }
    267301
     302    @Override
     303    public int hashCode() {
     304        final int prime = 31;
     305        int result = 1;
     306        result = prime * result + ((cloneMap == null) ? 0 : cloneMap.hashCode());
     307        result = prime * result + ((layer == null) ? 0 : layer.hashCode());
     308        return result;
     309    }
     310
     311    @Override
     312    public boolean equals(Object obj) {
     313        if (this == obj)
     314            return true;
     315        if (obj == null)
     316            return false;
     317        if (getClass() != obj.getClass())
     318            return false;
     319        Command other = (Command) obj;
     320        if (cloneMap == null) {
     321            if (other.cloneMap != null)
     322                return false;
     323        } else if (!cloneMap.equals(other.cloneMap))
     324            return false;
     325        if (layer == null) {
     326            if (other.layer != null)
     327                return false;
     328        } else if (!layer.equals(other.layer))
     329            return false;
     330        return true;
     331    }
    268332}
  • 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}
  • trunk/src/org/openstreetmap/josm/command/PseudoCommand.java

    r6883 r8447  
    1717    /**
    1818     * Provides a description text representing this command.
     19     * @return description text representing this command
    1920     */
    2021    public abstract String getDescriptionText();
     
    2223    /**
    2324     * Provides a descriptive icon of this command.
     25     * @return descriptive icon of this command
    2426     */
    2527    public Icon getDescriptionIcon() {
     
    2931    /**
    3032     * Return the primitives that take part in this command.
     33     * @return primitives that take part in this command
    3134     */
    3235    public abstract Collection<? extends OsmPrimitive> getParticipatingPrimitives();
Note: See TracChangeset for help on using the changeset viewer.