Changeset 5352 in josm for trunk


Ignore:
Timestamp:
2012-07-19T21:54:10+02:00 (12 years ago)
Author:
Don-vip
Message:

fix #7874 - do not warn about "untagged ways" that are relation members with role "outer", "inner", "perimeter", "edge" or "outline"

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/validation/tests/UntaggedWay.java

    r5287 r5352  
    55
    66import java.util.HashSet;
    7 import java.util.LinkedList;
    87import java.util.Map;
    98import java.util.Set;
     
    1110import org.openstreetmap.josm.Main;
    1211import org.openstreetmap.josm.command.Command;
     12import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1313import org.openstreetmap.josm.data.osm.Relation;
    1414import org.openstreetmap.josm.data.osm.RelationMember;
     
    3939    protected static final int COMMENTED_WAY = 306;
    4040
    41     private LinkedList<Way> multipolygonways;
     41    private Set<Way> waysUsedInRelations;
    4242
    4343    /** Ways that must have a name */
     
    5151        NAMED_WAYS.add( "residential" );
    5252        NAMED_WAYS.add( "pedestrian" ); ;
     53    }
     54   
     55    /** Whitelist of roles allowed to reference an untagged way */
     56    public static final Set<String> WHITELIST = new HashSet<String>();
     57    static {
     58        WHITELIST.add( "outer" );
     59        WHITELIST.add( "inner" );
     60        WHITELIST.add( "perimeter" );
     61        WHITELIST.add( "edge" );
     62        WHITELIST.add( "outline" );
    5363    }
    5464
     
    93103        }
    94104
    95         if (!w.isTagged() && !multipolygonways.contains(w)) {
     105        if (!w.isTagged() && !waysUsedInRelations.contains(w)) {
    96106            if (w.hasKeys()) {
    97107                errors.add(new TestError(this, Severity.WARNING, tr("Untagged ways (commented)"), COMMENTED_WAY, w));
     
    111121    public void startTest(ProgressMonitor monitor) {
    112122        super.startTest(monitor);
    113         multipolygonways = new LinkedList<Way>();
     123        waysUsedInRelations = new HashSet<Way>();
    114124        for (Relation r : Main.main.getCurrentDataSet().getRelations()) {
    115             if (r.isUsable() && r.isMultipolygon()) {
     125            if (r.isUsable()) {
    116126                for (RelationMember m : r.getMembers()) {
    117                     if (m.getMember() != null && m.getMember() instanceof Way &&
    118                             m.getMember().isUsable() && !m.getMember().isTagged()) {
    119                         multipolygonways.add((Way)m.getMember());
     127                    if (r.isMultipolygon() || WHITELIST.contains(m.getRole())) {
     128                        OsmPrimitive member = m.getMember();
     129                        if (member != null && member instanceof Way && member.isUsable() && !member.isTagged()) {
     130                            waysUsedInRelations.add((Way)member);
     131                        }
    120132                    }
    121133                }
     
    126138    @Override
    127139    public void endTest() {
    128         multipolygonways = null;
     140        waysUsedInRelations = null;
    129141        super.endTest();
    130142    }
Note: See TracChangeset for help on using the changeset viewer.