Skip to content

Commit

Permalink
[new] Highway access check (osmlab#588)
Browse files Browse the repository at this point in the history
* 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
nelli-a and Nelli Aydinyan (INSIGHT GLOBAL INC) authored Jul 28, 2021
1 parent b28c4db commit 5db6e15
Show file tree
Hide file tree
Showing 6 changed files with 785 additions and 1 deletion.
13 changes: 12 additions & 1 deletion config/configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@
"tags":"coastline"
}
},
"GenericTagCheck": {
"GenericTagCheck": {
"db": {
"taginfo": "extra/taginfo-db.db",
"wikidata": "extra/wikidata.db"
Expand All @@ -365,6 +365,17 @@
"tags":"tags"
}
},
"HighwayAccessCheck": {
"tags": {
"accessTags":["yes", "permissive"],
"highwayTags": ["motorway", "trunk", "footway", "bridleway", "steps", "path", "cycleway", "pedestrian", "track",
"bus_guideway", "busway", "raceway"]
},
"challenge": {
"difficulty": "EASY",
"description": "Checks if the object access is overly permissive"
}
},
"HighwayMissingNameAndRefTagCheck": {
"min.nonContiguous.angle": 30.0,
"min.highway.type": "tertiary",
Expand Down
1 change: 1 addition & 0 deletions docs/available_checks.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ This document is a list of tables with a description and link to documentation f
| [ConstructionCheck](checks/constructionCheck.md) | The purpose of this check is to identify construction tags where the construction hasn't been checked on recently, or the expected finish date has been passed. |
| [FixMeReviewCheck](checks/fixMeReviewCheck.md) | The purpose of this check is to flag features that contain the "fixme"/"FIXME" tags with along with a variety of other important tags. |
| [GenericTagCheck](checks/genericTagCheck.md) | This check uses TagInfo and Wiki Data databases to look for invalid tags and suggest replacements. |
| [HighwayAccessCheck](checks/highwayAccessCheck.md) | The check flags the objects that contain the proper access and highway tags. |
| [HighwayMissingNameAndRefTagCheck](checks/highwayMissingNameAndRefTagCheck.md) | This check detects highways that are missing a name and ref tag. At least one of them is required. |
| [HighwayToFerryTagCheck](checks/highwayToFerryTagCheck.md) | The purpose of this check is to identify all Edges with route=FERRY and highway=PATH (or higher). |
| ImproperAndUnknownRoadNameCheck | This check flags improper road name values. |
Expand Down
36 changes: 36 additions & 0 deletions docs/checks/highwayAccessCheck.md
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)
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;
}

}
Loading

0 comments on commit 5db6e15

Please sign in to comment.