Changeset 10001 in josm for trunk/src/org/openstreetmap/josm/actions/OrthogonalizeAction.java
- Timestamp:
- 2016-03-17T01:50:12+01:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/OrthogonalizeAction.java
r9999 r10001 328 328 329 329 // orthogonalize 330 final Direction[] HORIZONTAL= {Direction.RIGHT, Direction.LEFT};331 final Direction[] VERTICAL= {Direction.UP, Direction.DOWN};332 final Direction[][] ORIENTATIONS = {HORIZONTAL, VERTICAL};333 for (Direction[] orientation : ORIENTATIONS) {330 final Direction[] horizontal = {Direction.RIGHT, Direction.LEFT}; 331 final Direction[] vertical = {Direction.UP, Direction.DOWN}; 332 final Direction[][] orientations = {horizontal, vertical}; 333 for (Direction[] orientation : orientations) { 334 334 final Set<Node> s = new HashSet<>(allNodes); 335 int s _size = s.size();336 for (int dummy = 0; dummy < s _size; ++dummy) {335 int size = s.size(); 336 for (int dummy = 0; dummy < size; ++dummy) { 337 337 if (s.isEmpty()) { 338 338 break; 339 339 } 340 final Node dummy _n= s.iterator().next(); // pick arbitrary element of s341 342 final Set<Node> cs = new HashSet<>(); // will contain each node that can be reached from dummy _n343 cs.add(dummy _n); // walking only on horizontal / vertical segments340 final Node dummyN = s.iterator().next(); // pick arbitrary element of s 341 342 final Set<Node> cs = new HashSet<>(); // will contain each node that can be reached from dummyN 343 cs.add(dummyN); // walking only on horizontal / vertical segments 344 344 345 345 boolean somethingHappened = true; … … 364 364 } 365 365 366 final Map<Node, Double> nC = (orientation == HORIZONTAL) ? nY : nX;366 final Map<Node, Double> nC = (orientation == horizontal) ? nY : nX; 367 367 368 368 double average = 0; … … 385 385 // both heading nodes collapsing to one point, we simply skip this segment string and 386 386 // don't touch the node coordinates. 387 if (orientation == VERTICAL&& headingNodes.size() == 2 && cs.containsAll(headingNodes)) {387 if (orientation == vertical && headingNodes.size() == 2 && cs.containsAll(headingNodes)) { 388 388 continue; 389 389 } … … 404 404 final double dy = tmp.north() - n.getEastNorth().north(); 405 405 if (headingNodes.contains(n)) { // The heading nodes should not have changed 406 final double EPSILON= 1E-6;407 if (Math.abs(dx) > Math.abs( EPSILON* tmp.east()) ||408 Math.abs(dy) > Math.abs( EPSILON* tmp.east()))406 final double epsilon = 1E-6; 407 if (Math.abs(dx) > Math.abs(epsilon * tmp.east()) || 408 Math.abs(dy) > Math.abs(epsilon * tmp.east())) 409 409 throw new AssertionError(); 410 410 } else { … … 572 572 private static int angleToDirectionChange(double a, double deltaMax) throws RejectedAngleException { 573 573 a = standard_angle_mPI_to_PI(a); 574 double d0 = Math.abs(a);575 double d90 = Math.abs(a - Math.PI / 2);576 double d _m90 = Math.abs(a + Math.PI / 2);574 double d0 = Math.abs(a); 575 double d90 = Math.abs(a - Math.PI / 2); 576 double dm90 = Math.abs(a + Math.PI / 2); 577 577 int dirChange; 578 578 if (d0 < deltaMax) { … … 580 580 } else if (d90 < deltaMax) { 581 581 dirChange = 1; 582 } else if (d _m90 < deltaMax) {582 } else if (dm90 < deltaMax) { 583 583 dirChange = -1; 584 584 } else {
Note:
See TracChangeset
for help on using the changeset viewer.
