Ticket #12867: power.diff

File power.diff, 2.4 KB (added by stoecker, 8 years ago)
  • src/org/openstreetmap/josm/data/validation/tests/PowerLines.java

     
    4141    protected static final Collection<String> POWER_TOWER_TAGS = Arrays.asList("tower", "pole");
    4242    /** Values for {@code power} key interpreted as power stations */
    4343    protected static final Collection<String> POWER_STATION_TAGS = Arrays.asList("station", "sub_station", "substation", "plant", "generator");
     44    /** Values for {@code building} key interpreted as power stations */
     45    protected static final Collection<String> BUILDING_STATION_TAGS = Arrays.asList("transformer_tower");
    4446    /** Values for {@code power} key interpreted as allowed power items */
    4547    protected static final Collection<String> POWER_ALLOWED_TAGS = Arrays.asList("switch", "transformer", "busbar", "generator", "switchgear",
    4648            "portal", "terminal", "insulator");
     
    173175     * @return {@code true} if power key is set and equal to station/sub_station/plant
    174176     */
    175177    protected static final boolean isPowerStation(OsmPrimitive p) {
    176         return isPowerIn(p, POWER_STATION_TAGS);
     178        return isPowerIn(p, POWER_STATION_TAGS) || isBuildingIn(p, BUILDING_STATION_TAGS);
    177179    }
    178180
    179181    /**
     
    195197    }
    196198
    197199    /**
    198      * Helper function to check if power tags is a certain value.
     200     * Helper function to check if power tag is a certain value.
    199201     * @param p The primitive to be tested
    200202     * @param values List of possible values
    201203     * @return {@code true} if power key is set and equal to possible values
     
    205207        return v != null && values != null && values.contains(v);
    206208    }
    207209
     210    /**
     211     * Helper function to check if building tag is a certain value.
     212     * @param p The primitive to be tested
     213     * @param values List of possible values
     214     * @return {@code true} if power key is set and equal to possible values
     215     */
     216    private static boolean isBuildingIn(OsmPrimitive p, Collection<String> values) {
     217        String v = p.get("building");
     218        return v != null && values != null && values.contains(v);
     219    }
     220
    208221    protected static class PowerLineError extends TestError {
    209222        private final Way line;
    210223