Skip to content

Latest commit

 

History

History
49 lines (38 loc) · 2.94 KB

conflictingAreaTagCombination.md

File metadata and controls

49 lines (38 loc) · 2.94 KB

Conflicting Area Tag Check

Description

This check flags Atlas Area Objects that have conflicting tag combinations. An Atlas Area Object is an enclosed Polygon that (by default) uses this tag filter to differentiate itself from other Atlas Objects.

Live Example

  1. An OSM Editor has mapped this feature (osm id: 372444940) as a building and a tree, using the nautual=TREE and building=YES tags. These two tags should not logically co-exist. An editor should review the feature and make the appropriate changes.

  2. This closed Way (osm id: 452182969) is tagged as natural=WATER and man_made=WATER_TOWER. The natural=WATER tag should be used to tag areas of water (e.g. lakes, multipolygon water relations), or water bodies. Water towers are man made structures that contain water, therefore, these two should not co-exist.

Code Review

In Atlas, OSM elements are represented as Edges, Points, Lines, Nodes & Relations; in our case, we’re are looking at Areas.

Our first goal is to validate the incoming Atlas object. Valid features for this check will satisfy the following conditions:

  • Must be an Atlas Area Object
  • Cannot have an area=NO tag.
@Override
public boolean validCheckForObject(final AtlasObject object)
{
    return object instanceof Area
        && Validators.isNotOfType(object, AreaTag.class, AreaTag.NO);
}

Using the Validators class, we store each conflicting combination into a Predicate variable that can be used to test its truthiness.

private static final Predicate<Taggable> NATURAL_WATER_MANMANDE = object -> 
        Validators.isOfType(object, NaturalTag.class, NaturalTag.WATER)
        && Validators.isNotOfType(object, ManMadeTag.class, ManMadeTag.RESERVOIR_COVERED, ManMadeTag.WASTEWATER_PLANT);

For the variable above to be truthy, the following conditions must be true:

  • Area has natural=WATER tag
  • Area has a man_made tag AND its' value must not equal RESERVOIR_COVERED OR WASTEWATER_PLANT

Then, we can easily test each combination using Predicate's test() function.

if (NATURAL_WATER_MANMANDE.test(object))
{
    flag.addInstruction(this.getLocalizedInstruction(FOUR));
    hasConflictingCombinations = true;
}

To learn more about the code, please look at the comments in the source code for the check. ConflictingAreaTagCombination.java