Ignore:
Timestamp:
2014-04-29T03:24:57+02:00 (12 years ago)
Author:
Don-vip
Message:

Sonar - fix various issues

File:
1 edited

Legend:

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

    r7005 r7025  
    104104
    105105        switch (Main.pref.getInteger("merge-nodes.mode", 0)) {
    106         case 0: {
     106        case 0:
    107107            Node targetNode = candidates.get(size - 1);
    108108            for (final Node n : candidates) { // pick last one
     
    110110            }
    111111            return targetNode;
    112         }
    113         case 1: {
    114             double east = 0, north = 0;
     112        case 1:
     113            double east1 = 0, north1 = 0;
    115114            for (final Node n : candidates) {
    116                 east += n.getEastNorth().east();
    117                 north += n.getEastNorth().north();
    118             }
    119 
    120             return new Node(new EastNorth(east / size, north / size));
    121         }
    122         case 2: {
     115                east1 += n.getEastNorth().east();
     116                north1 += n.getEastNorth().north();
     117            }
     118
     119            return new Node(new EastNorth(east1 / size, north1 / size));
     120        case 2:
    123121            final double[] weights = new double[size];
    124122
     
    133131            }
    134132
    135             double east = 0, north = 0, weight = 0;
     133            double east2 = 0, north2 = 0, weight = 0;
    136134            for (int i = 0; i < size; i++) {
    137135                final EastNorth en = candidates.get(i).getEastNorth();
    138136                final double w = weights[i];
    139                 east += en.east() * w;
    140                 north += en.north() * w;
     137                east2 += en.east() * w;
     138                north2 += en.north() * w;
    141139                weight += w;
    142140            }
    143141
    144             return new Node(new EastNorth(east / weight, north / weight));
    145         }
     142            return new Node(new EastNorth(east2 / weight, north2 / weight));
    146143        default:
    147144            throw new RuntimeException("unacceptable merge-nodes.mode");
Note: See TracChangeset for help on using the changeset viewer.