Skip to content

Commit

Permalink
Add railway level_crossing check (osmlab#371)
Browse files Browse the repository at this point in the history
* Add railway level_crossing check

* Add documentation and fix bug found in first version

* Fix code smell issues

* Fix code smell complexity issue

* Add levelcrossing doc to available checks doc

* skipping rails that are also highways in some cases

* fix spotlessJava failure.

* add fix suggestions

* Update to deal with layers better.

* Ignore construction and proposed rails.

* Make it smell good.

* fix smells

* kick travis to retest

* one more smell removed.

* convert rail list to filter

* Add rail list to configuration file.

* Fix PR review requested changes

* Add enum for isValidLevelCrossingNode function
  • Loading branch information
atiannicelli authored Nov 4, 2020
1 parent d684325 commit 522cb00
Show file tree
Hide file tree
Showing 6 changed files with 990 additions and 1 deletion.
11 changes: 11 additions & 0 deletions config/configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,17 @@
"tags":"highway"
}
},
"LevelCrossingOnRailwayCheck": {
"layer.default": 0,
"railway.filter": "railway->rail,tram,disused,preserved,miniature,light_rail,subway,narrow_gauge",
"challenge": {
"description": "Tasks contain features which are missing or incorrectly tagged as railway:level_crossing.",
"blurb": "Fix level crossing railway/highway intersections",
"instruction": "Open your favorite editor and fix the railway/highway intersection nodes.",
"difficulty": "NORMAL",
"defaultPriority": "LOW"
}
},
"LineCrossingBuildingCheck": {
"challenge": {
"description": "The water body has invalid crossings by line item(s).",
Expand Down
3 changes: 2 additions & 1 deletion docs/available_checks.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ This document is a list of tables with a description and link to documentation f
| :--------- | :---------------- |
| BigNodeBadDataCheck | The purpose of this check is to flag any BigNodes that have may have some bad data. |
| ConnectivityCheck | This check identifies nodes that should be connected to nearby nodes or edges. |
| [DuplicateNodeCheck](docs/checks/duplicateNodeCheck.md) | The purpose of this check is to identify Nodes that are in the exact same location. |
| [DuplicateNodeCheck](checks/duplicateNodeCheck.md) | The purpose of this check is to identify Nodes that are in the exact same location. |
| [InvalidMiniRoundaboutCheck](checks/invalidMiniRoundaboutCheck.md) | The purpose of this check is to identify invalid mini-roundabouts (i.e. roundabouts that share the same rules as other roundabouts, but present as painted circles rather than physical circles). |
| [LevelCrossingOnRailwayCheck](checks/LevelCrossingOnRailwayCheck.md) | This check identifies incorrectly tagged or missing nodes at railway/highway intersections. |
| NodeValenceCheck | This check identifies nodes with too many connections. |
| [OrphanNodeCheck](tutorials/tutorial2-OrphanNodeCheck.md) | The purpose of this check is to identify untagged and unconnected Nodes in OSM. |

Expand Down
87 changes: 87 additions & 0 deletions docs/checks/LevelCrossingOnRailwayCheck.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Level Crossing on Railway Check

#### Description

The Purpose of this check is to detect and flag nodes under the four scenarios below:

1. When a railway crosses a highway on the same layer and intersection node is missing.
2. When a railway crosses a highway on the same layer and intersection node `railway=level_crossing` tag doesn't exist.
3. When a node `railway=level_crossing` tag exists, but the node is not the intersection of a highway and railway
4. When an area or way contain `railway=level_crossing` tag

#### Live Example

*Case 1: Bridge over Railway on same layer.*

Highway bridge goes over Railway, but layer missing on both railway and highway. The bridge should have a layer=1 tag
https://www.openstreetmap.org/way/80459517

*Case 2: Railway crosses a highway with no level_crossing tag*

The intersection node (OSM ID: 273135212) is missing a railway=level_crossing tag. Add the appropriate tag to the node.
https://www.openstreetmap.org/node/273135212

*Case 3: Railway crosses highway with no intersection node.*

The intersection of railway (OSM ID: 550221984) and highway (OSM ID: 637449204) is missing an intersection node. Add an appropriate intersection node.
https://www.openstreetmap.org/way/550221984 and https://www.openstreetmap.org/way/637449204 overlap without an intersection node.

*Case 4: Node is not a Level_crossing*

The node (OSM ID: 4147274783) is tagged with railway=level_crossing but is not the intersection of a railway and highway. Remove tag or add missing way.
https://www.openstreetmap.org/node/4147274783

*Case 5: Non-node tagged with railway=level_crossing*

Unable to find non-node features tagged with railway=level_crossing in OSM maps. Tested manually.

#### Code Review

In [Atlas](https://github.com/osmlab/atlas), OSM elements are represented as Edges, Points, Lines,
Nodes & Relations; in our case, we’re working with
[Edges](https://github.com/osmlab/atlas/blob/dev/src/main/java/org/openstreetmap/atlas/geography/atlas/items/Edge.java),
[Nodes](https://github.com/osmlab/atlas/blob/dev/src/main/java/org/openstreetmap/atlas/geography/atlas/items/Node.java), and
[Lines](https://github.com/osmlab/atlas/blob/dev/src/main/java/org/openstreetmap/atlas/geography/atlas/items/Line.java).
In OpenStreetMap, railways are [Ways](https://wiki.openstreetmap.org/wiki/Way) classified with
the `railway=rail`, `railway=tram`, `railway=disused`, `railway=miniature`, or `railway=preserved` tags. Highways are
[Ways](https://wiki.openstreetmap.org/wiki/Way) classified with `highway=*` tags. In this check we are interested in
the intersection of highweays and railways. These are represented by [Nodes](https://wiki.openstreetmap.org/wiki/Node).
We’ll use this information to filter our potential flag candidates.

A Car Navigable highway is any higway tagged with any of the following "highway:" tag values: MOTORWAY, TRUNK,
PRIMARY, SECONDARY, TERTIARY, UNCLASSIFIED, RESIDENTIAL, SERVICE, MOTORWAY_LINK, TRUNK_LINK, PRIMARY_LINK,
SECONDARY_LINK, TERTIARY_LINK, LIVING_STREET, TRACK, ROAD.

A valid intersection of a car navigable highway and railway should have a [Node](https://wiki.openstreetmap.org/wiki/Node)
at the intersection of the ways that is classified with a `railway=level_crossing`. Nodes at intersections are only
necessary if the railway and highway ways are on the same layer. It is common for a way that is classified with a
`bridge=yes` or `tunnel=yes` to go over or under another way without an intersection node. In those cases a node at the
intersection is not necessary, and if a node does exist at that intersection then the `railway=level_crossing` tag
should not be used. This check assumes that if a highway or railway has been tagged to indicate that this way is a
bridge or tunnel and the layer tag has not been set, then there is an implied layer of 1 for bridges and -1 for
tunnels.

Note: Railways and highways that are under construction will be ignored by this check. A way is under construction if
any tag key or tag value contains the string "construction".

The code has three major sections to check for all possible types of railway/highway intersections.

1. The first section is specifically designed to look at all [Nodes](https://wiki.openstreetmap.org/wiki/Node). Each
node is examined to count the number of highways and railways that contain this node.
1. If a node is contained in at least one highway and at least one railway on the same layer and is not tagged
with `railway=level_crossing` then it is flagged. A fix suggestion exists for this type of issue and will suggest
to add a railway=level_crossing tag to the Node.
1. If a node is tagged with `railway=level_crossing` but is not contained in any railways or highways or all
highways and railways are on separate layers then it is flagged. A fix suggestion exists for this issue and will suggest
to remove the invalid tag.

2. The second section examines all objects that are not Nodes or Points. If any non-node or point object is tagged
with `railway=level_crossing` then it is flagged. A fix suggestion exists for this issue and it will suggest to remove
the invalid tag.

3. The final section of code examines all railway [Lines](https://github.com/osmlab/atlas/blob/dev/src/main/java/org/openstreetmap/atlas/geography/atlas/items/Line.java).
Each railway is traversed to find any intersection with a car navigable highway. If an intersection is found that is
missing a node then it is flagged. This issue type does not include a fix suggestion.

To learn more about the code, please look at the comments in the source code for the check.
[LevelCrossingOnRailwayCheck.java](../../src/main/java/org/openstreetmap/atlas/checks/validation/intersections/LevelCrossingOnRailwayCheck.java)
Loading

0 comments on commit 522cb00

Please sign in to comment.