Ignore:
Timestamp:
2007-10-07T13:20:27+02:00 (17 years ago)
Author:
gebner
Message:

Merge 0.5.

File:
1 edited

Legend:

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

    r298 r343  
    11// License: GPL. Copyright 2007 by Immanuel Scholz and others
    2 
    32package org.openstreetmap.josm.data.osm.visitor;
    43
     
    1312
    1413import org.openstreetmap.josm.Main;
     14import org.openstreetmap.josm.data.osm.Relation;
    1515import org.openstreetmap.josm.data.osm.Node;
    1616import org.openstreetmap.josm.data.osm.OsmPrimitive;
    17 import org.openstreetmap.josm.data.osm.Segment;
    1817import org.openstreetmap.josm.data.osm.Way;
    1918import org.openstreetmap.josm.tools.ImageProvider;
     
    4140       
    4241        /**
    43          * If the segment has a key named "name", its value is displayed.
    44          * Otherwise, if it has "id", this is used. If none of these available,
    45          * "(x1,y1) -> (x2,y2)" is displayed with the nodes coordinates.
    46          */
    47         public void visit(Segment ls) {
    48                 name = ls.get("name");
    49                 if (name == null) {
    50                         if (ls.incomplete)
    51                                 name = ls.id == 0 ? tr("new") : ls.id+" ("+tr("unknown")+")";
    52                         else
    53                                 name = (ls.id==0?"":ls.id+" ")+"("+ls.from.coor.lat()+","+ls.from.coor.lon()+") -> ("+ls.to.coor.lat()+","+ls.to.coor.lon()+")";
    54                 }
    55                 addId(ls);
    56                 icon = ImageProvider.get("data", "segment");
    57                 trn("segment", "segments", 0); // no marktrn available
    58                 className = "segment";
    59         }
    60 
    61         /**
    6242         * If the node has a name-key or id-key, this is displayed. If not, (lat,lon)
    6343         * is displayed.
     
    8161                if (name == null) name = w.get("ref");
    8262                if (name == null) {
    83                         AllNodesVisitor.getAllNodes(w.segments);
    84                         Set<Node> nodes = new HashSet<Node>();
    85                         for (Segment ls : w.segments) {
    86                                 if (!ls.incomplete) {
    87                                         nodes.add(ls.from);
    88                                         nodes.add(ls.to);
    89                                 }
    90                         }
    9163                        String what = (w.get("highway") != null) ? "highway " : (w.get("railway") != null) ? "railway " : (w.get("waterway") != null) ? "waterway " : "";
    92                         name = what + trn("{0} node", "{0} nodes", nodes.size(), nodes.size());
     64                        name = what + trn("{0} node", "{0} nodes", w.nodes.size(), w.nodes.size());
    9365                }
    94                 if (w.isIncomplete())
    95                         name += " ("+tr("incomplete")+")";
    9666                addId(w);
    9767                icon = ImageProvider.get("data", "way");
    9868                trn("way", "ways", 0); // no marktrn available
    9969                className = "way";
     70        }
     71       
     72        /**
     73         */
     74        public void visit(Relation e) {
     75                name = e.get("type");
     76                // FIXME add names of members
     77                if (name == null)
     78                        name = "relation";
     79                addId(e);
     80                icon = ImageProvider.get("data", "relation");
     81                trn("relation", "relations", 0); // no marktrn available
     82                className = "relation";
    10083        }
    10184       
Note: See TracChangeset for help on using the changeset viewer.