# Changeset 12879 in josm for trunk

Ignore:
Timestamp:
2017-09-20T10:17:35+02:00 (2 years ago)
Message:

applied #15327 - small cleanup and "fix" for CreateCircleAction (patch by naoliv)

File:
1 edited

Unmodified
Removed
• ## trunk/src/org/openstreetmap/josm/actions/CreateCircleAction.java

 r12837 if (nodes.size() == 2) { // diameter: two single nodes needed or a way with two nodes Node n1 = nodes.get(0); double x1 = n1.getEastNorth().east(); double y1 = n1.getEastNorth().north(); Node n2 = nodes.get(1); double x2 = n2.getEastNorth().east(); double y2 = n2.getEastNorth().north(); // calculate the center (xc/yc) double xc = 0.5 * (x1 + x2); double yc = 0.5 * (y1 + y2); center = new EastNorth(xc, yc); EastNorth n1 = nodes.get(0).getEastNorth(); EastNorth n2 = nodes.get(1).getEastNorth(); center = n1.getCenter(n2); } else { // triangle: three single nodes needed or a way with three nodes // calculate the radius (r) EastNorth n1 = nodes.get(0).getEastNorth(); double r = Math.sqrt(Math.pow(center.east()-n1.east(), 2) + Math.pow(center.north()-n1.north(), 2)); double r = n1.distance(center); // see #10777 int numberOfNodesInCircle = (int) Math.ceil(6.0 * Math.pow(radiusInMeters, 0.5)); // an odd number of nodes makes the distribution uneven if ((numberOfNodesInCircle % 2) == 1) { // add 1 to make it even numberOfNodesInCircle += 1; } if (numberOfNodesInCircle < 6) { numberOfNodesInCircle = 6; numberOfNodesInCircle = 6; }
Note: See TracChangeset for help on using the changeset viewer.