Ignore:
Timestamp:
2013-02-17T15:01:13+01:00 (11 years ago)
Author:
Don-vip
Message:

fix #4664 - warn when reverting a way with direction defined by tag

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/TagCollection.java

    r5266 r5724  
    2424 * A TagCollection can be created:
    2525 * <ul>
    26  *  <li>from the tags managed by a specific {@link OsmPrimitive} with {@link #from(OsmPrimitive)}</li>
     26 *  <li>from the tags managed by a specific {@link OsmPrimitive} with {@link #from(Tagged)}</li>
    2727 *  <li>from the union of all tags managed by a collection of {@link OsmPrimitive}s with {@link #unionOfAllPrimitives(Collection)}</li>
    2828 *  <li>from the union of all tags managed by a {@link DataSet} with {@link #unionOfAllPrimitives(DataSet)}</li>
     
    5151    public static TagCollection from(Tagged primitive) {
    5252        TagCollection tags = new TagCollection();
    53         for (String key: primitive.keySet()) {
    54             tags.add(new Tag(key, primitive.get(key)));
     53        if (primitive != null) {
     54            for (String key: primitive.keySet()) {
     55                tags.add(new Tag(key, primitive.get(key)));
     56            }
    5557        }
    5658        return tags;
     
    158160
    159161    /**
     162     * Creates a tag collection from <code>tags</code>.
     163     * @param tags the collection of tags
     164     * @since 5724
     165     */
     166    public TagCollection(Collection<Tag> tags) {
     167        add(tags);
     168    }
     169
     170    /**
    160171     * Replies the number of tags in this tag collection
    161172     *
     
    637648     * Does nothing if primitives is null
    638649     *
    639      * @param primitive  the collection of primitives
     650     * @param primitives the collection of primitives
    640651     * @throws IllegalStateException thrown if this tag collection can't be applied
    641652     * because there are keys with multiple values
     
    657668     */
    658669    public TagCollection intersect(TagCollection other) {
    659         if (other == null) {
    660             other = new TagCollection();
    661         }
    662         TagCollection ret = new TagCollection(this);
    663         for (Tag tag: tags) {
    664             if (other.contains(tag)) {
    665                 ret.add(tag);
     670        TagCollection ret = new TagCollection();
     671        if (other != null) {
     672            for (Tag tag: tags) {
     673                if (other.contains(tag)) {
     674                    ret.add(tag);
     675                }
    666676            }
    667677        }
Note: See TracChangeset for help on using the changeset viewer.