Changeset 7025 in josm for trunk/src/org/openstreetmap/josm/actions/MergeNodesAction.java
- Timestamp:
- 2014-04-29T03:24:57+02:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/MergeNodesAction.java
r7005 r7025 104 104 105 105 switch (Main.pref.getInteger("merge-nodes.mode", 0)) { 106 case 0: {106 case 0: 107 107 Node targetNode = candidates.get(size - 1); 108 108 for (final Node n : candidates) { // pick last one … … 110 110 } 111 111 return targetNode; 112 } 113 case 1: { 114 double east = 0, north = 0; 112 case 1: 113 double east1 = 0, north1 = 0; 115 114 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: 123 121 final double[] weights = new double[size]; 124 122 … … 133 131 } 134 132 135 double east = 0, north= 0, weight = 0;133 double east2 = 0, north2 = 0, weight = 0; 136 134 for (int i = 0; i < size; i++) { 137 135 final EastNorth en = candidates.get(i).getEastNorth(); 138 136 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; 141 139 weight += w; 142 140 } 143 141 144 return new Node(new EastNorth(east / weight, north / weight)); 145 } 142 return new Node(new EastNorth(east2 / weight, north2 / weight)); 146 143 default: 147 144 throw new RuntimeException("unacceptable merge-nodes.mode");
Note:
See TracChangeset
for help on using the changeset viewer.