Skip to content

Commit

Permalink
Shadow Detection Check (osmlab#103)
Browse files Browse the repository at this point in the history
* check building parts

* convert heights; check buildings

* unit tests

* catch enclosed parts; config

* use walker for floating parts

* reflag single parts

* use buildings in walker

* use walker on all; update instruction

* fix num errors

* add relation support

* negative is ground

* add relation instruction

* handle building relations

* add building filter

* comments and docs

* make converter static

* fix typo

* code cleanup

* Long BaseCheck

* comment clean up

* sonar
  • Loading branch information
Bentleysb authored and matthieun committed Dec 19, 2018
1 parent 2fd747b commit 0eb11dd
Show file tree
Hide file tree
Showing 5 changed files with 1,144 additions and 0 deletions.
8 changes: 8 additions & 0 deletions config/configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,14 @@
"tags":"highway"
}
},
"ShadowDetectionCheck": {
"challenge": {
"description": "Verify the height and level tags to make sure the building does not float in 3D",
"blurb": "Fix floating buildings",
"instruction": "Open your favorite editor and check the height and placement of the building or building part for 3D alignment.",
"difficulty": "NORMAL"
}
},
"SharpAngleCheck": {
"threshold.degrees": 97.0,
"challenge": {
Expand Down
37 changes: 37 additions & 0 deletions docs/checks/shadowDetectionCheck.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Shadow Detection Check

This check flags buildings that are floating in 3D, casting abnormal shadows on the base map when rendered.

In OSM, 3D buildings are achieved by assigning `height` and/or `level` tags to ways or relations that have a `building` or `building:part` tag.
The [Simple 3D Buildings](https://wiki.openstreetmap.org/wiki/Simple_3D_buildings) osm wiki page documents much of this tagging scheme.
Important to this check is the use of `building:min_level` and `min_height` tags to define the bottom z level of a part of a building.
When improperly used these tags will cause building parts to become disconnected and float.

#### Live Examples

1. Way [id:260580125](https://www.openstreetmap.org/way/260580125) has a `building:min_level` tag that is > 0, but their is nothing below it to connect it to the ground.
2. Way [id:462577211](https://www.openstreetmap.org/way/462577211) has a `building:min_level` tag of 5, but the part below it,
way [id:462577208](https://www.openstreetmap.org/way/462577208), has a `level` tag of 4. This causes half the building to float one level above the other half.

#### Code Review

In [Atlas](https://github.com/osmlab/atlas), OSM elements are represented as Edges, Points, Lines, Nodes, Areas & Relations; in our case, we’re are looking at
[Edges](https://github.com/osmlab/atlas/blob/dev/src/main/java/org/openstreetmap/atlas/geography/atlas/items/Edge.java), and
[Relations](https://github.com/osmlab/atlas/blob/dev/src/main/java/org/openstreetmap/atlas/geography/atlas/items/Relation.java).

The first process in this check is to validate incoming objects, to see if they have the potential to be floating building parts.
This is done by testing that each object:

* is an Area or multipolygon Relation
* has a `building` or `building:part` tag
* has a `min_height` or `building:min_level` tag

Once an object has been validated it has its `min_height` or `building:min_level` tag checked to see if it is > 0, indicating it is off the ground.
If it is, a BFS walker is used to find connected building parts that form a path to the ground (see the `getFloatingParts` method).
The walker uses geographic indices and polygon overlap calculations to locate parts that overlap in 2D (see the `neighboringPart` method),
and then checks height and level tags to determine 3D overlap (see the `neighborsHeightContains` method).
When the walker is unable to find a 3D path to the ground, all the collected building parts are flagged as floating.

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

Loading

0 comments on commit 0eb11dd

Please sign in to comment.