Changeset 4033 in osm for applications/editors/josm


Ignore:
Timestamp:
2007-08-08T23:58:24+02:00 (17 years ago)
Author:
frsantos
Message:

Check for empty (without segments) ways

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/UntaggedWay.java

    r3259 r4033  
    33import static org.openstreetmap.josm.tools.I18n.tr;
    44
    5 import java.util.*;
     5import java.util.HashSet;
     6import java.util.Map;
     7import java.util.Set;
    68
     9import org.openstreetmap.josm.command.Command;
     10import org.openstreetmap.josm.command.DeleteCommand;
    711import org.openstreetmap.josm.data.osm.Way;
    8 import org.openstreetmap.josm.plugins.validator.*;
     12import org.openstreetmap.josm.plugins.validator.Severity;
     13import org.openstreetmap.josm.plugins.validator.Test;
     14import org.openstreetmap.josm.plugins.validator.TestError;
    915/**
    1016 * Checks for untagged ways
     
    1420public class UntaggedWay extends Test
    1521{
     22        /** Empty way error */
     23        protected static final int EMPTY_WAY    = 0;
     24        /** Untagged way error */
     25        protected static final int UNTAGGED_WAY = 1;
     26        /** Unnamed way error */
     27        protected static final int UNNAMED_WAY  = 2;
     28
    1629    /** Tags allowed in a way */
    1730    public static final String[] ALLOWED_TAGS = new String[] { "created_by", "converted_by" };
     
    6477                   
    6578                    if( !hasName)
    66                         errors.add( new TestError(this, Severity.WARNING, tr("Unnamed ways"), w) );
     79                        errors.add( new TestError(this, Severity.WARNING, tr("Unnamed ways"), w, UNNAMED_WAY ) );
    6780                }
    6881            }
     
    7184        if( numTags == 0 )
    7285        {
    73             errors.add( new TestError(this, Severity.WARNING, tr("Untagged ways"), w) );
     86            errors.add( new TestError(this, Severity.WARNING, tr("Untagged ways"), w, UNTAGGED_WAY) );
    7487        }
     88       
     89        if( w.segments.size() == 0 )
     90        {
     91            errors.add( new TestError(this, Severity.ERROR, tr("Empty ways"), w, EMPTY_WAY) );
     92        }
     93       
    7594        }               
     95       
     96        @Override
     97        public boolean isFixable(TestError testError)
     98        {
     99                if( testError.getTester() instanceof UntaggedWay )
     100                {
     101                        return testError.getInternalCode() == EMPTY_WAY;
     102                }
     103               
     104                return false;
     105        }
     106       
     107        @Override
     108        public Command fixError(TestError testError)
     109        {
     110                return new DeleteCommand(testError.getPrimitives());
     111        }
    76112}
Note: See TracChangeset for help on using the changeset viewer.