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

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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"));
Note: See TracChangeset for help on using the changeset viewer.