Changeset 31285 in osm for applications/editors/josm/plugins/measurement/src/org
- Timestamp:
- 2015-06-19T21:45:15+02:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/measurement/src/org/openstreetmap/josm/plugins/measurement/MeasurementDialog.java
r30737 r31285 70 70 71 71 /** 72 * The measurement label for radius if the currently selected loop is a circle. 73 */ 74 protected JLabel selectRadiusLabel; 75 76 /** 72 77 * The measurement label for the segment angle, actually updated, if 2 nodes are selected 73 78 */ … … 119 124 valuePanel.add(selectAreaLabel); 120 125 126 valuePanel.add(new JLabel(tr("Selection Radius"))); 127 128 selectRadiusLabel = new JLabel(getRadiusText(0)); 129 valuePanel.add(selectRadiusLabel); 130 121 131 JLabel angle = new JLabel(tr("Angle")); 122 132 angle.setToolTipText(tr("Angle between two selected Nodes")); … … 142 152 protected String getAreaText(double v) { 143 153 return NavigatableComponent.getSystemOfMeasurement().getAreaText(v, new DecimalFormat("#0.000"), 1e-3); 154 } 155 156 protected String getRadiusText(double v) { 157 return NavigatableComponent.getSystemOfMeasurement().getDistText(v, new DecimalFormat("#0.000"), 1e-3); 144 158 } 145 159 … … 160 174 double segAngle = 0.0; 161 175 double area = 0.0; 176 double radius = 0.0; 162 177 Node lastNode = null; 163 178 // Don't mix up way and nodes computation (fix #6872). Priority given to ways … … 181 196 Node lastN = null; 182 197 double wayArea = 0.0; 198 Double firstSegLength = null; 199 boolean isCircle = true; 183 200 for (Node n: w.getNodes()) { 184 201 if (lastN != null && lastN.getCoor() != null && n.getCoor() != null) { 185 length += lastN.getCoor().greatCircleDistance(n.getCoor()); 202 final double segLength = lastN.getCoor().greatCircleDistance(n.getCoor()); 203 if (firstSegLength == null) { 204 firstSegLength = segLength; 205 } 206 if (isCircle && Math.abs(firstSegLength - segLength) > 0.000001) { 207 isCircle = false; 208 } 209 length += segLength; 186 210 //http://local.wasp.uwa.edu.au/~pbourke/geometry/polyarea/ 187 211 wayArea += (MeasurementLayer.calcX(n.getCoor()) * MeasurementLayer.calcY(lastN.getCoor())) … … 197 221 area += wayArea; 198 222 } 223 if (ways.size() == 1 && area > 0.0) { 224 radius = length / (2 * Math.PI); 225 } 199 226 } 200 227 … … 202 229 final String angleLabel = getAngleText(segAngle); 203 230 final String areaLabel = getAreaText(area); 231 final String radiusLabel = getRadiusText(radius); 204 232 205 233 GuiHelper.runInEDT(new Runnable() { … … 209 237 segAngleLabel.setText(angleLabel); 210 238 selectAreaLabel.setText(areaLabel); 239 selectRadiusLabel.setText(radiusLabel); 211 240 } 212 241 });
Note:
See TracChangeset
for help on using the changeset viewer.