Skip to content

Commit

Permalink
Sink Island Check Enhancements (#36)
Browse files Browse the repository at this point in the history
* Update to remove edges with end node equal to certain amenity types

* Initial logic for Sink Island Enhancements

* Added peek logic to remove amenity type edge;

* Moved condition to exclude end nodes with certain amenity types to very end

* Use valid edge to filter, and modify check for end node having amentity tag value

* Update to unit test and dependencies

* Remove unnecessary lines in flag
  • Loading branch information
savannahostrowski authored and mgcuthbert committed May 2, 2018
1 parent 1d02130 commit 526220b
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
project.ext.versions = [
checkstyle: '7.6.1',
atlas: '5.0.12',
atlas: '5.0.14',
commons:'2.6',
atlas_generator: '4.0.4',
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
Expand All @@ -14,7 +15,9 @@
import org.openstreetmap.atlas.checks.flag.CheckFlag;
import org.openstreetmap.atlas.geography.atlas.items.AtlasObject;
import org.openstreetmap.atlas.geography.atlas.items.Edge;
import org.openstreetmap.atlas.geography.atlas.items.Node;
import org.openstreetmap.atlas.tags.AerowayTag;
import org.openstreetmap.atlas.tags.AmenityTag;
import org.openstreetmap.atlas.tags.HighwayTag;
import org.openstreetmap.atlas.tags.RouteTag;
import org.openstreetmap.atlas.tags.SyntheticBoundaryNodeTag;
Expand All @@ -28,13 +31,19 @@
* @author matthieun
* @author cuthbertm
* @author gpogulsky
* @author savannahostrowski
*/
public class SinkIslandCheck extends BaseCheck<Long>
{
public static final float LOAD_FACTOR = 0.8f;
public static final long TREE_SIZE_DEFAULT = 50;
private static final List<String> FALLBACK_INSTRUCTIONS = Arrays
.asList("Road is impossible to get out of.");
private static final float LOAD_FACTOR = 0.8f;
private static final long TREE_SIZE_DEFAULT = 50;
private static final List<String> FALLBACK_INSTRUCTIONS = Collections
.singletonList("Road is impossible to get out of.");
private static final String MOTORCYCLE_PARKING_AMENITY = "MOTORCYCLE_PARKING";
private static final String PARKING_ENTRANCE_AMENITY = "PARKING_ENTRANCE";
private static final List<String> amenityValuesToExclude = Arrays.asList(
AmenityTag.PARKING.toString(), AmenityTag.PARKING_SPACE.toString(),
MOTORCYCLE_PARKING_AMENITY, PARKING_ENTRANCE_AMENITY);
private static final long serialVersionUID = -1432150496331502258L;
private final int storeSize;
private final int treeSize;
Expand Down Expand Up @@ -171,6 +180,8 @@ private boolean validEdge(final AtlasObject object)
// Ignore any airport taxiways and runways, as these often create a sink island
&& !Validators.isOfType(object, AerowayTag.class, AerowayTag.TAXIWAY,
AerowayTag.RUNWAY)
// Ignore edges that have an amenity tag equal to one of the amenityValuesToExclude
&& !endNodeHasAmenityTypeToExclude(object)
// Ignore edges that have been way sectioned at the border, as has high probability
// of creating a false positive due to the sectioning of the way
&& !(SyntheticBoundaryNodeTag.isBoundaryNode(((Edge) object).end())
Expand All @@ -180,4 +191,23 @@ private boolean validEdge(final AtlasObject object)
// Ignore any highways tagged as areas
&& !TagPredicates.IS_AREA.test(object);
}

/**
* This function checks to see if the end node of an Edge AtlasObject has an amenity tag with
* one of the amenityValuesToExclude.
*
* @param object
* An AtlasObject (known to be an Edge)
* @return {@code true} if the end node of the end has one of the amenityValuesToExclude, and
* {@code false} otherwise
*/
private boolean endNodeHasAmenityTypeToExclude(final AtlasObject object)
{
final Edge edge = (Edge) object;
final Node endNode = edge.end();

return Validators.isOfType(endNode, AmenityTag.class, AmenityTag.PARKING,
AmenityTag.PARKING_SPACE, AmenityTag.MOTORCYCLE_PARKING,
AmenityTag.PARKING_ENTRANCE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,13 @@ public void testSinkDetection()
ConfigurationResolver.inlineConfiguration("{\"SinkIslandCheck.tree.size\": 3}")));
this.verifier.globallyVerify(flags -> Assert.assertEquals(1, flags.size()));
}

@Test
public void testSingleEdgeWithAmenity()
{
this.verifier.actual(this.setup.getSingleEdgeWithAmenityAtlas(), new SinkIslandCheck(
ConfigurationResolver.inlineConfiguration("{\"SinkIslandCheck.tree.size\": 3}")));
this.verifier.globallyVerify(flags -> Assert.assertEquals(0, flags.size()));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ public class SinkIslandCheckTestRule extends CoreTestRule
@Loc(value = TEST_7) }, tags = { "highway=primary", "oneway=yes" }) })
private Atlas singleEdgeAtlas;

@TestAtlas(nodes = { @Node(coordinates = @Loc(value = TEST_6)),
@Node(coordinates = @Loc(value = TEST_7), tags = { "amenity=parking" }) },

edges = { @Edge(id = "360978519000003", coordinates = { @Loc(value = TEST_6),
@Loc(value = TEST_7) }, tags = { "highway=primary", "oneway=yes" }) })
private Atlas singleEdgeWithAmenityAtlas;

public Atlas getSingleEdgeAtlas()
{
return this.singleEdgeAtlas;
Expand All @@ -68,4 +75,9 @@ public Atlas getTestAtlas()
{
return this.testAtlas;
}

public Atlas getSingleEdgeWithAmenityAtlas()
{
return this.singleEdgeWithAmenityAtlas;
}
}

0 comments on commit 526220b

Please sign in to comment.