Changeset 12879 in josm
 Timestamp:
 20170920T10:17:35+02:00 (3 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/org/openstreetmap/josm/actions/CreateCircleAction.java
r12837 r12879 162 162 if (nodes.size() == 2) { 163 163 // diameter: two single nodes needed or a way with two nodes 164 Node n1 = nodes.get(0); 165 double x1 = n1.getEastNorth().east(); 166 double y1 = n1.getEastNorth().north(); 167 Node n2 = nodes.get(1); 168 double x2 = n2.getEastNorth().east(); 169 double y2 = n2.getEastNorth().north(); 170 171 // calculate the center (xc/yc) 172 double xc = 0.5 * (x1 + x2); 173 double yc = 0.5 * (y1 + y2); 174 center = new EastNorth(xc, yc); 164 EastNorth n1 = nodes.get(0).getEastNorth(); 165 EastNorth n2 = nodes.get(1).getEastNorth(); 166 167 center = n1.getCenter(n2); 175 168 } else { 176 169 // triangle: three single nodes needed or a way with three nodes … … 184 177 // calculate the radius (r) 185 178 EastNorth n1 = nodes.get(0).getEastNorth(); 186 double r = Math.sqrt(Math.pow(center.east()n1.east(), 2) + 187 Math.pow(center.north()n1.north(), 2)); 179 double r = n1.distance(center); 188 180 189 181 // see #10777 … … 194 186 195 187 int numberOfNodesInCircle = (int) Math.ceil(6.0 * Math.pow(radiusInMeters, 0.5)); 188 // an odd number of nodes makes the distribution uneven 189 if ((numberOfNodesInCircle % 2) == 1) { 190 // add 1 to make it even 191 numberOfNodesInCircle += 1; 192 } 196 193 if (numberOfNodesInCircle < 6) { 197 numberOfNodesInCircle = 6;194 numberOfNodesInCircle = 6; 198 195 } 199 196
Note: See TracChangeset
for help on using the changeset viewer.