Changeset 15691 in josm for trunk/src


Ignore:
Timestamp:
2020-01-12T14:54:20+01:00 (5 years ago)
Author:
GerdP
Message:

fix #18544: Don't warn crossing administrative and protected_area boundaries

  • exclude boundary=protected_area crossings
  • check also complete members of incomplete relations
  • if segments are crossing: collect boundary tags of all parent relations and complain if any match is found
File:
1 edited

Legend:

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

    r15515 r15691  
    88import java.util.Arrays;
    99import java.util.HashMap;
     10import java.util.HashSet;
    1011import java.util.List;
    1112import java.util.Map;
    1213import java.util.Objects;
     14import java.util.Set;
    1315
    1416import org.openstreetmap.josm.data.coor.EastNorth;
     
    214216        @Override
    215217        public boolean isPrimitiveUsable(OsmPrimitive p) {
    216             return super.isPrimitiveUsable(p) && p.hasKey("boundary")
    217                     && (!(p instanceof Relation) || (((Relation) p).isMultipolygon() && !((Relation) p).hasIncompleteMembers()));
     218            return super.isPrimitiveUsable(p) && p.hasKey("boundary") && !p.hasTag("boundary", "protected_area")
     219                    && (!(p instanceof Relation) || (((Relation) p).isMultipolygon()));
    218220        }
    219221
    220222        @Override
    221223        boolean ignoreWaySegmentCombination(Way w1, Way w2) {
    222             return !Objects.equals(w1.get("boundary"), w2.get("boundary"));
     224            // ignore ways which have no common boundary tag value
     225            Set<String> s1 = getBoundaryTags(w1);
     226            Set<String> s2 = getBoundaryTags(w2);
     227            for (String type : s1) {
     228                if (s2.contains(type))
     229                    return false;
     230            }
     231            return true;
     232        }
     233
     234        /**
     235         * Collect all boundary tag values of the way and its parent relations
     236         * @param w the way to check
     237         * @return set with the found boundary tag values
     238         */
     239        private static Set<String> getBoundaryTags(Way w) {
     240            final Set<String> types = new HashSet<>();
     241            String type = w.get("boundary");
     242            if (type != null)
     243                types.add(type);
     244            w.referrers(Relation.class).filter(Relation::isMultipolygon).map(r -> r.get("boundary"))
     245                    .filter(Objects::nonNull).forEach(types::add);
     246            types.remove("protected_area");
     247            return types;
    223248        }
    224249
     
    226251        public void visit(Relation r) {
    227252            for (Way w : r.getMemberPrimitives(Way.class)) {
    228                 visit(w);
     253                if (!w.isIncomplete())
     254                    visit(w);
    229255            }
    230256        }
Note: See TracChangeset for help on using the changeset viewer.