Changeset 6629 in josm


Ignore:
Timestamp:
2014-01-05T12:03:37+01:00 (11 years ago)
Author:
simon04
Message:

Replace NodesDuplicatingWayTags test by a corresponding MapCSS test

Location:
trunk
Files:
1 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/data/validator/unnecessary.mapcss

    r6548 r6629  
    1616  assertNoMatch: "way emergency=designated";
    1717}
     18
     19/* see ticket #7639 -- Warn when a node has the same tags as its parent way. */
     20way >:sameTags node:tagged {
     21  throwWarning: tr("Nodes duplicating parent way tags");
     22}
  • trunk/src/org/openstreetmap/josm/data/osm/AbstractPrimitive.java

    r6610 r6629  
    671671
    672672    /**
    673      * Replies true if other isn't null and has the same tags (key/value-pairs) as this.
    674      *
    675      * @param other the other object primitive
    676      * @return true if other isn't null and has the same tags (key/value-pairs) as this.
    677      */
    678     public boolean hasSameTags(OsmPrimitive other) {
    679         // We cannot directly use Arrays.equals(keys, other.keys) as keys is not ordered by key
    680         // but we can at least check if both arrays are null or of the same size before creating
    681         // and comparing the key maps (costly operation, see #7159)
    682         return (keys == null && other.keys == null)
    683             || (keys != null && other.keys != null && keys.length == other.keys.length && (keys.length == 0 || getKeys().equals(other.getKeys())));
    684     }
    685 
    686     /**
    687673     * What to do, when the tags have changed by one of the tag-changing methods.
    688674     */
  • trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java

    r6491 r6629  
    1010import java.util.Collections;
    1111import java.util.Date;
     12import java.util.HashMap;
    1213import java.util.HashSet;
    1314import java.util.LinkedHashSet;
     
    726727    }
    727728
     729    /**
     730     * Returns {@link #getKeys()} for which {@code key} does not fulfill {@link #isUninterestingKey}.
     731     */
     732    public Map<String, String> getInterestingTags() {
     733        Map<String, String> result = new HashMap<String, String>();
     734        String[] keys = this.keys;
     735        if (keys != null) {
     736            for (int i = 0; i < keys.length; i += 2) {
     737                if (!isUninterestingKey(keys[i])) {
     738                    result.put(keys[i], keys[i + 1]);
     739                }
     740            }
     741        }
     742        return result;
     743    }
     744
    728745    private static volatile Match directionKeys = null;
    729746    private static volatile Match reversedDirectionKeys = null;
     
    11151132
    11161133    /**
     1134     * Replies true if other isn't null and has the same interesting tags (key/value-pairs) as this.
     1135     *
     1136     * @param other the other object primitive
     1137     * @return true if other isn't null and has the same interesting tags (key/value-pairs) as this.
     1138     */
     1139    public boolean hasSameInterestingTags(OsmPrimitive other) {
     1140        // We cannot directly use Arrays.equals(keys, other.keys) as keys is not ordered by key
     1141        // but we can at least check if both arrays are null or of the same size before creating
     1142        // and comparing the key maps (costly operation, see #7159)
     1143        return (keys == null && other.keys == null)
     1144                || (keys != null && other.keys != null && keys.length == other.keys.length
     1145                        && (keys.length == 0 || getInterestingTags().equals(other.getInterestingTags())));
     1146    }
     1147
     1148    /**
    11171149     * Replies true if this primitive and other are equal with respect to their
    11181150     * semantic attributes.
     
    11331165        // can't do an equals check on the internal keys array because it is not ordered
    11341166        //
    1135         return hasSameTags(other);
     1167        return hasSameInterestingTags(other);
    11361168    }
    11371169
  • trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java

    r6613 r6629  
    3636import org.openstreetmap.josm.data.validation.tests.MultipolygonTest;
    3737import org.openstreetmap.josm.data.validation.tests.NameMismatch;
    38 import org.openstreetmap.josm.data.validation.tests.NodesDuplicatingWayTags;
    3938import org.openstreetmap.josm.data.validation.tests.OpeningHourTest;
    4039import org.openstreetmap.josm.data.validation.tests.OverlappingWays;
     
    110109        DuplicateRelation.class, // ID 1901 .. 1999
    111110        WayConnectedToArea.class, // ID 2301 .. 2399
    112         NodesDuplicatingWayTags.class, // ID 2401 .. 2499
    113111        PowerLines.class, // ID 2501 .. 2599
    114112        Addresses.class, // ID 2601 .. 2699
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Condition.java

    r6611 r6629  
    99
    1010import org.openstreetmap.josm.data.osm.Node;
    11 import org.openstreetmap.josm.data.osm.OsmUtils;
    1211import org.openstreetmap.josm.data.osm.Relation;
    1312import org.openstreetmap.josm.data.osm.Tag;
     
    1514import org.openstreetmap.josm.gui.mappaint.Cascade;
    1615import org.openstreetmap.josm.gui.mappaint.Environment;
     16import org.openstreetmap.josm.tools.CheckParameterUtil;
    1717import org.openstreetmap.josm.tools.Predicates;
    1818import org.openstreetmap.josm.tools.Utils;
     
    5858
    5959    public static Condition createPseudoClassCondition(String id, boolean not, Context context) {
    60         return new PseudoClassCondition(id, not);
     60        return new PseudoClassCondition(id, not, context);
    6161    }
    6262
     
    305305        public final boolean not;
    306306
    307         public PseudoClassCondition(String id, boolean not) {
     307        public PseudoClassCondition(String id, boolean not, Context context) {
    308308            this.id = id;
    309309            this.not = not;
     310            CheckParameterUtil.ensureThat(!"sameTags".equals(id) || Context.LINK.equals(context), "sameTags only supported in LINK context");
    310311        }
    311312
     
    322323                    return true;
    323324                return false;
    324             } else if (equal(id, "modified"))
     325            } else if (equal(id, "modified")) {
    325326                return e.osm.isModified() || e.osm.isNewOrUndeleted();
    326             else if (equal(id, "new"))
     327            } else if (equal(id, "new")) {
    327328                return e.osm.isNew();
    328             else if (equal(id, "connection") && (e.osm instanceof Node))
     329            } else if (equal(id, "connection") && (e.osm instanceof Node)) {
    329330                return ((Node) e.osm).isConnectionNode();
    330             else if (equal(id, "tagged"))
     331            } else if (equal(id, "tagged")) {
    331332                return e.osm.isTagged();
     333            } else if ("sameTags".equals(id)) {
     334                return e.osm.hasSameInterestingTags(Utils.firstNonNull(e.child, e.parent));
     335            }
    332336            return true;
    333337        }
Note: See TracChangeset for help on using the changeset viewer.