Changeset 564 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2008-02-26T01:54:22+01:00 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/AlignInCircleAction.java
r469 r564 53 53 54 54 // Now calculate the average distance to each node from the 55 // centre. 56 double avdist = 0; 57 for (Node n : nodes) 58 avdist += Math.sqrt(avn.eastNorth.distance(n.eastNorth)); 55 // centre. This method is ok as long as distances are short 56 // relative to the distance from the N or S poles. 57 double distances[] = new double[nodes.size()]; 58 double avdist = 0, latd, lond; 59 double lonscale = Math.cos(avn.coor.lat() * Math.PI/180.0); 60 lonscale = lonscale * lonscale; 61 int i = 0; 62 for (Node n : nodes) { 63 latd = n.coor.lat() - avn.coor.lat(); 64 lond = n.coor.lon() - avn.coor.lon(); 65 distances[i] = Math.sqrt(latd * latd + lonscale * lond * lond); 66 avdist += distances[i++]; 67 } 59 68 avdist = avdist / nodes.size(); 60 69 61 70 Collection<Command> cmds = new LinkedList<Command>(); 62 71 // Move each node to that distance from the centre. 72 i = 0; 63 73 for (Node n : nodes) { 64 74 double dx = n.eastNorth.east() - avn.eastNorth.east(); 65 75 double dy = n.eastNorth.north() - avn.eastNorth.north(); 66 double dist = Math.sqrt(avn.eastNorth.distance(n.eastNorth));76 double dist = distances[i++]; 67 77 cmds.add(new MoveCommand(n, (dx * (avdist / dist)) - dx, (dy * (avdist / dist)) - dy)); 68 78 }
Note:
See TracChangeset
for help on using the changeset viewer.