forked from osmlab/atlas-checks
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add InvalidPiersCheck and Update Atlas version (osmlab#209)
* Initial commit * Add config * Refactor to include new requirements(overlapping + same level/layer) * Fix checkstyle errors * SpotlessApply * Add polygonal building/ferry as valid case * Add sorting of edges * Add unit tests and md doc * Add java docs * Update doc and spotlessApply * Fix typo * Fix sonar bug * Update instructions
- Loading branch information
1 parent
01a8766
commit 7245262
Showing
11 changed files
with
678 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# InvalidPiersCheck | ||
|
||
#### Description | ||
|
||
The purpose of this check is to identify piers (OSM ways with man_made=Pier tag) that: (1) have a | ||
linear geometry but _DO NOT_ have an area=Yes Tag, or (2) have a polygonal geometry but _DO NOT_ | ||
have an area=Yes Tag. A pier must: (A) have a highway Tag or (B) have an overlapping highway at the | ||
same level and same layer as the pier or (C) be connected to a ferry route at the same layer and | ||
same level as the pier or (D) be connected to or overlapping a building/amenity=Ferry_Terminal at | ||
the same layer and same level as the pier. In addition, if a pier is polygonal, then it will also | ||
be considered a valid check candidate if it has building and/or amenity=Ferry_Terminal Tags. | ||
If a pier does not meet one or more of these criteria, this check will | ||
not flag the pier. | ||
|
||
#### Live Examples | ||
|
||
1. Edge [id:691592715](https://www.openstreetmap.org/way/691592715) is a linear pier with a highway | ||
tag and does not have an area=yes tag | ||
2. Edge [id:106157819](https://www.openstreetmap.org/way/106157819) is a polygonal pier with an | ||
overlapping highway and no area=yes tag. | ||
|
||
#### Code Review | ||
|
||
The check ensures that the Atlas object being evaluated is an [Edge](https://github.com/osmlab/atlas/blob/dev/src/main/java/org/openstreetmap/atlas/geography/atlas/items/Edge.java) | ||
with man_made = pier tag and no area = yes tag. All the way sectioned edges of the OSM way are first collected. | ||
Using all the collected edges, the geometry formed is verified to be either linear or polygonal. We | ||
can flag the edge if it has a highway tag with priority greater than or equal to minimum type set in | ||
the configurable or if the pier is polygonal with a building tag or is polygonal pier with amenity=ferry_terminal. | ||
If the above conditions are not met, then check if the way formed from the edges overlaps a highway | ||
or building or is connected to a ferry route or amenity=ferry_terminal. If any of these conditions | ||
are met, we can flag the edges. | ||
|
||
To learn more about the code, please look at the comments in the source code for the check. | ||
[InvalidPiersCheck.java](../../src/main/java/org/openstreetmap/atlas/checks/validation/linear/edges/InvalidPiersCheck.java) |
362 changes: 362 additions & 0 deletions
362
src/main/java/org/openstreetmap/atlas/checks/validation/linear/edges/InvalidPiersCheck.java
Large diffs are not rendered by default.
Oops, something went wrong.
83 changes: 83 additions & 0 deletions
83
...st/java/org/openstreetmap/atlas/checks/validation/linear/edges/InvalidPiersCheckTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package org.openstreetmap.atlas.checks.validation.linear.edges; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.openstreetmap.atlas.checks.configuration.ConfigurationResolver; | ||
import org.openstreetmap.atlas.checks.validation.verifier.ConsumerBasedExpectedCheckVerifier; | ||
|
||
/** | ||
* Unit test for {@link InvalidPiersCheck} | ||
* | ||
* @author sayas01 | ||
*/ | ||
public class InvalidPiersCheckTest | ||
{ | ||
@Rule | ||
public InvalidPiersCheckTestRule setup = new InvalidPiersCheckTestRule(); | ||
|
||
@Rule | ||
public ConsumerBasedExpectedCheckVerifier verifier = new ConsumerBasedExpectedCheckVerifier(); | ||
|
||
@Test | ||
public void testLinearPierConnectedToBuilding() | ||
{ | ||
this.verifier.actual(this.setup.getLinearPierConnectedToBuildingAtlas(), | ||
new InvalidPiersCheck(ConfigurationResolver.emptyConfiguration())); | ||
this.verifier.verifyNotNull(); | ||
this.verifier.globallyVerify(flags -> Assert.assertEquals(1, flags.size())); | ||
} | ||
|
||
@Test | ||
public void testLinearPierConnectedToFerry() | ||
{ | ||
this.verifier.actual(this.setup.getLinearPierConnectedToFerryAtlas(), | ||
new InvalidPiersCheck(ConfigurationResolver.emptyConfiguration())); | ||
this.verifier.verifyNotNull(); | ||
this.verifier.globallyVerify(flags -> Assert.assertEquals(1, flags.size())); | ||
} | ||
|
||
@Test | ||
public void testLinearPierWithHighwayTag() | ||
{ | ||
this.verifier.actual(this.setup.getLinearPierWithHighwayTag(), | ||
new InvalidPiersCheck(ConfigurationResolver.emptyConfiguration())); | ||
this.verifier.verifyNotNull(); | ||
this.verifier.globallyVerify(flags -> Assert.assertEquals(1, flags.size())); | ||
} | ||
|
||
@Test | ||
public void testMinimumHighwayConfiguration() | ||
{ | ||
this.verifier.actual(this.setup.getLinearPierWithHighwayTag(), | ||
new InvalidPiersCheck(ConfigurationResolver.inlineConfiguration( | ||
"{\"InvalidPiersCheck\":{\"highway.type.minimum.pier\":\"footway\"}}"))); | ||
this.verifier.globallyVerify(flags -> Assert.assertEquals(1, flags.size())); | ||
} | ||
|
||
@Test | ||
public void testPolygonalPierConnectedToBuilding() | ||
{ | ||
this.verifier.actual(this.setup.getPolygonalPierConnectedToBuildingAtlas(), | ||
new InvalidPiersCheck(ConfigurationResolver.emptyConfiguration())); | ||
this.verifier.verifyNotNull(); | ||
this.verifier.globallyVerify(flags -> Assert.assertEquals(1, flags.size())); | ||
} | ||
|
||
@Test | ||
public void testPolygonalPierOverlappingHighway() | ||
{ | ||
this.verifier.actual(this.setup.getPolygonalPierOverlappingHighwayAtlas(), | ||
new InvalidPiersCheck(ConfigurationResolver.emptyConfiguration())); | ||
this.verifier.verifyNotNull(); | ||
this.verifier.globallyVerify(flags -> Assert.assertEquals(1, flags.size())); | ||
} | ||
|
||
@Test | ||
public void testValidPolygonalPier() | ||
{ | ||
this.verifier.actual(this.setup.getValidPierAtlas(), | ||
new InvalidPiersCheck(ConfigurationResolver.emptyConfiguration())); | ||
this.verifier.verifyEmpty(); | ||
} | ||
} |
87 changes: 87 additions & 0 deletions
87
...ava/org/openstreetmap/atlas/checks/validation/linear/edges/InvalidPiersCheckTestRule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package org.openstreetmap.atlas.checks.validation.linear.edges; | ||
|
||
import org.openstreetmap.atlas.geography.atlas.Atlas; | ||
import org.openstreetmap.atlas.utilities.testing.CoreTestRule; | ||
import org.openstreetmap.atlas.utilities.testing.TestAtlas; | ||
import org.openstreetmap.atlas.utilities.testing.TestAtlas.Edge; | ||
import org.openstreetmap.atlas.utilities.testing.TestAtlas.Loc; | ||
import org.openstreetmap.atlas.utilities.testing.TestAtlas.Node; | ||
|
||
/** | ||
* {@link InvalidPiersCheckTest} test data | ||
* | ||
* @author sayas01 | ||
*/ | ||
public class InvalidPiersCheckTestRule extends CoreTestRule | ||
{ | ||
private static final String TEST_1 = "1.2042824, 103.7984000"; | ||
private static final String TEST_2 = "1.2052837, 103.7992780"; | ||
private static final String TEST_3 = "1.4216577, 103.9106552"; | ||
private static final String TEST_4 = "1.4217830, 103.9106544"; | ||
private static final String TEST_5 = "1.4217858, 103.9107547"; | ||
private static final String TEST_6 = "1.4221270, 103.9107607"; | ||
|
||
@TestAtlas( | ||
// Nodes | ||
nodes = { @Node(coordinates = @TestAtlas.Loc(value = TEST_1)), | ||
@Node(coordinates = @TestAtlas.Loc(value = TEST_2)) }, | ||
// Edges | ||
edges = { @Edge(id = "1000000", coordinates = { @Loc(value = TEST_1), | ||
@Loc(value = TEST_2) }, tags = { "highway=service", "man_made=pier" }) }) | ||
private Atlas linearPierWithHighwayTagAtlas; | ||
|
||
@TestAtlas( | ||
// Nodes | ||
nodes = { @Node(coordinates = @Loc(value = TEST_3)), | ||
@Node(coordinates = @Loc(value = TEST_4)), | ||
@Node(coordinates = @Loc(value = TEST_5)), | ||
@Node(coordinates = @Loc(value = TEST_6)) }, | ||
// Edges | ||
edges = { @Edge(id = "1000000", coordinates = { @Loc(value = TEST_3), | ||
@Loc(value = TEST_4), @Loc(value = TEST_5) }, tags = { "man_made=pier" }), | ||
@Edge(id = "2000000", coordinates = { @Loc(value = TEST_5), | ||
@Loc(value = TEST_6) }, tags = { "route=ferry" }), }) | ||
private Atlas linearPierConnectedToFerryAtlas; | ||
|
||
@TestAtlas(loadFromTextResource = "InvalidPiersCheck/polygonalPierOverlappingHighwayAtlas.txt") | ||
private Atlas polygonalPierOverlappingHighwayAtlas; | ||
|
||
@TestAtlas(loadFromTextResource = "InvalidPiersCheck/linearPierConnectedToBuildingAtlas.txt") | ||
private Atlas linearPierConnectedToBuildingAtlas; | ||
|
||
@TestAtlas(loadFromTextResource = "InvalidPiersCheck/polygonalPierConnectedToBuildingAtlas.txt") | ||
private Atlas polygonalPierConnectedToBuildingAtlas; | ||
|
||
@TestAtlas(loadFromTextResource = "InvalidPiersCheck/validPolygonalPier.txt") | ||
private Atlas validPierAtlas; | ||
|
||
public Atlas getLinearPierConnectedToBuildingAtlas() | ||
{ | ||
return this.linearPierConnectedToBuildingAtlas; | ||
} | ||
|
||
public Atlas getLinearPierConnectedToFerryAtlas() | ||
{ | ||
return this.linearPierConnectedToFerryAtlas; | ||
} | ||
|
||
public Atlas getLinearPierWithHighwayTag() | ||
{ | ||
return this.linearPierWithHighwayTagAtlas; | ||
} | ||
|
||
public Atlas getPolygonalPierConnectedToBuildingAtlas() | ||
{ | ||
return this.polygonalPierConnectedToBuildingAtlas; | ||
} | ||
|
||
public Atlas getPolygonalPierOverlappingHighwayAtlas() | ||
{ | ||
return this.polygonalPierOverlappingHighwayAtlas; | ||
} | ||
|
||
public Atlas getValidPierAtlas() | ||
{ | ||
return this.validPierAtlas; | ||
} | ||
} |
Oops, something went wrong.