Changeset 71 in josm for src/org/openstreetmap/josm/command


Ignore:
Timestamp:
2006-03-25T16:21:09+01:00 (19 years ago)
Author:
imi
Message:
  • refactored GpsPoint to be immutable and added LatLon and NorthEast
  • refactored Bounding Box calculations
  • various other renames
File:
1 edited

Legend:

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

    r34 r71  
    77
    88import org.openstreetmap.josm.Main;
     9import org.openstreetmap.josm.data.coor.LatLon;
     10import org.openstreetmap.josm.data.coor.EastNorth;
    911import org.openstreetmap.josm.data.osm.Node;
    1012import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    2224         * The objects that should be moved.
    2325         */
    24         public List<Node> objects = new LinkedList<Node>();
     26        public Collection<Node> objects = new LinkedList<Node>();
    2527        /**
    2628         * x difference movement. Coordinates are in northern/eastern
     
    5355                this.x = x;
    5456                this.y = y;
    55                 this.objects = getAffectedNodes(objects);
     57                this.objects = AllNodesVisitor.getAllNodes(objects);
    5658                for (Node n : this.objects) {
    5759                        OldState os = new OldState();
    58                         os.x = n.coor.x;
    59                         os.y = n.coor.y;
    60                         os.lat = n.coor.lat;
    61                         os.lon = n.coor.lon;
     60                        os.x = n.eastNorth.east();
     61                        os.y = n.eastNorth.north();
     62                        os.lat = n.coor.lat();
     63                        os.lon = n.coor.lon();
    6264                        os.modified = n.modified;
    6365                        oldState.add(os);
     
    6567        }
    6668
    67         /**
    68          * @return a list of all nodes that will be moved if using the given set of
    69          * objects.
    70          */
    71         public static List<Node> getAffectedNodes(Collection<OsmPrimitive> objects) {
    72                 AllNodesVisitor visitor = new AllNodesVisitor();
    73                 for (OsmPrimitive osm : objects)
    74                         osm.visit(visitor);
    75                 return new LinkedList<Node>(visitor.nodes);
    76         }
    77        
    7869        /**
    7970         * Move the same set of objects again by the specified vector. The vectors
     
    8677        public void moveAgain(double x, double y) {
    8778                for (Node n : objects) {
    88                         n.coor.x += x;
    89                         n.coor.y += y;
    90                         Main.pref.getProjection().xy2latlon(n.coor);
     79                        n.eastNorth = new EastNorth(n.eastNorth.east()+x, n.eastNorth.north()+y);
     80                        n.coor = Main.pref.getProjection().eastNorth2latlon(n.eastNorth);
    9181                }
    9282                this.x += x;
     
    9686        public void executeCommand() {
    9787                for (Node n : objects) {
    98                         n.coor.x += x;
    99                         n.coor.y += y;
    100                         Main.pref.getProjection().xy2latlon(n.coor);
     88                        n.eastNorth = new EastNorth(n.eastNorth.east()+x, n.eastNorth.north()+y);
     89                        n.coor = Main.pref.getProjection().eastNorth2latlon(n.eastNorth);
    10190                        n.modified = true;
    10291                }
     
    10796                for (Node n : objects) {
    10897                        OldState os = it.next();
    109                         n.coor.x = os.x;
    110                         n.coor.y = os.y;
    111                         n.coor.lat = os.lat;
    112                         n.coor.lon = os.lon;
     98                        n.eastNorth = new EastNorth(os.x, os.y);
     99                        n.coor = new LatLon(os.lat, os.lon);
    113100                        n.modified = os.modified;
    114101                }
Note: See TracChangeset for help on using the changeset viewer.