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.
[new] Highway access check (osmlab#588)
* streenamecheck logic * streetnamecheck config * streetnamecheck push2 * indexoutofboundsexception * indexoutofbounds error for line 120 * fir flagging * nomenklature * renamed vars * DEU tagging of associated street * fixing deprecated * raw highwayaccesscheck * highwayaccesscheck code * streetnamecheck tests * updated config * added StreetNameCheck * deleted highwayaccesscheck * docker adjustments * build successful * suppressions * redo builds * substituted unicode and deleted suppresion * raw highwayaccesscheck * testing renamed branch * highwayaccesscheck tests * highway access check documentation and docker build * deleted StreetNameCheck from HIghwayAccessCheck * del StreetNameCheck test from highwayaccess * del stretnamecheck testrule from highwayaccess * del streetnamecheck from available_checks * del streetnamecheck readme file * del streetnamecheck configs * PR resubmit * pass test * remove enabled true from highwayaccesscheck * change enabled value default to true * format config.json Co-authored-by: Nelli Aydinyan (INSIGHT GLOBAL INC) <[email protected]>
- Loading branch information
Showing
6 changed files
with
785 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# HighwayAccessCheck | ||
|
||
#### Description | ||
This check flags all the objects of type Way that contain the access tag equal to "yes" or "permissive" | ||
and the highway tag equal to one of the following: ["footway", "bridleway", "steps", "path", "cycleway", "pedestrian", | ||
"track", "bus_guideway", "busway", "raceway", "motorway", "trunk"] | ||
[OSMOSE](http://osmose.openstreetmap.fr/en/issues/open?item=3220). | ||
|
||
#### Configurables | ||
No configurable variables for HighwayAccessCheck | ||
|
||
|
||
#### Live Example | ||
|
||
[Way:705630999](https://www.openstreetmap.org/way/705630999) has the tags: access=yes, highway=cycleway. | ||
|
||
#### Code Review | ||
This check evaluates [Edges](https://github.com/osmlab/atlas/blob/dev/src/main/java/org/openstreetmap/atlas/geography/atlas/items/Edge.java). | ||
It flags the objects that contains the proper access and highway tags. | ||
|
||
##### Validating the Object | ||
We first validate that the incoming object is: | ||
* Hasn't been flagged previously | ||
* A Way (Main Edge) | ||
|
||
|
||
##### Flagging the Object | ||
###### Scenario | ||
* The object is a way, has an access tag "yes" or "permissive" and a highway tag from the following list: ["footway", "bridleway", "steps", "path", "cycleway", "pedestrian", | ||
"track", "bus_guideway", "busway", "raceway", "motorway", "trunk"]. | ||
|
||
##### Not flagging the Object | ||
* Any other scenario than the one described above. | ||
|
||
|
||
To learn more about the code, please look at the comments in the source code for the check: [HighwayAccessCheck.java](../../src/main/java/org/openstreetmap/atlas/checks/validation/tag/HighwayAccessCheck.java) |
113 changes: 113 additions & 0 deletions
113
src/main/java/org/openstreetmap/atlas/checks/validation/tag/HighwayAccessCheck.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,113 @@ | ||
package org.openstreetmap.atlas.checks.validation.tag; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import org.openstreetmap.atlas.checks.base.BaseCheck; | ||
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.walker.OsmWayWalker; | ||
import org.openstreetmap.atlas.tags.AccessTag; | ||
import org.openstreetmap.atlas.tags.HighwayTag; | ||
import org.openstreetmap.atlas.utilities.configuration.Configuration; | ||
|
||
/** | ||
* HighwayAccessCheck looks for ways that contain the access tag "yes" or "permissive". If the | ||
* access tag is found, then the highway tag is also checked. Finally, the object is flagged if the | ||
* highway tag is found in either motorway tags or in the footway tags provided in the beginning. | ||
* | ||
* @author v-naydinyan | ||
*/ | ||
public class HighwayAccessCheck extends BaseCheck<Long> | ||
{ | ||
|
||
private static final long serialVersionUID = -5533238262833368666L; | ||
private static final List<String> ACCESS_TAGS_TO_FLAG_DEFAULT = Arrays.asList("yes", | ||
"permissive"); | ||
private static final List<String> HIGHWAY_TAGS_TO_FLAG_DEFAULT = Arrays.asList("motorway", | ||
"trunk", "footway", "bridleway", "steps", "path", "cycleway", "pedestrian", "track", | ||
"bus_guideway", "busway", "raceway"); | ||
|
||
private static final List<String> FALLBACK_INSTRUCTIONS = Arrays.asList( | ||
"The access tag value is probably too generic for this way. A tag value of \"yes\" or \"permissive\" allows access to all types of traffic. If special access is granted or restricted on this way then please specify it or remove the access tag. See https://wiki.openstreetmap.org/wiki/Key:access?uselang=en#Transport_mode_restrictions for more information."); | ||
|
||
private final List<String> accessTagsToFlag; | ||
private final List<String> highwayTagsToFlag; | ||
|
||
/** | ||
* The default constructor that must be supplied. The Atlas Checks framework will generate the | ||
* checks with this constructor, supplying a configuration that can be used to adjust any | ||
* parameters that the check uses during operation. There are no internal variables | ||
* | ||
* @param configuration | ||
* the JSON configuration for this check | ||
*/ | ||
public HighwayAccessCheck(final Configuration configuration) | ||
{ | ||
super(configuration); | ||
|
||
this.accessTagsToFlag = this.configurationValue(configuration, "tags.accessTags", | ||
ACCESS_TAGS_TO_FLAG_DEFAULT); | ||
this.highwayTagsToFlag = this.configurationValue(configuration, "tags.highwayTags", | ||
HIGHWAY_TAGS_TO_FLAG_DEFAULT); | ||
|
||
} | ||
|
||
/** | ||
* This function will validate if the supplied atlas object is valid for the check. | ||
* | ||
* @param object | ||
* the atlas object supplied by the Atlas-Checks framework for evaluation | ||
* @return {@code true} if this object should be checked | ||
*/ | ||
@Override | ||
public boolean validCheckForObject(final AtlasObject object) | ||
{ | ||
return !this.isFlagged(object.getOsmIdentifier()) | ||
&& (object instanceof Edge && ((Edge) object).isMainEdge()); | ||
} | ||
|
||
@Override | ||
protected CheckFlag createFlag(final AtlasObject object, final String instruction) | ||
{ | ||
if (object instanceof Edge) | ||
{ | ||
return super.createFlag(new OsmWayWalker((Edge) object).collectEdges(), instruction); | ||
} | ||
return super.createFlag(object, instruction); | ||
} | ||
|
||
/** | ||
* This is the actual function that will check to see whether the object needs to be flagged. | ||
* | ||
* @param object | ||
* the atlas object supplied by the Atlas-Checks framework for evaluation | ||
* @return an optional {@link CheckFlag} object that | ||
*/ | ||
@Override | ||
protected Optional<CheckFlag> flag(final AtlasObject object) | ||
{ | ||
this.markAsFlagged(object.getOsmIdentifier()); | ||
|
||
final String accessTag = object.tag(AccessTag.KEY); | ||
final String highwayTag = object.tag(HighwayTag.KEY); | ||
|
||
// Check if the access tag is yes or permissive | ||
if (this.accessTagsToFlag.contains(accessTag) | ||
&& this.highwayTagsToFlag.contains(highwayTag)) | ||
{ | ||
return Optional.of(this.createFlag(object, this.getLocalizedInstruction(0))); | ||
|
||
} | ||
return Optional.empty(); | ||
} | ||
|
||
@Override | ||
protected List<String> getFallbackInstructions() | ||
{ | ||
return FALLBACK_INSTRUCTIONS; | ||
} | ||
|
||
} |
Oops, something went wrong.