Changeset 3784 in josm for trunk


Ignore:
Timestamp:
2011-01-11T00:30:13+01:00 (14 years ago)
Author:
framm
Message:

fix duplicate node test. check introduced in r3871 did not achieve desired result.
introduced new error type "duplicate nodes in two un-closed ways".
never allow merging of nodes if both are part of an un-closed way (e.g. two roads crossing),
but allow merging if at least one way is closed (e.g. landuse/landuse).

File:
1 edited

Legend:

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

    r3781 r3784  
    8585    protected static int DUPLICATE_NODE_MIXED = 2;
    8686    protected static int DUPLICATE_NODE_OTHER = 3;
     87    protected static int DUPLICATE_NODE_UNCLOSED = 4;
    8788    protected static int DUPLICATE_NODE_BUILDING = 10;
    8889    protected static int DUPLICATE_NODE_BOUNDARY = 11;
     
    155156            if (mm.get(tagSet).size() > 1) {
    156157
     158                boolean oneWayClosed = false;
     159
    157160                for (String type: types) {
    158161                    typeMap.put(type, false);
     
    167170                                boolean typed = false;
    168171                                Way w=(Way) sp;
     172                                oneWayClosed = oneWayClosed || w.isClosed();
    169173                                Map<String, String> keys = w.getKeys();
    170174                                for (String type: typeMap.keySet()) {
     
    190194                }
    191195
    192                 if (nbType>1) {
     196                if (!oneWayClosed) {
     197                    String msg = marktr("Duplicate nodes in two un-closed ways");
     198                    errors.add(new TestError(
     199                            parentTest,
     200                            Severity.WARNING,
     201                            tr("Duplicated nodes"),
     202                            tr(msg),
     203                            msg,
     204                            DUPLICATE_NODE_UNCLOSED,
     205                            mm.get(tagSet)
     206                    ));
     207                } else if (nbType>1) {
    193208                    String msg = marktr("Mixed type duplicated nodes");
    194209                    errors.add(new TestError(
     
    384399    @Override
    385400    public boolean isFixable(TestError testError) {
    386         return (testError.getTester() instanceof DuplicateNode && testError.getSeverity() == Severity.ERROR);
     401        if (!(testError.getTester() instanceof DuplicateNode)) return false;
     402        // never merge nodes with different tags.
     403        if (testError.getCode() == DUPLICATE_NODE) return false;
     404        // never merge nodes from two different non-closed geometries
     405        if (testError.getCode() == DUPLICATE_NODE_UNCLOSED) return false;
     406        // everything else is ok to merge
     407        return true;
    387408    }
    388409
Note: See TracChangeset for help on using the changeset viewer.