Ticket #2302: tagged.2.patch

File tagged.2.patch, 14.1 KB (added by jttt, 11 years ago)
  • src/org/openstreetmap/josm/actions/SplitWayAction.java

     
    253253            Way wayToAdd = new Way();
    254254            if (selectedWay.keys != null) {
    255255                wayToAdd.keys = new HashMap<String, String>(selectedWay.keys);
    256                 wayToAdd.checkTagged();
    257                 wayToAdd.checkDirectionTagged();
    258256            }
    259257            newWays.add(wayToAdd);
    260258            wayToAdd.nodes.addAll(chunkIt.next());
  • src/org/openstreetmap/josm/actions/search/SearchCompiler.java

     
    314314
    315315    private static class Untagged extends Match {
    316316        @Override public boolean match(OsmPrimitive osm) {
    317             return !osm.tagged;
     317            return !osm.isTagged();
    318318        }
    319319        @Override public String toString() {return "untagged";}
    320320    }
  • src/org/openstreetmap/josm/actions/UnGlueAction.java

     
    139139
    140140        Node c = new Node(selectedNode);
    141141        c.keys = null;
    142         c.tagged = false;
    143142        c.selected = false;
    144143        cmds.add(new ChangeCommand(selectedNode, c));
    145144       
     
    188187            return false;
    189188       
    190189        selectedNode = (Node)n;
    191         return  selectedNode.tagged;
     190        return  selectedNode.isTagged();
    192191    }
    193192
    194193    /**
  • src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java

     
    401401                    trkseg = new ArrayList<WayPoint>();
    402402                    trk.trackSegs.add(trkseg);
    403403                }
    404                 if (!n.tagged) {
     404                if (!n.isTagged()) {
    405405                    doneNodes.add(n);
    406406                }
    407407                WayPoint wpt = new WayPoint(n.coor);
  • src/org/openstreetmap/josm/gui/dialogs/RelationEditor.java

     
    409409        if (RelationEditor.this.relation == null) {
    410410            // If the user wanted to create a new relation, but hasn't added any members or
    411411            // tags, don't add an empty relation
    412             clone.checkTagged();
    413             if(clone.members.size() == 0 && !clone.tagged)
     412            if(clone.members.size() == 0 && !clone.isTagged())
    414413                return;
    415414            Main.main.undoRedo.add(new AddCommand(clone));
    416415            DataSet.fireSelectionChanged(Main.ds.getSelected());
  • src/org/openstreetmap/josm/io/OsmReader.java

     
    104104               osm.user = user;
    105105               osm.visible = visible;
    106106               osm.version = version;
    107                osm.checkTagged();
    108                osm.checkDirectionTagged();
    109107               osm.mappaintStyle = null;
    110108          }
    111109     }
  • src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java

     
    162162
    163163        //profilerN = 0;
    164164        for (final OsmPrimitive osm : data.ways)
    165             if (!osm.deleted && !osm.selected && osm.tagged)
     165            if (!osm.deleted && !osm.selected && osm.isTagged())
    166166            {
    167167                osm.visit(this);
    168168        //        profilerN++;
     
    170170        displaySegments();
    171171
    172172        for (final OsmPrimitive osm : data.ways)
    173             if (!osm.deleted && !osm.selected && !osm.tagged)
     173            if (!osm.deleted && !osm.selected && !osm.isTagged())
    174174            {
    175175                osm.visit(this);
    176176        //        profilerN++;
     
    254254            drawNode(n, highlightColor, selectedNodeSize, selectedNodeRadius, fillSelectedNode);
    255255        else if (n.selected)
    256256            drawNode(n, selectedColor, selectedNodeSize, selectedNodeRadius, fillSelectedNode);
    257         else if(n.tagged)
     257        else if(n.isTagged())
    258258            drawNode(n, nodeColor, taggedNodeSize, taggedNodeRadius, fillUnselectedNode);
    259259        else
    260260            drawNode(n, nodeColor, unselectedNodeSize, unselectedNodeRadius, fillUnselectedNode);
     
    300300           (even if the tag is negated as in oneway=false) or the way is selected */
    301301
    302302        boolean showThisDirectionArrow = w.selected
    303         || (showDirectionArrow && (!showRelevantDirectionsOnly || w.hasDirectionKeys));
     303        || (showDirectionArrow && (!showRelevantDirectionsOnly || w.hasDirectionKeys()));
    304304        /* head only takes over control if the option is true,
    305305           the direction should be shown at all and not only because it's selected */
    306306        boolean showOnlyHeadArrowOnly = showThisDirectionArrow && !w.selected && showHeadArrowOnly;
     
    312312            wayColor = highlightColor;
    313313        } else if(w.selected) {
    314314            wayColor = selectedColor;
    315         } else if (!w.tagged) {
     315        } else if (!w.isTagged()) {
    316316            wayColor = untaggedWayColor;
    317317        } else {
    318318            wayColor = dfltWayColor;
  • src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java

     
    156156            drawNode(n, highlightColor, selectedNodeSize, selectedNodeRadius, fillSelectedNode);
    157157        else if (n.selected)
    158158            drawNode(n, selectedColor, selectedNodeSize, selectedNodeRadius, fillSelectedNode);
    159         else if (n.tagged)
     159        else if (n.isTagged())
    160160            drawNode(n, nodeColor, taggedNodeSize, taggedNodeRadius, fillUnselectedNode);
    161161        else
    162162            drawNode(n, nodeColor, unselectedNodeSize, unselectedNodeRadius, fillUnselectedNode);
     
    244244           the way is tagged with a direction key
    245245           (even if the tag is negated as in oneway=false) or the way is selected */
    246246        boolean showDirection = w.selected || ((!useRealWidth) && (showDirectionArrow
    247         && (!showRelevantDirectionsOnly || w.hasDirectionKeys)));
     247        && (!showRelevantDirectionsOnly || w.hasDirectionKeys())));
    248248        /* head only takes over control if the option is true,
    249249           the direction should be shown at all and not only because it's selected */
    250250        boolean showOnlyHeadArrowOnly = showDirection && !w.selected && showHeadArrowOnly;
  • src/org/openstreetmap/josm/data/osm/Way.java

     
    9191        super.cloneFrom(osm);
    9292        nodes.clear();
    9393        nodes.addAll(((Way)osm).nodes);
    94         checkDirectionTagged();
    9594    }
    9695
    9796    @Override public String toString() {
  • src/org/openstreetmap/josm/data/osm/OsmPrimitive.java

     
    106106    public User user = null;
    107107
    108108    /**
    109      * true if this object is considered "tagged". To be "tagged", an object
    110      * must have one or more "non-standard" tags. "created_by" and "source"
    111      * are typically considered "standard" tags and do not make an object
    112      * "tagged".
    113      */
    114     public boolean tagged = false;
    115 
    116     /**
    117      * true if this object has direction dependent tags (e.g. oneway)
    118      */
    119     public boolean hasDirectionKeys = false;
    120 
    121     /**
    122109     * If set to true, this object is currently selected.
    123110     */
    124111    public volatile boolean selected = false;
     
    154141     */
    155142    public int version = -1;
    156143
     144    private static Collection<String> uninteresting = null;
    157145    /**
    158146     * Contains a list of "uninteresting" keys that do not make an object
    159147     * "tagged".
    160148     * Initialized by checkTagged()
    161149     */
    162     public static Collection<String> uninteresting = null;
     150    public static Collection<String> getUninterestingKeys() {
     151        if(uninteresting == null) {
     152            uninteresting = Main.pref.getCollection("tags.uninteresting",
     153                    Arrays.asList(new String[]{"source","note","comment","converted_by","created_by"}));
     154        }
     155        return uninteresting;
     156    }
     157       
    163158
     159    private static Collection<String> directionKeys = null;
     160   
    164161    /**
    165162     * Contains a list of direction-dependent keys that make an object
    166163     * direction dependent.
    167164     * Initialized by checkDirectionTagged()
    168165     */
    169     public static Collection<String> directionKeys = null;
     166    public static Collection<String> getDirectionKeys() {
     167        if(directionKeys == null) {
     168            directionKeys = Main.pref.getCollection("tags.direction",
     169                    Arrays.asList(new String[]{"oneway","incline","incline_steep","aerialway"}));
     170        }
     171        return directionKeys;
     172    }
    170173
    171174    /**
    172175     * Implementation of the visitor scheme. Subclasses have to call the correct
     
    241244                keys = new HashMap<String, String>();
    242245            keys.put(key, value);
    243246        }
    244         checkTagged();
    245         checkDirectionTagged();
    246247        mappaintStyle = null;
    247248    }
    248249    /**
     
    254255            if (keys.isEmpty())
    255256                keys = null;
    256257        }
    257         checkTagged();
    258         checkDirectionTagged();
    259258        mappaintStyle = null;
    260259    }
    261260
     
    291290        selected = osm.selected;
    292291        timestamp = osm.timestamp;
    293292        version = osm.version;
    294         tagged = osm.tagged;
    295293        incomplete = osm.incomplete;
    296294        clearCached();
    297295        clearErrors();
     
    319317        return timestamp == null ? null : new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(timestamp);
    320318    }
    321319
     320   
    322321    /**
    323      * Updates the "tagged" flag. "keys" property should probably be made private
    324      * to make sure this gets called when keys are set.
     322     * true if this object is considered "tagged". To be "tagged", an object
     323     * must have one or more "non-standard" tags. "created_by" and "source"
     324     * are typically considered "standard" tags and do not make an object
     325     * "tagged".
    325326     */
    326     public void checkTagged() {
    327         tagged = false;
    328         if(uninteresting == null)
    329             uninteresting = Main.pref.getCollection("tags.uninteresting",
    330             Arrays.asList(new String[]{"source","note","comment","converted_by","created_by"}));
     327    public boolean isTagged() {
     328        // TODO Cache value after keys are made private
     329        getUninterestingKeys();
    331330        if (keys != null) {
    332331            for (Entry<String,String> e : keys.entrySet()) {
    333332                if (!uninteresting.contains(e.getKey())) {
    334                     tagged = true;
    335                     break;
     333                    return true;
    336334                }
    337335            }
    338336        }
     337        return false;
    339338    }
    340339    /**
    341      * Updates the "hasDirectionKeys" flag. "keys" property should probably be made private
    342      * to make sure this gets called when keys are set.
     340     * true if this object has direction dependent tags (e.g. oneway)
    343341     */
    344     public void checkDirectionTagged() {
    345         hasDirectionKeys = false;
    346         if(directionKeys == null)
    347             /* this list only works for keys but not for values (e.g. highway=incline won't work here) */
    348             directionKeys = Main.pref.getCollection("tags.direction",
    349             Arrays.asList(new String[]{"oneway","incline","incline_steep","aerialway","junction"}));
     342    public boolean hasDirectionKeys() {
     343        // TODO Cache value after keys are made private
     344        getDirectionKeys();
    350345        if (keys != null) {
    351346            for (Entry<String,String> e : keys.entrySet()) {
    352347                if (directionKeys.contains(e.getKey())) {
    353                     hasDirectionKeys = true;
    354                     break;
     348                    return true;
    355349                }
    356350            }
    357351        }
     352        return false;
    358353    }
     354
    359355}
  • src/org/openstreetmap/josm/command/DeleteCommand.java

     
    188188            for (OsmPrimitive osm : del) {
    189189                if (osm instanceof Way) {
    190190                    for (Node n : ((Way) osm).nodes) {
    191                         if (!n.tagged) {
     191                        if (!n.isTagged()) {
    192192                            CollectBackReferencesVisitor v = new CollectBackReferencesVisitor(Main.ds, false);
    193193                            n.visit(v);
    194194                            v.data.removeAll(del);
     
    321321            Way wnew2 = new Way();
    322322            if (wnew.keys != null) {
    323323                wnew2.keys = new HashMap<String, String>(wnew.keys);
    324                 wnew2.checkTagged();
    325                 wnew2.checkDirectionTagged();
    326324            }
    327325            wnew2.nodes.addAll(n2);
    328326            cmds.add(new AddCommand(wnew2));