Changeset 21539 in osm for applications/editors


Ignore:
Timestamp:
2010-06-01T09:11:37+02:00 (14 years ago)
Author:
stoecker
Message:

added relation checker based on new tagging code

Location:
applications/editors/josm/plugins/validator
Files:
1 added
3 edited

Legend:

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

    r20799 r21539  
    2727        -->
    2828        <property name="commit.message" value="don't break relations, when fixing duplicate ways" />
    29         <property name="plugin.main.version" value="3118" />
     29        <property name="plugin.main.version" value="3289" />
    3030
    3131
  • applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/OSMValidatorPlugin.java

    r20828 r21539  
    4444import org.openstreetmap.josm.plugins.validator.tests.NodesWithSameName;
    4545import org.openstreetmap.josm.plugins.validator.tests.OverlappingWays;
     46import org.openstreetmap.josm.plugins.validator.tests.RelationChecker;
    4647import org.openstreetmap.josm.plugins.validator.tests.SelfIntersectingWay;
    4748import org.openstreetmap.josm.plugins.validator.tests.SimilarNamedWays;
     
    8384     */
    8485    @SuppressWarnings("unchecked")
    85     public static Class<Test>[] allAvailableTests = new Class[] { DuplicateNode.class, // ID    1 ..   99
     86    public static Class<Test>[] allAvailableTests = new Class[] {
     87            DuplicateNode.class, // ID    1 ..   99
    8688            OverlappingWays.class, // ID  101 ..  199
    8789            UntaggedNode.class, // ID  201 ..  299
     
    100102            NameMismatch.class, // ID  1501 ..  1599
    101103            MultipolygonTest.class, // ID  1601 ..  1699
     104            RelationChecker.class, // ID  1701 ..  1799
    102105    };
    103106
  • applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/ValidateAction.java

    r20828 r21539  
    106106
    107107    class ValidationTask extends PleaseWaitRunnable {
    108         private Collection<Test> tests;
    109         private Collection<OsmPrimitive> validatedPrimitmives;
    110         private Collection<OsmPrimitive> formerValidatedPrimitives;
    111         private boolean canceled;
     108        private Collection<Test> tests;
     109        private Collection<OsmPrimitive> validatedPrimitmives;
     110        private Collection<OsmPrimitive> formerValidatedPrimitives;
     111        private boolean canceled;
    112112        private List<TestError> errors;
    113113
     
    118118         * @param formerValidatedPrimitives the last collection of primitives being validates. May be null.
    119119         */
    120         public ValidationTask(Collection<Test> tests, Collection<OsmPrimitive> validatedPrimitives, Collection<OsmPrimitive> formerValidatedPrimitives) {
    121                 super(tr("Validating"), false /*don't ignore exceptions */);
    122                 this.validatedPrimitmives  = validatedPrimitives;
    123                 this.formerValidatedPrimitives = formerValidatedPrimitives;
    124                 this.tests = tests;
    125         }
     120        public ValidationTask(Collection<Test> tests, Collection<OsmPrimitive> validatedPrimitives, Collection<OsmPrimitive> formerValidatedPrimitives) {
     121            super(tr("Validating"), false /*don't ignore exceptions */);
     122            this.validatedPrimitmives  = validatedPrimitives;
     123            this.formerValidatedPrimitives = formerValidatedPrimitives;
     124            this.tests = tests;
     125        }
    126126
    127                 @Override
    128                 protected void cancel() {
    129                         this.canceled = true;
    130                 }
     127        @Override
     128        protected void cancel() {
     129            this.canceled = true;
     130        }
    131131
    132                 @Override
    133                 protected void finish() {
    134                         if (canceled) return;
     132        @Override
     133        protected void finish() {
     134            if (canceled) return;
    135135
    136                         // update GUI on Swing EDT
    137                         //
    138                         Runnable r = new Runnable()  {
    139                                 public void run() {
    140                                 plugin.validationDialog.tree.setErrors(errors);
    141                                 plugin.validationDialog.setVisible(true);
    142                                 Main.main.getCurrentDataSet().fireSelectionChanged();
    143                                 }
    144                         };
    145                         if (SwingUtilities.isEventDispatchThread()) {
    146                                 r.run();
    147                         } else {
    148                                 SwingUtilities.invokeLater(r);
    149                         }
    150                 }
     136            // update GUI on Swing EDT
     137            //
     138            Runnable r = new Runnable()  {
     139                public void run() {
     140                    plugin.validationDialog.tree.setErrors(errors);
     141                    plugin.validationDialog.setVisible(true);
     142                    Main.main.getCurrentDataSet().fireSelectionChanged();
     143                }
     144            };
     145            if (SwingUtilities.isEventDispatchThread()) {
     146                r.run();
     147            } else {
     148                SwingUtilities.invokeLater(r);
     149            }
     150        }
    151151
    152                 @Override
    153                 protected void realRun() throws SAXException, IOException,
    154                                 OsmTransferException {
    155                         if (tests == null || tests.isEmpty()) return;
    156                 errors = new ArrayList<TestError>(200);
    157                 getProgressMonitor().setTicksCount(tests.size() * validatedPrimitmives.size());
    158                 int testCounter = 0;
    159                         for (Test test : tests) {
    160                                 if (canceled) return;
    161                                 testCounter++;
    162                                 getProgressMonitor().setCustomText(tr("Test {0}/{1}: Starting {2}", testCounter, tests.size(),test.name));
    163                     test.setPartialSelection(formerValidatedPrimitives != null);
    164                     test.startTest(getProgressMonitor().createSubTaskMonitor(validatedPrimitmives.size(), false));
    165                     test.visit(validatedPrimitmives);
    166                     test.endTest();
    167                     errors.addAll(test.getErrors());
    168                 }
    169                         tests = null;
    170                 if (Main.pref.getBoolean(PreferenceEditor.PREF_USE_IGNORE, true)) {
    171                                 getProgressMonitor().subTask(tr("Updating ignored errors ..."));
    172                     for (TestError error : errors) {
    173                         if (canceled) return;
    174                         List<String> s = new ArrayList<String>();
    175                         s.add(error.getIgnoreState());
    176                         s.add(error.getIgnoreGroup());
    177                         s.add(error.getIgnoreSubGroup());
    178                         for (String state : s) {
    179                             if (state != null && plugin.ignoredErrors.contains(state)) {
    180                                 error.setIgnored(true);
    181                             }
    182                         }
    183                     }
    184                 }
    185                 }
     152        @Override
     153        protected void realRun() throws SAXException, IOException,
     154                OsmTransferException {
     155            if (tests == null || tests.isEmpty()) return;
     156            errors = new ArrayList<TestError>(200);
     157            getProgressMonitor().setTicksCount(tests.size() * validatedPrimitmives.size());
     158            int testCounter = 0;
     159            for (Test test : tests) {
     160                if (canceled) return;
     161                testCounter++;
     162                getProgressMonitor().setCustomText(tr("Test {0}/{1}: Starting {2}", testCounter, tests.size(),test.name));
     163                test.setPartialSelection(formerValidatedPrimitives != null);
     164                test.startTest(getProgressMonitor().createSubTaskMonitor(validatedPrimitmives.size(), false));
     165                test.visit(validatedPrimitmives);
     166                test.endTest();
     167                errors.addAll(test.getErrors());
     168            }
     169            tests = null;
     170            if (Main.pref.getBoolean(PreferenceEditor.PREF_USE_IGNORE, true)) {
     171                getProgressMonitor().subTask(tr("Updating ignored errors ..."));
     172                for (TestError error : errors) {
     173                    if (canceled) return;
     174                    List<String> s = new ArrayList<String>();
     175                    s.add(error.getIgnoreState());
     176                    s.add(error.getIgnoreGroup());
     177                    s.add(error.getIgnoreSubGroup());
     178                    for (String state : s) {
     179                        if (state != null && plugin.ignoredErrors.contains(state)) {
     180                            error.setIgnored(true);
     181                        }
     182                    }
     183                }
     184            }
     185        }
    186186    }
    187187}
Note: See TracChangeset for help on using the changeset viewer.