- Timestamp:
- 2018-04-27T00:42:18+02:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/tests/RightAngleBuildingTest.java
r13688 r13689 5 5 6 6 import java.util.Collections; 7 import java.util.List; 7 8 8 9 import org.openstreetmap.josm.actions.OrthogonalizeAction; … … 44 45 if (!w.isUsable() || !w.isClosed() || !isBuilding(w)) return; 45 46 46 for (Pair<Double, Node> pair: w.getAngles()) { 47 if (!checkAngle(w, pair.a, pair.b)) 47 List<Pair<Double, Node>> angles = w.getAngles(); 48 for (Pair<Double, Node> pair: angles) { 49 if (checkAngle(w, pair.a, pair.b)) { 50 TestError.Builder builder = TestError.builder(this, Severity.WARNING, 3701) 51 .message(tr("Building with an almost square angle")) 52 .primitives(w) 53 .highlight(pair.b); 54 if (angles.stream().noneMatch(p -> Math.abs(p.a - 90) >= maxAngleDelta)) { 55 builder.fix(() -> { 56 try { 57 return OrthogonalizeAction.orthogonalize(Collections.singleton(w)); 58 } catch (InvalidUserInputException e) { 59 Logging.warn(e); 60 return null; 61 } 62 }); 63 } 64 errors.add(builder.build()); 48 65 return; 66 } 49 67 } 50 68 } … … 59 77 private boolean checkAngle(Way w, double angle, Node n) { 60 78 double difference = Math.abs(angle - 90); 61 62 if (difference > minAngleDelta && difference < maxAngleDelta) { 63 errors.add(TestError.builder(this, Severity.WARNING, 3701) 64 .message(tr("Building with an almost square angle")) 65 .primitives(w) 66 .highlight(n) 67 .fix(() -> { 68 try { 69 return OrthogonalizeAction.orthogonalize(Collections.singleton(w)); 70 } catch (InvalidUserInputException e) { 71 Logging.warn(e); 72 return null; 73 } 74 }) 75 .build()); 76 return false; 77 } 78 79 return true; 79 return difference > minAngleDelta && difference < maxAngleDelta; 80 80 } 81 81 }
Note:
See TracChangeset
for help on using the changeset viewer.