From 761877b4f996ecf29bf5d635be4720546f9fe51c Mon Sep 17 00:00:00 2001 From: Ladyslaw Wlodarski <69821285+ladwlo@users.noreply.github.com> Date: Thu, 14 Jan 2021 16:04:23 +0100 Subject: [PATCH] AutoFix suggestions for Building Road Intersection check (#392) --- .../intersections/BuildingRoadIntersectionCheck.java | 4 ++++ .../intersections/BuildingRoadIntersectionCheckTest.java | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/openstreetmap/atlas/checks/validation/intersections/BuildingRoadIntersectionCheck.java b/src/main/java/org/openstreetmap/atlas/checks/validation/intersections/BuildingRoadIntersectionCheck.java index 61b55af7c..aee65ba8b 100644 --- a/src/main/java/org/openstreetmap/atlas/checks/validation/intersections/BuildingRoadIntersectionCheck.java +++ b/src/main/java/org/openstreetmap/atlas/checks/validation/intersections/BuildingRoadIntersectionCheck.java @@ -10,6 +10,8 @@ import org.openstreetmap.atlas.checks.base.BaseCheck; import org.openstreetmap.atlas.checks.flag.CheckFlag; import org.openstreetmap.atlas.geography.Location; +import org.openstreetmap.atlas.geography.atlas.change.FeatureChange; +import org.openstreetmap.atlas.geography.atlas.complete.CompleteEntity; import org.openstreetmap.atlas.geography.atlas.items.Area; import org.openstreetmap.atlas.geography.atlas.items.AtlasObject; import org.openstreetmap.atlas.geography.atlas.items.Edge; @@ -39,6 +41,7 @@ * * @author mgostintsev * @author sayas01 + * @author ladwlo (autofix) */ public class BuildingRoadIntersectionCheck extends BaseCheck { @@ -128,6 +131,7 @@ protected Optional flag(final AtlasObject object) ignoreTags()); final CheckFlag flag = new CheckFlag(getTaskIdentifier(building)); flag.addObject(building); + flag.addFixSuggestion(FeatureChange.remove(CompleteEntity.shallowFrom(building))); this.handleIntersections(intersectingEdges, flag, building); return flag.getPolyLines().size() > 1 ? Optional.of(flag) : Optional.empty(); } diff --git a/src/test/java/org/openstreetmap/atlas/checks/validation/intersections/BuildingRoadIntersectionCheckTest.java b/src/test/java/org/openstreetmap/atlas/checks/validation/intersections/BuildingRoadIntersectionCheckTest.java index 246ea6579..fb8eb1dfc 100644 --- a/src/test/java/org/openstreetmap/atlas/checks/validation/intersections/BuildingRoadIntersectionCheckTest.java +++ b/src/test/java/org/openstreetmap/atlas/checks/validation/intersections/BuildingRoadIntersectionCheckTest.java @@ -37,6 +37,7 @@ public void testCheck() { this.verifier.actual(this.setup.getAtlas(), check); this.verifier.verifyExpectedSize(2); + this.verifier.verify(flag -> Assert.assertEquals(1, flag.getFixSuggestions().size())); } /** @@ -77,6 +78,7 @@ public void testHighwayFilterConfig() { this.verifier.actual(this.setup.getCorewayIntersectionAtlas(), highwayFilterCheck); this.verifier.verifyExpectedSize(2); + this.verifier.verify(flag -> Assert.assertEquals(1, flag.getFixSuggestions().size())); } @Test @@ -118,7 +120,7 @@ public void testSpanishCheck() flag.getInstructions().contains("Edificio(id-323232) cruza calle(id-292929)")); }); this.verifier.verifyExpectedSize(2); - + this.verifier.verify(flag -> Assert.assertEquals(1, flag.getFixSuggestions().size())); } /**