Changeset 30623 in osm for applications/editors/josm
- Timestamp:
- 2014-09-03T22:48:35+02:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/simplifyarea/src/sk/zdila/josm/plugin/simplify/SimplifyAreaAction.java
r30145 r30623 40 40 public class SimplifyAreaAction extends JosmAction { 41 41 42 private static final long serialVersionUID = 6854238214548011750L;43 44 42 public SimplifyAreaAction() { 45 43 super(tr("Simplify Area"), "simplify", tr("Delete unnecessary nodes from an area."), … … 48 46 } 49 47 50 51 48 private List<Bounds> getCurrentEditBounds() { 52 49 return Main.main.getEditLayer().data.getDataSourceBounds(); 53 50 } 54 55 51 56 52 private boolean isInBounds(final Node node, final List<Bounds> bounds) { … … 62 58 return false; 63 59 } 64 65 60 66 61 private boolean confirmWayWithNodesOutsideBoundingBox() { … … 76 71 } 77 72 78 79 73 private void alertSelectAtLeastOneWay() { 80 74 HelpAwareOptionPane.showOptionDialog(Main.parent, tr("Please select at least one way to simplify."), tr("Warning"), JOptionPane.WARNING_MESSAGE, null); 81 75 } 82 83 76 84 77 private boolean confirmSimplifyManyWays(final int numWays) { … … 90 83 return ret == 0; 91 84 } 92 93 85 94 86 @Override … … 190 182 } 191 183 192 193 184 // average nearby nodes 194 185 private Collection<Command> averageNearbyNodes(final Collection<Way> ways, final Collection<Node> nodesAlreadyDeleted) { … … 250 241 } 251 242 252 final double dist = coordMap.get(n1).greatCircleDistance(coordMap.get(n2)); 253 if (dist < minDist && dist < mergeThreshold) { 254 minDist = dist; 255 node1 = n1; 256 node2 = n2; 243 final LatLon a = coordMap.get(n1); 244 final LatLon b = coordMap.get(n2); 245 246 if (a != null && b != null) { 247 final double dist = a.greatCircleDistance(b); 248 if (dist < minDist && dist < mergeThreshold) { 249 minDist = dist; 250 node1 = n1; 251 node2 = n2; 252 } 257 253 } 258 254 } … … 269 265 } 270 266 } 271 272 267 273 268 final Collection<Command> commands = new ArrayList<Command>(); … … 311 306 } 312 307 313 314 308 private void addNodesToDelete(final Collection<Node> nodesToDelete, final Way w) { 315 309 final double angleThreshold = Main.pref.getDouble(SimplifyAreaPreferenceSetting.ANGLE_THRESHOLD, 10); … … 408 402 } 409 403 410 411 404 public static double computeConvectAngle(final LatLon coord1, final LatLon coord2, final LatLon coord3) { 412 405 final double angle = Math.abs(heading(coord2, coord3) - heading(coord1, coord2)); 413 406 return Math.toDegrees(angle < Math.PI ? angle : 2 * Math.PI - angle); 414 407 } 415 416 408 417 409 public static double computeArea(final LatLon coord1, final LatLon coord2, final LatLon coord3) { … … 426 418 } 427 419 428 429 420 public static double R = 6378135; 430 421 … … 432 423 return R * Math.asin(sin(l1.greatCircleDistance(l2) / R) * sin(heading(l1, l2) - heading(l1, l3))); 433 424 } 434 435 425 436 426 public static double heading(final LatLon a, final LatLon b) { … … 445 435 } 446 436 447 448 437 @Override 449 438 protected void updateEnabledState() { … … 455 444 } 456 445 457 458 446 @Override 459 447 protected void updateEnabledState(final Collection<? extends OsmPrimitive> selection) { 460 448 setEnabled(selection != null && !selection.isEmpty()); 461 449 } 462 463 450 }
Note:
See TracChangeset
for help on using the changeset viewer.