Ignore:
Timestamp:
2009-03-08T14:39:18+01:00 (15 years ago)
Author:
stoecker
Message:

some validator fixes, reenabled debug

Location:
applications/editors/josm/plugins/validator
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/validator/build.xml

    r14003 r14015  
    1010    <target name="compile" depends="init">
    1111        <echo message="creating ${plugin.jar}"/>
    12         <javac srcdir="src" classpath="${josm}" debug="false" destdir="${plugin.build.dir}">
     12        <javac srcdir="src" classpath="${josm}" debug="true" destdir="${plugin.build.dir}">
    1313            <compilerarg value="-Xlint:deprecation"/>
    1414            <compilerarg value="-Xlint:unchecked"/>
     
    2626                <attribute name="Plugin-Description" value="An OSM data validator. It checks for problems in data, and provides fixes for the common ones. Spellcheck integrated for tag names."/>
    2727                <attribute name="Plugin-Link" value="http://wiki.openstreetmap.org/index.php/JOSM/Plugins/Validator"/>
    28                 <attribute name="Plugin-Mainversion" value="1465"/>
     28                <attribute name="Plugin-Mainversion" value="1470"/>
    2929                <attribute name="Plugin-Version" value="${version.entry.commit.revision}"/>
    3030            </manifest>
  • applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/PreferenceEditor.java

    r13497 r14015  
    4545    public static final String PREF_TESTS_BEFORE_UPLOAD = PREFIX + ".testsBeforeUpload";
    4646
     47    /** The preferences key for ignored severity other on upload */
     48    public static final String PREF_OTHER_UPLOAD = PREFIX + ".otherUpload";
     49
    4750    /**
    4851     * The preferences key for enabling the permanent filtering
     
    5356    private JCheckBox prefUseIgnore;
    5457    private JCheckBox prefUseLayer;
     58    private JCheckBox prefOtherUpload;
    5559
    5660    /** The list of all tests */
     
    7377        prefUseLayer.setToolTipText(tr("Use the error layer to display problematic elements."));
    7478        testPanel.add(prefUseLayer, GBC.eol());
     79
     80        prefOtherUpload = new JCheckBox(tr("Show informational level on upload."), Main.pref.getBoolean(PREF_OTHER_UPLOAD, false));
     81        prefOtherUpload.setToolTipText(tr("Show the informational tests in the upload check windows."));
     82        testPanel.add(prefOtherUpload, GBC.eol());
    7583
    7684        GBC a = GBC.eol().insets(-5,0,0,0);
     
    117125        Main.pref.put( PREF_TESTS_BEFORE_UPLOAD, testsBeforeUpload.toString());
    118126        Main.pref.put( PREF_USE_IGNORE, prefUseIgnore.isSelected());
     127        Main.pref.put( PREF_OTHER_UPLOAD, prefOtherUpload.isSelected());
    119128        Main.pref.put( PREF_LAYER, prefUseLayer.isSelected());
    120129        return false;
  • applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/Test.java

    r13497 r14015  
    2222 * validated. These primitives are always visited in the same order: nodes
    2323 * first, then ways.
    24  * 
     24 *
    2525 * @author frsantos
    2626 */
     
    2929    /** Name of the test */
    3030    protected String name;
    31    
     31
    3232    /** Description of the test */
    3333    protected String description;
    34    
     34
    3535    /** Whether this test is enabled. Enabled by default */
    3636    protected boolean enabled = true;
     
    4141    /** The preferences check for validation on upload */
    4242    protected JCheckBox checkBeforeUpload;
    43    
     43
    4444    /** Whether this test must check before upload. Enabled by default */
    4545    protected boolean testBeforeUpload = true;
     
    6464        this.description = description;
    6565    }
    66    
     66
    6767    /**
    6868     * Constructor
     
    7373        this.name = name;
    7474    }
    75    
     75
    7676    /**
    7777     * Initializes any global data used this tester.
    7878     * @param plugin The plugin
    7979     * @throws Exception When cannot initialize the test
    80      */ 
     80     */
    8181    public static void initialize(OSMValidatorPlugin plugin) throws Exception {}
    82    
     82
    8383    /**
    8484     * Notification of the start of the test. The tester can initialize the
    8585     * structures it may need for this test
    86      */ 
    87     public void startTest() 
     86     */
     87    public void startTest()
    8888    {
    8989        errors = new ArrayList<TestError>(30);
     
    9393     * Flag notifying that this test is run over a partial data selection
    9494     * @param partialSelection Whether the test is on a partial selection data
    95      */ 
    96     public void setPartialSelection(boolean partialSelection) 
     95     */
     96    public void setPartialSelection(boolean partialSelection)
    9797    {
    9898        this.partialSelection = partialSelection;
    9999    }
    100    
     100
    101101    /**
    102102     * Gets the validation errors accumulated until this moment.
    103      * @return The list of errors 
    104      */
    105     public List<TestError> getErrors() 
     103     * @return The list of errors
     104     */
     105    public List<TestError> getErrors()
    106106    {
    107107        return errors;
    108108    }
    109    
     109
    110110    /**
    111111     * Notification of the end of the test. The tester may perform additional
    112      * actions and destroy the used structures 
     112     * actions and destroy the used structures
    113113     */
    114114    public void endTest() {}
     
    117117     * Visits all primitives to be tested. These primitives are always visited
    118118     * in the same order: nodes first, then ways.
    119      * 
     119     *
    120120     * @param selection The primitives to be tested
    121121     */
    122     public void visit(Collection<OsmPrimitive> selection) 
     122    public void visit(Collection<OsmPrimitive> selection)
    123123    {
    124124        for (OsmPrimitive p : selection)
     
    136136
    137137    /**
    138      * Allow the tester to manage its own preferences 
     138     * Allow the tester to manage its own preferences
    139139     * @param testPanel The panel to add any preferences component
    140140     */
    141     public void addGui(JPanel testPanel) 
     141    public void addGui(JPanel testPanel)
    142142    {
    143143        checkEnabled = new JCheckBox(name, enabled);
     
    161161        return false;
    162162    }
    163    
     163
    164164    /**
    165165     * Fixes the error with the appropiate command
    166      * 
     166     *
    167167     * @param testError
    168168     * @return The command to fix the error
     
    172172        return null;
    173173    }
    174    
     174
    175175    /**
    176176     * Returns true if the given error can be fixed automatically
    177      * 
     177     *
    178178     * @param testError The error to check if can be fixed
    179179     * @return true if the error can be fixed
  • applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/ValidateUploadHook.java

    r13497 r14015  
    6060            test.visit(selection);
    6161            test.endTest();
    62             errors.addAll( test.getErrors() );
     62            if(Main.pref.getBoolean(PreferenceEditor.PREF_OTHER_UPLOAD, false))
     63                errors.addAll( test.getErrors() );
     64            else
     65            {
     66                for(TestError e : test.getErrors())
     67                {
     68                    if(e.getSeverity() != Severity.OTHER)
     69                        errors.add(e);
     70                }
     71            }
    6372        }
    6473        tests = null;
  • applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/TagChecker.java

    r13918 r14015  
    1515import java.text.MessageFormat;
    1616import java.util.ArrayList;
     17import java.util.Arrays;
    1718import java.util.Collection;
    1819import java.util.Collections;
     
    255256        if(presets != null)
    256257        {
     258            Way w = new Way();
     259            w.checkTagged();
     260            w.checkDirectionTagged();
    257261            presetsValueData = new Bag<String, String>();
     262            for(String a : OsmPrimitive.uninteresting)
     263                presetsValueData.add(a);
     264            for(String a : OsmPrimitive.directionKeys)
     265                presetsValueData.add(a);
     266            for(String a : Main.pref.getCollection(PreferenceEditor.PREFIX + ".knownkeys",
     267            Arrays.asList(new String[]{"is_in", "int_ref", "fixme", "population"})))
     268                presetsValueData.add(a);
    258269            for(TaggingPreset p : presets)
    259270            {
     
    270281                        TaggingPreset.Key k = (TaggingPreset.Key) i;
    271282                        presetsValueData.add(k.key, k.value);
     283                    }
     284                    else if(i instanceof TaggingPreset.Text)
     285                    {
     286                        TaggingPreset.Text k = (TaggingPreset.Text) i;
     287                        presetsValueData.add(k.key);
     288                    }
     289                    else if(i instanceof TaggingPreset.Check)
     290                    {
     291                        TaggingPreset.Check k = (TaggingPreset.Check) i;
     292                        presetsValueData.add(k.key, "yes");
     293                        presetsValueData.add(k.key, "no");
    272294                    }
    273295                }
     
    369391            {
    370392                List<String> values = presetsValueData.get(key);
    371                 if( values == null)
    372                 {
    373                     String i = marktr("Key ''{0}'' not in presets.");
    374                     errors.add( new TestError(this, Severity.OTHER, tr("Presets do not contain property key"),
    375                     tr(i, key), MessageFormat.format(i, key), INVALID_VALUE, p) );
    376                     withErrors.add(p, "UPK");
    377                 }
    378                 else if(!values.contains(prop.getValue()))
     393                if(values == null)
     394                {
     395                    Boolean ignore = false;
     396                    for(String a : Main.pref.getCollection(PreferenceEditor.PREFIX + ".startswithkeys",
     397                    Arrays.asList(new String[]{"opengeodb","openGeoDB","name:","note:"})))
     398                    {
     399                        if(key.startsWith(a))
     400                            ignore = true;
     401                    }
     402                    for(String a : Main.pref.getCollection(PreferenceEditor.PREFIX + ".endswithkeys",
     403                    Arrays.asList(new String[]{":forward",":backward",":left",":right"})))
     404                    {
     405                        if(key.endsWith(a))
     406                            ignore = true;
     407                    }
     408                    if(!ignore)
     409                    {
     410                        String i = marktr("Key ''{0}'' not in presets.");
     411                        errors.add( new TestError(this, Severity.OTHER, tr("Presets do not contain property key"),
     412                        tr(i, key), MessageFormat.format(i, key), INVALID_VALUE, p) );
     413                        withErrors.add(p, "UPK");
     414                    }
     415                }
     416                else if(values.size() > 0 && !values.contains(prop.getValue()))
    379417                {
    380418                    String i = marktr("Value ''{0}'' for key ''{1}'' not in presets.");
  • applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/UnconnectedWays.java

    r13598 r14015  
    33import static org.openstreetmap.josm.tools.I18n.tr;
    44
     5import java.awt.geom.Area;
    56import java.awt.geom.Line2D;
    67import java.util.Arrays;
     
    6061    public void endTest()
    6162    {
     63        Area a = Main.ds.getDataSourceArea();
    6264        Map<Node, Way> map = new HashMap<Node, Way>();
    6365        for(Node en : endnodes_highway)
     
    6567            for(MyWaySegment s : ways)
    6668            {
    67                 if(s.highway && s.nearby(en, mindist))
     69                if(s.highway && s.nearby(en, mindist) && (a == null || a.contains(en.coor)))
    6870                    map.put(en, s.w);
    6971            }
     
    8385            for(MyWaySegment s : ways)
    8486            {
    85                 if(!s.highway && s.nearby(en, mindist) && !s.isArea())
     87                if(!s.highway && s.nearby(en, mindist) && !s.isArea() && (a == null || a.contains(en.coor)))
    8688                    map.put(en, s.w);
    8789            }
     
    9193            for(MyWaySegment s : ways)
    9294            {
    93                 if(s.nearby(en, mindist) && !s.isArea())
     95                if(s.nearby(en, mindist) && !s.isArea() && (a == null || a.contains(en.coor)))
    9496                    map.put(en, s.w);
    9597            }
     
    112114                for(MyWaySegment s : ways)
    113115                {
    114                     if(s.nearby(en, minmiddledist))
     116                    if(s.nearby(en, minmiddledist) && (a == null || a.contains(en.coor)))
    115117                        map.put(en, s.w);
    116118                }
     
    130132                for(MyWaySegment s : ways)
    131133                {
    132                     if(s.nearby(en, minmiddledist))
     134                    if(s.nearby(en, minmiddledist) && (a == null || a.contains(en.coor)))
    133135                        map.put(en, s.w);
    134136                }
  • applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/util/Bag.java

    r13497 r14015  
    4848
    4949    /**
     50     * Adds an element to the bag
     51     * @param key The key of the element
     52     * @param value The element to add
     53     */
     54    public void add(K key)
     55    {
     56        List<V> values = get(key);
     57        if( values == null )
     58        {
     59            values = new ArrayList<V>();
     60            put(key, values);
     61        }
     62    }
     63
     64    /**
    5065     * Constructor
    5166     */
Note: See TracChangeset for help on using the changeset viewer.