Changeset 12837 in josm


Ignore:
Timestamp:
2017-09-13T11:17:21+02:00 (10 days ago)
Author:
bastiK
Message:

fixed #10777 - new algorithm to determine the node count in CreateCircleAction (patch by naoliv)

File:
1 edited

Legend:

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

    r12726 r12837  
    131131            return;
    132132
    133         int numberOfNodesInCircle = Main.pref.getInteger("createcircle.nodecount", 16);
    134         if (numberOfNodesInCircle < 1) {
    135             numberOfNodesInCircle = 1;
    136         } else if (numberOfNodesInCircle > 100) {
    137             numberOfNodesInCircle = 100;
    138         }
    139 
    140133        DataSet ds = getLayerManager().getEditDataSet();
    141134        Collection<OsmPrimitive> sel = ds.getSelected();
     
    193186        double r = Math.sqrt(Math.pow(center.east()-n1.east(), 2) +
    194187                Math.pow(center.north()-n1.north(), 2));
     188
     189        // see #10777
     190        LatLon ll1 = Main.getProjection().eastNorth2latlon(n1);
     191        LatLon ll2 = Main.getProjection().eastNorth2latlon(center);
     192
     193        double radiusInMeters = ll1.greatCircleDistance(ll2);
     194
     195        int numberOfNodesInCircle = (int) Math.ceil(6.0 * Math.pow(radiusInMeters, 0.5));
     196        if (numberOfNodesInCircle < 6) {
     197           numberOfNodesInCircle = 6;
     198        }
    195199
    196200        // Order nodes by angle
Note: See TracChangeset for help on using the changeset viewer.