Changeset 1636 in josm for trunk/src/org/openstreetmap/josm/command
- Timestamp:
- 2009-06-06T13:38:32+02:00 (16 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/command
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/command/MoveCommand.java
r1169 r1636 15 15 import javax.swing.tree.MutableTreeNode; 16 16 17 import org.openstreetmap.josm.Main;18 17 import org.openstreetmap.josm.data.coor.EastNorth; 19 18 import org.openstreetmap.josm.data.coor.LatLon; … … 88 87 public void moveAgain(double x, double y) { 89 88 for (Node n : objects) { 90 n.eastNorth = new EastNorth(n.eastNorth.east()+x, n.eastNorth.north()+y); 91 n.coor = Main.proj.eastNorth2latlon(n.eastNorth); 89 n.setEastNorth(n.eastNorth.add(x, y)); 92 90 } 93 91 this.x += x; … … 97 95 @Override public boolean executeCommand() { 98 96 for (Node n : objects) { 99 n.eastNorth = new EastNorth(n.eastNorth.east()+x, n.eastNorth.north()+y); 100 n.coor = Main.proj.eastNorth2latlon(n.eastNorth); 97 n.setEastNorth(n.eastNorth.add(x, y)); 101 98 n.modified = true; 102 99 } … … 108 105 for (Node n : objects) { 109 106 OldState os = it.next(); 110 n.eastNorth = os.eastNorth; 111 n.coor = os.latlon; 107 n.setEastNorth(os.eastNorth); 112 108 n.modified = os.modified; 113 109 } -
trunk/src/org/openstreetmap/josm/command/RotateCommand.java
r1169 r1636 13 13 import javax.swing.tree.MutableTreeNode; 14 14 15 import org.openstreetmap.josm.Main;16 15 import org.openstreetmap.josm.data.coor.EastNorth; 17 import org.openstreetmap.josm.data.coor.LatLon;18 16 import org.openstreetmap.josm.data.osm.Node; 19 17 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 36 34 * pivot point 37 35 */ 38 private Nodepivot;36 private EastNorth pivot; 39 37 40 38 /** … … 62 60 63 61 this.objects = AllNodesVisitor.getAllNodes(objects); 64 pivot = new Node(new LatLon(0,0)); 65 pivot.eastNorth = new EastNorth(0,0); 62 pivot = new EastNorth(0,0); 66 63 67 64 for (Node n : this.objects) { … … 71 68 os.modified = n.modified; 72 69 oldState.put(n, os); 73 pivot .eastNorth = new EastNorth(pivot.eastNorth.east()+os.eastNorth.east(),pivot.eastNorth.north()+os.eastNorth.north());70 pivot = pivot.add(os.eastNorth.east(), os.eastNorth.north()); 74 71 } 75 pivot.eastNorth = new EastNorth(pivot.eastNorth.east()/this.objects.size(), pivot.eastNorth.north()/this.objects.size()); 76 pivot.coor = Main.proj.eastNorth2latlon(pivot.eastNorth); 72 pivot = new EastNorth(pivot.east()/this.objects.size(), pivot.north()/this.objects.size()); 77 73 78 74 rotationAngle = Math.PI/2; … … 87 83 public void rotateAgain(EastNorth start, EastNorth end) { 88 84 // compute angle 89 startAngle = Math.atan2(start.east()-pivot.east North.east(), start.north()-pivot.eastNorth.north());90 double endAngle = Math.atan2(end.east()-pivot.east North.east(), end.north()-pivot.eastNorth.north());85 startAngle = Math.atan2(start.east()-pivot.east(), start.north()-pivot.north()); 86 double endAngle = Math.atan2(end.east()-pivot.east(), end.north()-pivot.north()); 91 87 rotationAngle += startAngle - endAngle; 92 88 rotateNodes(false); … … 102 98 double sinPhi = Math.sin(rotationAngle); 103 99 EastNorth oldEastNorth = oldState.get(n).eastNorth; 104 double x = oldEastNorth.east() - pivot.eastNorth.east(); 105 double y = oldEastNorth.north() - pivot.eastNorth.north(); 106 double nx = sinPhi * x + cosPhi * y + pivot.eastNorth.east(); 107 double ny = -cosPhi * x + sinPhi * y + pivot.eastNorth.north(); 108 n.eastNorth = new EastNorth(nx, ny); 109 n.coor = Main.proj.eastNorth2latlon(n.eastNorth); 100 double x = oldEastNorth.east() - pivot.east(); 101 double y = oldEastNorth.north() - pivot.north(); 102 double nx = sinPhi * x + cosPhi * y + pivot.east(); 103 double ny = -cosPhi * x + sinPhi * y + pivot.north(); 104 n.setEastNorth(nx, ny); 110 105 if (setModified) 111 106 n.modified = true; … … 121 116 for (Node n : objects) { 122 117 MoveCommand.OldState os = oldState.get(n); 123 n.eastNorth = os.eastNorth; 124 n.coor = os.latlon; 118 n.setEastNorth(os.eastNorth); 125 119 n.modified = os.modified; 126 120 }
Note:
See TracChangeset
for help on using the changeset viewer.