Changeset 11608 in josm


Ignore:
Timestamp:
2017-02-25T03:14:20+01:00 (5 months ago)
Author:
Don-vip
Message:

fix #14402 - add blacklist for leisure area values to avoid false positives - improve globally the detection of keys/tags

Location:
trunk/src/org/openstreetmap/josm
Files:
27 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/command/ChangePropertyKeyCommand.java

    r11362 r11608  
    9393            return false; // save old
    9494        for (OsmPrimitive osm : objects) {
    95             if (osm.hasKey(key) || osm.hasKey(newKey)) {
     95            String oldValue = osm.get(key);
     96            if (oldValue != null || osm.hasKey(newKey)) {
    9697                osm.setModified(true);
    97                 String oldValue = osm.get(key);
    9898                osm.put(newKey, oldValue);
    9999                osm.remove(key);
  • trunk/src/org/openstreetmap/josm/data/osm/AbstractPrimitive.java

    r11587 r11608  
    706706     * Replies true, if the map of key/value pairs of this primitive is not empty.
    707707     *
    708      * @return true, if the map of key/value pairs of this primitive is not empty; false
    709      *   otherwise
     708     * @return true, if the map of key/value pairs of this primitive is not empty; false otherwise
    710709     */
    711710    @Override
     
    718717     *
    719718     * @param key the key
    720      * @return true, if his primitive has a tag with key <code>key</code>
    721      */
     719     * @return true, if this primitive has a tag with key <code>key</code>
     720     */
     721    @Override
    722722    public boolean hasKey(String key) {
    723723        return key != null && indexOfKey(keys, key) >= 0;
     
    728728     *
    729729     * @param keys the keys
    730      * @return true, if his primitive has a tag with any of the <code>keys</code>
     730     * @return true, if this primitive has a tag with any of the <code>keys</code>
    731731     * @since 11587
    732732     */
     
    758758
    759759    /**
    760      * Tests whether this primitive contains a tag consisting of {@code key} and {@code values}.
     760     * Tests whether this primitive contains a tag consisting of {@code key} and {@code value}.
    761761     * @param key the key forming the tag.
    762762     * @param value value forming the tag.
    763      * @return true iff primitive contains a tag consisting of {@code key} and {@code value}.
     763     * @return true if primitive contains a tag consisting of {@code key} and {@code value}.
    764764     */
    765765    public boolean hasTag(String key, String value) {
     
    781781     * @param key the key forming the tag.
    782782     * @param values one or many values forming the tag.
    783      * @return true iff primitive contains a tag consisting of {@code key} and any of {@code values}.
     783     * @return true if primitive contains a tag consisting of {@code key} and any of {@code values}.
    784784     */
    785785    public boolean hasTag(String key, Collection<String> values) {
    786786        return values.contains(get(key));
    787787    }
     788
     789    /**
     790     * Tests whether this primitive contains a tag consisting of {@code key} and a value different from {@code value}.
     791     * @param key the key forming the tag.
     792     * @param value value not forming the tag.
     793     * @return true if primitive contains a tag consisting of {@code key} and a value different from {@code value}.
     794     * @since 11608
     795     */
     796    public boolean hasTagDifferent(String key, String value) {
     797        String v = get(key);
     798        return v != null && !v.equals(value);
     799    }
     800
     801    /**
     802     * Tests whether this primitive contains a tag consisting of {@code key} and none of {@code values}.
     803     * @param key the key forming the tag.
     804     * @param values one or many values forming the tag.
     805     * @return true if primitive contains a tag consisting of {@code key} and none of {@code values}.
     806     * @since 11608
     807     */
     808    public boolean hasTagDifferent(String key, String... values) {
     809        return hasTagDifferent(key, Arrays.asList(values));
     810    }
     811
     812    /**
     813     * Tests whether this primitive contains a tag consisting of {@code key} and none of {@code values}.
     814     * @param key the key forming the tag.
     815     * @param values one or many values forming the tag.
     816     * @return true if primitive contains a tag consisting of {@code key} and none of {@code values}.
     817     * @since 11608
     818     */
     819    public boolean hasTagDifferent(String key, Collection<String> values) {
     820        String v = get(key);
     821        return v != null && !values.contains(v);
     822    }
    788823}
  • trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java

    r11600 r11608  
    13531353     */
    13541354    public final boolean hasAreaTags() {
    1355         return hasKey("landuse", "amenity", "leisure", "building", "building:part")
    1356                 || "yes".equals(get("area"))
    1357                 || "riverbank".equals(get("waterway"))
     1355        return hasKey("landuse", "amenity", "building", "building:part")
     1356                || hasTag("area", "yes")
     1357                || hasTag("waterway", "riverbank")
     1358                || hasTagDifferent("leisure", "picnic_table", "slipway", "firepit")
    13581359                || hasTag("natural", "water", "wood", "scrub", "wetland", "grassland", "heath", "rock", "bare_rock",
    13591360                                     "sand", "beach", "scree", "bay", "glacier", "shingle", "fell", "reef", "stone",
  • trunk/src/org/openstreetmap/josm/data/osm/Tagged.java

    r10736 r11608  
    44import java.util.Collection;
    55import java.util.Map;
     6
    67/**
    78 * Objects implement Tagged if they provide a map of key/value pairs.
    89 *
    9  *
     10 * @since 2115
    1011 */
    1112// FIXME: better naming? setTags(), getTags(), getKeys() instead of keySet() ?
     
    6768
    6869    /**
     70     * Replies true if there is a tag with key <code>key</code>.
     71     *
     72     * @param key the key
     73     * @return true, if there is a tag with key <code>key</code>
     74     * @since 11608
     75     */
     76    default boolean hasKey(String key) {
     77        return get(key) != null;
     78    }
     79
     80    /**
    6981     * Replies the set of keys
    7082     *
  • trunk/src/org/openstreetmap/josm/data/osm/history/HistoryNode.java

    r8509 r11608  
    1010
    1111/**
    12  * Represents an immutable OSM node in the context of a historical view on
    13  * OSM data.
    14  *
     12 * Represents an immutable OSM node in the context of a historical view on OSM data.
     13 * @since 1670
    1514 */
    1615public class HistoryNode extends HistoryOsmPrimitive {
  • trunk/src/org/openstreetmap/josm/data/osm/history/HistoryOsmPrimitive.java

    r11553 r11608  
    55
    66import java.text.MessageFormat;
     7import java.util.Collection;
    78import java.util.Collections;
    89import java.util.Date;
     
    1920import org.openstreetmap.josm.data.osm.Relation;
    2021import org.openstreetmap.josm.data.osm.SimplePrimitiveId;
     22import org.openstreetmap.josm.data.osm.Tagged;
    2123import org.openstreetmap.josm.data.osm.User;
    2224import org.openstreetmap.josm.data.osm.Way;
     
    2426
    2527/**
    26  * Represents an immutable OSM primitive in the context of a historical view on
    27  * OSM data.
    28  *
     28 * Represents an immutable OSM primitive in the context of a historical view on OSM data.
     29 * @since 1670
    2930 */
    30 public abstract class HistoryOsmPrimitive implements Comparable<HistoryOsmPrimitive> {
     31public abstract class HistoryOsmPrimitive implements Tagged, Comparable<HistoryOsmPrimitive> {
    3132
    3233    private long id;
     
    3839    private long version;
    3940    private Map<String, String> tags;
    40 
    41     protected final void ensurePositiveLong(long value, String name) {
    42         if (value <= 0) {
    43             throw new IllegalArgumentException(MessageFormat.format("Parameter ''{0}'' > 0 expected. Got ''{1}''.", name, value));
    44         }
    45     }
    4641
    4742    /**
     
    119114    }
    120115
     116    /**
     117     * Returns the id.
     118     * @return the id
     119     */
    121120    public long getId() {
    122121        return id;
    123122    }
    124123
     124    /**
     125     * Returns the primitive id.
     126     * @return the primitive id
     127     */
    125128    public PrimitiveId getPrimitiveId() {
    126129        return new SimplePrimitiveId(id, getType());
    127130    }
    128131
     132    /**
     133     * Determines if the primitive is still visible.
     134     * @return {@code true} if the primitive is still visible
     135     */
    129136    public boolean isVisible() {
    130137        return visible;
    131138    }
    132139
     140    /**
     141     * Returns the user.
     142     * @return the user
     143     */
    133144    public User getUser() {
    134145        return user;
    135146    }
    136147
     148    /**
     149     * Returns the changeset id.
     150     * @return the changeset id
     151     */
    137152    public long getChangesetId() {
    138153        return changesetId;
    139154    }
    140155
     156    /**
     157     * Returns the timestamp.
     158     * @return the timestamp
     159     */
    141160    public Date getTimestamp() {
    142161        return timestamp;
    143162    }
    144163
     164    /**
     165     * Returns the version.
     166     * @return the version
     167     */
    145168    public long getVersion() {
    146169        return version;
    147170    }
    148171
     172    protected final void ensurePositiveLong(long value, String name) {
     173        if (value <= 0) {
     174            throw new IllegalArgumentException(MessageFormat.format("Parameter ''{0}'' > 0 expected. Got ''{1}''.", name, value));
     175        }
     176    }
     177
    149178    public boolean matches(long id, long version) {
    150179        return this.id == id && this.version == version;
     
    155184    }
    156185
     186    /**
     187     * Returns the primitive type.
     188     * @return the primitive type
     189     */
    157190    public abstract OsmPrimitiveType getType();
    158191
     
    164197    }
    165198
    166     public void put(String key, String value) {
     199    @Override
     200    public final void put(String key, String value) {
    167201        tags.put(key, value);
    168202    }
    169203
    170     public String get(String key) {
     204    @Override
     205    public final String get(String key) {
    171206        return tags.get(key);
    172207    }
    173208
    174     public boolean hasTag(String key) {
    175         return tags.get(key) != null;
    176     }
    177 
     209    @Override
     210    public final boolean hasKey(String key) {
     211        return tags.containsKey(key);
     212    }
     213
     214    @Override
     215    public final Map<String, String> getKeys() {
     216        return getTags();
     217    }
     218
     219    @Override
     220    public final void setKeys(Map<String, String> keys) {
     221        throw new UnsupportedOperationException();
     222    }
     223
     224    @Override
     225    public final void remove(String key) {
     226        throw new UnsupportedOperationException();
     227    }
     228
     229    @Override
     230    public final void removeAll() {
     231        throw new UnsupportedOperationException();
     232    }
     233
     234    @Override
     235    public final boolean hasKeys() {
     236        return !tags.isEmpty();
     237    }
     238
     239    @Override
     240    public final Collection<String> keySet() {
     241        return Collections.unmodifiableSet(tags.keySet());
     242    }
     243
     244    /**
     245     * Replies the key/value map.
     246     * @return the key/value map
     247     */
    178248    public Map<String, String> getTags() {
    179249        return Collections.unmodifiableMap(tags);
     
    272342    public String toString() {
    273343        return getClass().getSimpleName() + " [version=" + version + ", id=" + id + ", visible=" + visible + ", "
    274                 + (timestamp != null ? "timestamp=" + timestamp : "") + ", "
    275                 + (user != null ? "user=" + user + ", " : "") + "changesetId="
     344                + (timestamp != null ? ("timestamp=" + timestamp) : "") + ", "
     345                + (user != null ? ("user=" + user + ", ") : "") + "changesetId="
    276346                + changesetId
    277347                + ']';
  • trunk/src/org/openstreetmap/josm/data/osm/history/HistoryRelation.java

    r10632 r11608  
    1515
    1616/**
    17  * Represents an immutable OSM relation in the context of a historical view on
    18  * OSM data.
    19  *
     17 * Represents an immutable OSM relation in the context of a historical view on OSM data.
     18 * @since 1670
    2019 */
    2120public class HistoryRelation extends HistoryOsmPrimitive {
  • trunk/src/org/openstreetmap/josm/data/osm/history/HistoryWay.java

    r10662 r11608  
    1515
    1616/**
    17  * Represents an immutable OSM way in the context of a historical view on
    18  * OSM data.
    19  *
     17 * Represents an immutable OSM way in the context of a historical view on OSM data.
     18 * @since 1670
    2019 */
    2120public class HistoryWay extends HistoryOsmPrimitive {
  • trunk/src/org/openstreetmap/josm/data/validation/Test.java

    r11553 r11608  
    342342     */
    343343    protected static final boolean isBuilding(OsmPrimitive p) {
    344         String v = p.get("building");
    345         return v != null && !"no".equals(v) && !"entrance".equals(v);
     344        return p.hasTagDifferent("building", "no", "entrance");
    346345    }
    347346
     
    357356        Test test = (Test) obj;
    358357        return Objects.equals(name, test.name) &&
    359                 Objects.equals(description, test.description);
     358               Objects.equals(description, test.description);
    360359    }
    361360}
  • trunk/src/org/openstreetmap/josm/data/validation/tests/Addresses.java

    r11339 r11608  
    6363            // warning level only if several relations have different names, see #10945
    6464            final String name = list.get(0).get("name");
    65             if (name == null || SubclassFilteredCollection.filter(list, r -> name.equals(r.get("name"))).size() < list.size()) {
     65            if (name == null || SubclassFilteredCollection.filter(list, r -> r.hasTag("name", name)).size() < list.size()) {
    6666                level = Severity.WARNING;
    6767            } else {
     
    147147                        street.add((Way) p);
    148148                    }
    149                     if (relationName != null && p.hasKey("name") && !relationName.equals(p.get("name"))) {
     149                    if (relationName != null && p.hasTagDifferent("name", relationName)) {
    150150                        if (wrongStreetNames.isEmpty()) {
    151151                            wrongStreetNames.add(r);
  • trunk/src/org/openstreetmap/josm/data/validation/tests/Coastlines.java

    r11129 r11608  
    251251
    252252    private static boolean isCoastline(OsmPrimitive osm) {
    253         return osm instanceof Way && "coastline".equals(osm.get("natural"));
     253        return osm instanceof Way && osm.hasTag("natural", "coastline");
    254254    }
    255255
  • trunk/src/org/openstreetmap/josm/data/validation/tests/CrossingWays.java

    r11587 r11608  
    241241
    242242    static boolean isHighway(OsmPrimitive w) {
    243         return w.hasKey(HIGHWAY) && !w.hasTag(HIGHWAY, "rest_area", "services");
     243        return w.hasTagDifferent(HIGHWAY, "rest_area", "services");
    244244    }
    245245
  • trunk/src/org/openstreetmap/josm/data/validation/tests/Highways.java

    r11129 r11608  
    9292    public void visit(Way w) {
    9393        if (w.isUsable()) {
    94             if (w.isClosed() && w.hasKey("highway") && CLASSIFIED_HIGHWAYS.contains(w.get("highway"))
    95                     && w.hasKey("junction") && "roundabout".equals(w.get("junction"))) {
     94            if (w.isClosed() && w.hasTag("highway", CLASSIFIED_HIGHWAYS) && w.hasTag("junction", "roundabout")) {
    9695                // TODO: find out how to handle splitted roundabouts (see #12841)
    9796                testWrongRoundabout(w);
     
    131130                if (list.size() > 2 || oneway1 == null || oneway2 == null || !oneway1 || !oneway2) {
    132131                    // Error when the highway tags do not match
    133                     if (!w.get("highway").equals(s)) {
     132                    String value = w.get("highway");
     133                    if (!value.equals(s)) {
    134134                        errors.add(TestError.builder(this, Severity.WARNING, WRONG_ROUNDABOUT_HIGHWAY)
    135                                 .message(tr("Incorrect roundabout (highway: {0} instead of {1})", w.get("highway"), s))
     135                                .message(tr("Incorrect roundabout (highway: {0} instead of {1})", value, s))
    136136                                .primitives(w)
    137137                                .fix(() -> new ChangePropertyCommand(w, "highway", s))
  • trunk/src/org/openstreetmap/josm/data/validation/tests/LongSegment.java

    r11129 r11608  
    3535    @Override
    3636    public void visit(Way w) {
    37         if ("ferry".equals(w.get("route"))) {
     37        if (w.hasTag("route", "ferry")) {
    3838            return;
    3939        }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/MultipolygonTest.java

    r11590 r11608  
    175175    private void checkStyleConsistency(Relation r, Multipolygon polygon) {
    176176        ElemStyles styles = MapPaintStyles.getStyles();
    177         if (styles != null && !"boundary".equals(r.get("type"))) {
     177        if (styles != null && !r.hasTag("type", "boundary")) {
    178178            AreaElement area = ElemStyles.getAreaElemStyle(r, false);
    179179            boolean areaStyle = area != null;
  • trunk/src/org/openstreetmap/josm/data/validation/tests/OverlappingWays.java

    r11129 r11608  
    9090
    9191                for (WaySegment ws : duplicated) {
    92                     if (ws.way.get("highway") != null) {
     92                    if (ws.way.hasKey("highway")) {
    9393                        highway++;
    94                     } else if (ws.way.get("railway") != null) {
     94                    } else if (ws.way.hasKey("railway")) {
    9595                        railway++;
    9696                    }
     
    107107                    currentWays.add(ws.way);
    108108                }
    109                 /* These ways not seen before
    110                  * If two or more of the overlapping ways are
    111                  * highways or railways mark a separate error
    112                  */
     109                // These ways not seen before
     110                // If two or more of the overlapping ways are highways or railways mark a separate error
    113111                if ((highlight = seenWays.get(currentWays)) == null) {
    114112                    String errortype;
  • trunk/src/org/openstreetmap/josm/data/validation/tests/PowerLines.java

    r11432 r11608  
    165165     */
    166166    private static boolean isPowerIn(OsmPrimitive p, Collection<String> values) {
    167         String v = p.get("power");
    168         return v != null && values != null && values.contains(v);
     167        return p.hasTag("power", values);
    169168    }
    170169
     
    176175     */
    177176    private static boolean isBuildingIn(OsmPrimitive p, Collection<String> values) {
    178         String v = p.get("building");
    179         return v != null && values != null && values.contains(v);
     177        return p.hasTag("building", values);
    180178    }
    181179}
  • trunk/src/org/openstreetmap/josm/data/validation/tests/TurnrestrictionTest.java

    r11129 r11608  
    4848    @Override
    4949    public void visit(Relation r) {
    50         if (!"restriction".equals(r.get("type")))
     50        if (!r.hasTag("type", "restriction"))
    5151            return;
    5252
     
    224224
    225225    private static boolean isFullOneway(Way w) {
    226         return w.isOneway() != 0 && !"no".equals(w.get("oneway:bicycle"));
     226        return w.isOneway() != 0 && !w.hasTag("oneway:bicycle", "no");
    227227    }
    228228
  • trunk/src/org/openstreetmap/josm/data/validation/tests/UnconnectedWays.java

    r11587 r11608  
    306306            this.isAbandoned = "abandoned".equals(railway) || w.isKeyTrue("disused");
    307307            this.highway = (highway != null || railway != null) && !isAbandoned;
    308             this.isBoundary = !this.highway && "administrative".equals(w.get("boundary"));
     308            this.isBoundary = !this.highway && w.hasTag("boundary", "administrative");
    309309            line = new Line2D.Double(n1.getEastNorth().east(), n1.getEastNorth().north(),
    310310                    n2.getEastNorth().east(), n2.getEastNorth().north());
  • trunk/src/org/openstreetmap/josm/gui/DefaultNameFormatter.java

    r10991 r11608  
    169169                }
    170170                if (n == null) {
    171                     String s;
    172                     if ((s = node.get("addr:housename")) != null) {
     171                    String s = node.get("addr:housename");
     172                    if (s != null) {
    173173                        /* I18n: name of house as parameter */
    174174                        n = tr("House {0}", s);
     
    250250                }
    251251                if (n == null) {
    252                     n = (way.get("highway") != null) ? tr("highway") :
    253                             (way.get("railway") != null) ? tr("railway") :
    254                                 (way.get("waterway") != null) ? tr("waterway") :
    255                                         (way.get("landuse") != null) ? tr("landuse") : null;
     252                    n = way.hasKey("highway") ? tr("highway") :
     253                        way.hasKey("railway") ? tr("railway") :
     254                        way.hasKey("waterway") ? tr("waterway") :
     255                        way.hasKey("landuse") ? tr("landuse") : null;
    256256                }
    257257                if (n == null) {
    258                     String s;
    259                     if ((s = way.get("addr:housename")) != null) {
     258                    String s = way.get("addr:housename");
     259                    if (s != null) {
    260260                        /* I18n: name of house as parameter */
    261261                        n = tr("House {0}", s);
     
    273273                    }
    274274                }
    275                 if (n == null && way.get("building") != null) n = tr("building");
     275                if (n == null && way.hasKey("building")) {
     276                    n = tr("building");
     277                }
    276278                if (n == null || n.isEmpty()) {
    277279                    n = String.valueOf(way.getId());
     
    407409        String name = trc("Relation type", relation.get("type"));
    408410        if (name == null) {
    409             name = (relation.get("public_transport") != null) ? tr("public transport") : null;
     411            name = relation.hasKey("public_transport") ? tr("public transport") : null;
    410412        }
    411413        if (name == null) {
     
    573575        if (sb.length() == 0) {
    574576            sb.append(
    575                     (way.get("highway") != null) ? tr("highway") :
    576                         (way.get("railway") != null) ? tr("railway") :
    577                             (way.get("waterway") != null) ? tr("waterway") :
    578                                 (way.get("landuse") != null) ? tr("landuse") : ""
     577                    way.hasKey("highway") ? tr("highway") :
     578                    way.hasKey("railway") ? tr("railway") :
     579                    way.hasKey("waterway") ? tr("waterway") :
     580                    way.hasKey("landuse") ? tr("landuse") : ""
    579581                    );
    580582        }
    581583
    582         int nodesNo = way.isClosed() ? way.getNumNodes() -1 : way.getNumNodes();
     584        int nodesNo = way.isClosed() ? (way.getNumNodes() -1) : way.getNumNodes();
    583585        String nodes = trn("{0} node", "{0} nodes", nodesNo, nodesNo);
    584586        if (sb.length() == 0) {
     
    587589        /* note: length == 0 should no longer happen, but leave the bracket code
    588590           nevertheless, who knows what future brings */
    589         sb.append((sb.length() > 0) ? " ("+nodes+')' : nodes);
     591        sb.append((sb.length() > 0) ? (" ("+nodes+')') : nodes);
    590592        decorateNameWithId(sb, way);
    591593        return sb.toString();
     
    595597    public String format(HistoryRelation relation) {
    596598        StringBuilder sb = new StringBuilder();
    597         if (relation.get("type") != null) {
    598             sb.append(relation.get("type"));
     599        String type = relation.get("type");
     600        if (type != null) {
     601            sb.append(type);
    599602        } else {
    600603            sb.append(tr("relation"));
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/sort/RelationSortUtils.java

    r11587 r11608  
    2929
    3030    static Direction roundaboutType(Way w) {
    31         if (w != null && "roundabout".equals(w.get("junction"))) {
     31        if (w != null && w.hasTag("junction", "roundabout")) {
    3232            int nodesCount = w.getNodesCount();
    3333            if (nodesCount > 2 && nodesCount < 200) {
     
    3636                Node n3 = w.getNode(2);
    3737                if (n1 != null && n2 != null && n3 != null && w.isClosed()) {
    38                     /** do some simple determinant / cross pruduct test on the first 3 nodes
     38                    /** do some simple determinant / cross product test on the first 3 nodes
    3939                        to see, if the roundabout goes clock wise or ccw */
    4040                    EastNorth en1 = n1.getEastNorth();
  • trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserModel.java

    r11553 r11608  
    605605        public boolean hasTag(String key) {
    606606            HistoryOsmPrimitive primitive = getPointInTime(pointInTimeType);
    607             if (primitive == null)
    608                 return false;
    609             return primitive.hasTag(key);
     607            return primitive != null && primitive.hasKey(key);
    610608        }
    611609
     
    620618            PointInTimeType opposite = pointInTimeType.opposite();
    621619            HistoryOsmPrimitive primitive = getPointInTime(opposite);
    622             if (primitive == null)
    623                 return false;
    624             return primitive.hasTag(key);
     620            return primitive != null && primitive.hasKey(key);
    625621        }
    626622
     
    636632            String value = getValue(key);
    637633            String oppositeValue = getOppositeValue(key);
    638             if (value == null || oppositeValue == null)
    639                 return false;
    640             return value.equals(oppositeValue);
     634            return value != null && value.equals(oppositeValue);
    641635        }
    642636
  • trunk/src/org/openstreetmap/josm/gui/io/ChangesetCellRenderer.java

    r10242 r11608  
    4040                    DateUtils.formatDateTime(cs.getCreatedAt(), DateFormat.SHORT, DateFormat.SHORT)).append("<br>");
    4141        }
    42         if (cs.get("comment") != null) {
    43             sb.append("<strong>").append(tr("Changeset comment:")).append("</strong>").append(cs.get("comment")).append("<br>");
     42        String comment = cs.get("comment");
     43        if (comment != null) {
     44            sb.append("<strong>").append(tr("Changeset comment:")).append("</strong>").append(comment).append("<br>");
    4445        }
    4546        return sb.toString();
     
    5960            setIcon(icon);
    6061            StringBuilder sb = new StringBuilder();
    61             if (cs.get("comment") != null) {
    62                 sb.append(cs.getId()).append(" - ").append(cs.get("comment"));
     62            String comment = cs.get("comment");
     63            if (comment != null) {
     64                sb.append(cs.getId()).append(" - ").append(comment);
    6365            } else if (cs.get("name") != null) {
    6466                sb.append(cs.getId()).append(" - ").append(cs.get("name"));
  • trunk/src/org/openstreetmap/josm/gui/io/UploadParameterSummaryPanel.java

    r9996 r11608  
    88import java.beans.PropertyChangeEvent;
    99import java.beans.PropertyChangeListener;
     10import java.util.Optional;
    1011
    1112import javax.swing.BorderFactory;
     
    4546            msg.append(tr("Objects are uploaded to a <strong>new changeset</strong>."));
    4647        } else {
    47             String uploadComment = selectedChangeset.get("comment") == null ?
    48                     "" : selectedChangeset.get("comment");
    4948            msg.append(tr("Objects are uploaded to the <strong>open changeset</strong> {0} with upload comment ''{1}''.",
    5049                    selectedChangeset.getId(),
    51                     uploadComment
     50                    Optional.ofNullable(selectedChangeset.get("comment")).orElse("")
    5251            ));
    5352        }
  • trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java

    r11366 r11608  
    665665            Map<String, Object> trkAttr = new HashMap<>();
    666666
    667             if (w.get("name") != null) {
    668                 trkAttr.put("name", w.get("name"));
     667            String name = w.get("name");
     668            if (name != null) {
     669                trkAttr.put("name", name);
    669670            }
    670671
  • trunk/src/org/openstreetmap/josm/gui/layer/gpx/ChooseTrackVisibilityAction.java

    r11457 r11608  
    1717import java.util.Comparator;
    1818import java.util.Map;
     19import java.util.Optional;
    1920
    2021import javax.swing.AbstractAction;
     
    111112        for (GpxTrack trk : layer.data.tracks) {
    112113            Map<String, Object> attr = trk.getAttributes();
    113             String name = (String) (attr.containsKey(GpxConstants.GPX_NAME) ? attr.get(GpxConstants.GPX_NAME) : "");
    114             String desc = (String) (attr.containsKey(GpxConstants.GPX_DESC) ? attr.get(GpxConstants.GPX_DESC) : "");
     114            String name = (String) Optional.ofNullable(attr.get(GpxConstants.GPX_NAME)).orElse("");
     115            String desc = (String) Optional.ofNullable(attr.get(GpxConstants.GPX_DESC)).orElse("");
    115116            String time = GpxLayer.getTimespanForTrack(trk);
    116117            TrackLength length = new TrackLength(trk.length());
    117             String url = (String) (attr.containsKey("url") ? attr.get("url") : "");
     118            String url = (String) Optional.ofNullable(attr.get("url")).orElse("");
    118119            tracks[i] = new Object[]{name, desc, time, length, url};
    119120            i++;
  • trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyles.java

    r11493 r11608  
    388388                    addIfNotNull(sl, LineElement.createCasing(env));
    389389                    addIfNotNull(sl, LineTextElement.create(env));
    390                 } else if ("restriction".equals(osm.get("type"))) {
     390                } else if (osm.hasTag("type", "restriction")) {
    391391                    addIfNotNull(sl, NodeElement.create(env));
    392392                }
Note: See TracChangeset for help on using the changeset viewer.