Ticket #2583: Don-t-adjust-coordinates-when-copying-from-another-l.patch

File Don-t-adjust-coordinates-when-copying-from-another-l.patch, 4.1 KB (added by anonymous, 17 years ago)
  • src/org/openstreetmap/josm/Main.java

    From 7ba565933582d2a9ff592f1baa7d4456eae481de Mon Sep 17 00:00:00 2001
    From: Michel Marti <mcdmx@users.sf.net>
    Date: Thu, 14 May 2009 16:13:06 +0200
    Subject: [PATCH] Don't adjust coordinates when copying from another layer
    
    When copying objects from one layer to another, the user usually does
    not want JOSM to tinker with the coordinates of the copied objects.
    
    ---
     src/org/openstreetmap/josm/Main.java               |    1 +
     src/org/openstreetmap/josm/actions/CopyAction.java |    1 +
     .../openstreetmap/josm/actions/PasteAction.java    |   13 ++++++++-----
     3 files changed, 10 insertions(+), 5 deletions(-)
    
    diff --git a/src/org/openstreetmap/josm/Main.java b/src/org/openstreetmap/josm/Main.java
    index 1b5c14d..6381f2d 100644
    a b abstract public class Main {  
    8686     * The global paste buffer.
    8787     */
    8888    public static DataSet pasteBuffer = new DataSet();
     89    public static Layer pasteSource;
    8990    /**
    9091     * The projection method used.
    9192     */
  • src/org/openstreetmap/josm/actions/CopyAction.java

    diff --git a/src/org/openstreetmap/josm/actions/CopyAction.java b/src/org/openstreetmap/josm/actions/CopyAction.java
    index d427168..1423037 100644
    a b public final class CopyAction extends JosmAction implements SelectionChangedList  
    4747        if(noSelection()) return;
    4848
    4949        Main.pasteBuffer = copyData();
     50        Main.pasteSource = Main.main.editLayer();
    5051        Main.main.menu.paste.setEnabled(true); /* now we have a paste buffer we can make paste available */
    5152
    5253        for(JosmAction a : listeners) {
  • src/org/openstreetmap/josm/actions/PasteAction.java

    diff --git a/src/org/openstreetmap/josm/actions/PasteAction.java b/src/org/openstreetmap/josm/actions/PasteAction.java
    index f6c4b0b..a2bfa7b 100644
    a b import org.openstreetmap.josm.data.osm.OsmPrimitive;  
    2323import org.openstreetmap.josm.data.osm.RelationMember;
    2424import org.openstreetmap.josm.data.osm.Way;
    2525import org.openstreetmap.josm.data.coor.EastNorth;
     26import org.openstreetmap.josm.gui.layer.Layer;
    2627import org.openstreetmap.josm.tools.Shortcut;
    2728
    2829public final class PasteAction extends JosmAction {
    public final class PasteAction extends JosmAction {  
    3435    }
    3536
    3637    public void actionPerformed(ActionEvent e) {
    37         pasteData(Main.pasteBuffer, e);
     38        pasteData(Main.pasteBuffer, Main.pasteSource, e);
    3839    }
    3940   
    40     public static void pasteData(DataSet pasteBuffer, ActionEvent e) {
     41    public static void pasteData(DataSet pasteBuffer, Layer source, ActionEvent e) {
    4142        /* Find the middle of the pasteBuffer area */
    4243        double maxEast = -1E100, minEast = 1E100, maxNorth = -1E100, minNorth = 1E100;
    4344        for (Node n : pasteBuffer.nodes) {
    public final class PasteAction extends JosmAction {  
    5152
    5253        EastNorth mPosition;
    5354        if((e.getModifiers() & ActionEvent.CTRL_MASK) ==0){
     55            /* adjust the coordinates to the middle of the visible map area */
    5456            mPosition = Main.map.mapView.getCenter();
    5557        } else {
    5658            mPosition = Main.map.mapView.getEastNorth(Main.map.mapView.lastMEvent.getX(), Main.map.mapView.lastMEvent.getY());
    public final class PasteAction extends JosmAction {  
    6668        for (Node n : pasteBuffer.nodes) {
    6769            Node nnew = new Node(n);
    6870            nnew.id = 0;
    69             /* adjust the coordinates to the middle of the visible map area */
    70             nnew.eastNorth = new EastNorth(nnew.eastNorth.east() + offsetEast, nnew.eastNorth.north() + offsetNorth);
    71             nnew.coor = Main.proj.eastNorth2latlon(nnew.eastNorth);
     71            if (Main.main.editLayer() == source) {
     72                nnew.eastNorth = new EastNorth(nnew.eastNorth.east() + offsetEast, nnew.eastNorth.north() + offsetNorth);
     73                nnew.coor = Main.proj.eastNorth2latlon(nnew.eastNorth);
     74            }
    7275            map.put(n, nnew);
    7376        }
    7477        for (Way w : pasteBuffer.ways) {