Changeset 64 in josm for src/org/openstreetmap/josm/data


Ignore:
Timestamp:
2006-03-16T19:35:44+01:00 (18 years ago)
Author:
imi
Message:
  • renamed track to way
  • refactored Key to be a simple String
  • fixed PropertyDialog which displayed <different> for doubled values
Location:
src/org/openstreetmap/josm/data
Files:
1 deleted
14 edited
1 moved

Legend:

Unmodified
Added
Removed
  • src/org/openstreetmap/josm/data/Preferences.java

    r58 r64  
    4242
    4343        /**
    44          * Whether lines should be drawn between track points of raw gps data.
     44         * Whether lines should be drawn between way points of raw gps data.
    4545         */
    4646        private boolean drawRawGpsLines = false;
  • src/org/openstreetmap/josm/data/osm/DataSet.java

    r40 r64  
    2121
    2222        /**
    23          * All nodes goes here, even when included in other data (tracks etc).
     23         * All nodes goes here, even when included in other data (waies etc).
    2424         * This enables the instant conversion of the whole DataSet by iterating over
    2525         * this data structure.
     
    2828
    2929        /**
    30          * All line segments goes here, even when they are in a track.
     30         * All line segments goes here, even when they are in a way.
    3131         */
    3232        public Collection<LineSegment> lineSegments = new LinkedList<LineSegment>();
    3333
    3434        /**
    35          * All tracks (Streets etc.) in the DataSet.
     35         * All waies (Streets etc.) in the DataSet.
    3636         *
    37          * The nodes of the track segments of this track must be objects from
    38          * the nodes list, however the track segments are stored only in the
    39          * track list.
     37         * The nodes of the way segments of this way must be objects from
     38         * the nodes list, however the way segments are stored only in the
     39         * way list.
    4040         */
    41         public Collection<Track> tracks = new LinkedList<Track>();
     41        public Collection<Way> waies = new LinkedList<Way>();
    4242
    4343        /**
     
    4949                o.addAll(nodes);
    5050                o.addAll(lineSegments);
    51                 o.addAll(tracks);
     51                o.addAll(waies);
    5252                return o;
    5353        }
     
    133133                clearSelection(nodes);
    134134                clearSelection(lineSegments);
    135                 clearSelection(tracks);
     135                clearSelection(waies);
    136136        }
    137137
     
    144144                Collection<OsmPrimitive> sel = getSelected(nodes);
    145145                sel.addAll(getSelected(lineSegments));
    146                 sel.addAll(getSelected(tracks));
     146                sel.addAll(getSelected(waies));
    147147                return sel;
    148148        }
     
    155155                if (list == null)
    156156                        return;
    157                 for (OsmPrimitive osm : list) {
     157                for (OsmPrimitive osm : list)
    158158                        osm.setSelected(false);
    159                         if (osm.keys != null)
    160                                 clearSelection(osm.keys.keySet());
    161                 }
    162159        }
    163160
     
    170167                if (list == null)
    171168                        return sel;
    172                 for (OsmPrimitive osm : list) {
     169                for (OsmPrimitive osm : list)
    173170                        if (osm.isSelected() && !osm.isDeleted())
    174171                                sel.add(osm);
    175                         if (osm.keys != null)
    176                                 sel.addAll(getSelected(osm.keys.keySet()));
    177                 }
    178172                return sel;
    179173        }
  • src/org/openstreetmap/josm/data/osm/LineSegment.java

    r36 r64  
    66
    77/**
    8  * One track line segment consisting of a pair of nodes (start/end)
     8 * One way line segment consisting of a pair of nodes (start/end)
    99 *
    1010 * @author imi
  • src/org/openstreetmap/josm/data/osm/OsmPrimitive.java

    r61 r64  
    2424         * The key/value list for this primitive.
    2525         */
    26         public Map<Key, String> keys;
     26        public Map<String, String> keys;
    2727
    2828        /**
     
    7878
    7979                if (keys != null) {
    80                         for (Key k : keys.keySet())
     80                        for (String k : keys.keySet())
    8181                                if (other.keys.containsKey(k) && !keys.get(k).equals(other.keys.get(k)))
    8282                                        return false;
    83                         for (Key k : other.keys.keySet())
     83                        for (String k : other.keys.keySet())
    8484                                if (keys.containsKey(k) && !other.keys.get(k).equals(keys.get(k)))
    8585                                        return false;
     
    140140         * @param value The value for the key.
    141141         */
    142         public void put(Key key, String value) {
     142        public void put(String key, String value) {
    143143                if (keys == null)
    144                         keys = new HashMap<Key, String>();
     144                        keys = new HashMap<String, String>();
    145145                keys.put(key, value);
    146146        }
    147147       
    148         public String get(Key key) {
     148        public String get(String key) {
    149149                return (keys == null) ? null : keys.get(key);
    150150        }
  • src/org/openstreetmap/josm/data/osm/Way.java

    r63 r64  
    77
    88/**
    9  * One full track, consisting of several track segments chained together.
     9 * One full way, consisting of several way segments chained together.
    1010 *
    1111 * @author imi
    1212 */
    13 public class Track extends OsmPrimitive {
     13public class Way extends OsmPrimitive {
    1414
    1515        /**
    16          * All track segments in this track
     16         * All way segments in this way
    1717         */
    1818        public final List<LineSegment> segments = new ArrayList<LineSegment>();
     
    2020       
    2121        /**
    22          * Return the last node in the track. This is the node, which no line segment
     22         * Return the last node in the way. This is the node, which no line segment
    2323         * has as start, but at least one has it as end. If there are not exact one
    2424         * such nodes found, <code>null</code> is returned.
     
    4545
    4646        /**
    47          * Return the first node in the track. This is the node, which no line segment
     47         * Return the first node in the way. This is the node, which no line segment
    4848         * has as end, but at least one as starting node. If there are not exact one
    4949         * such nodes found, <code>null</code> is returned.
  • src/org/openstreetmap/josm/data/osm/visitor/AddVisitor.java

    r40 r64  
    44
    55import org.openstreetmap.josm.data.osm.DataSet;
    6 import org.openstreetmap.josm.data.osm.Key;
    76import org.openstreetmap.josm.data.osm.LineSegment;
    87import org.openstreetmap.josm.data.osm.Node;
    9 import org.openstreetmap.josm.data.osm.Track;
     8import org.openstreetmap.josm.data.osm.Way;
    109
    1110/**
     
    3029                ds.lineSegments.add(ls);
    3130        }
    32         public void visit(Track t) {
    33                 ds.tracks.add(t);
     31        public void visit(Way t) {
     32                ds.waies.add(t);
    3433        }
    35         public void visit(Key k) {}
    3634}
  • src/org/openstreetmap/josm/data/osm/visitor/AllNodesVisitor.java

    r23 r64  
    44import java.util.HashSet;
    55
    6 import org.openstreetmap.josm.data.osm.Key;
    76import org.openstreetmap.josm.data.osm.LineSegment;
    87import org.openstreetmap.josm.data.osm.Node;
    98import org.openstreetmap.josm.data.osm.OsmPrimitive;
    10 import org.openstreetmap.josm.data.osm.Track;
     9import org.openstreetmap.josm.data.osm.Way;
    1110
    1211/**
     
    3837
    3938        /**
    40          * Tracks have all nodes from their line segments.
     39         * Ways have all nodes from their line segments.
    4140         */
    42         public void visit(Track t) {
     41        public void visit(Way t) {
    4342                for (LineSegment ls : t.segments) {
    4443                        nodes.add(ls.start);
    4544                        nodes.add(ls.end);
    4645                }
    47         }
    48 
    49         /**
    50          * Keys have no nodes.
    51          */
    52         public void visit(Key k) {
    5346        }
    5447
  • src/org/openstreetmap/josm/data/osm/visitor/BoundingVisitor.java

    r35 r64  
    22
    33import org.openstreetmap.josm.data.Bounds;
    4 import org.openstreetmap.josm.data.osm.Key;
    54import org.openstreetmap.josm.data.osm.LineSegment;
    65import org.openstreetmap.josm.data.osm.Node;
    7 import org.openstreetmap.josm.data.osm.Track;
     6import org.openstreetmap.josm.data.osm.Way;
    87
    98/**
     
    5352        }
    5453
    55         public void visit(Track t) {
     54        public void visit(Way t) {
    5655                for (LineSegment ls : t.segments)
    5756                        visit(ls);
    5857        }
    59 
    60         public void visit(Key k) {
    61                 // do nothing
    62         }
    6358}
    6459
  • src/org/openstreetmap/josm/data/osm/visitor/CollectBackReferencesVisitor.java

    r40 r64  
    55
    66import org.openstreetmap.josm.data.osm.DataSet;
    7 import org.openstreetmap.josm.data.osm.Key;
    87import org.openstreetmap.josm.data.osm.LineSegment;
    98import org.openstreetmap.josm.data.osm.Node;
    109import org.openstreetmap.josm.data.osm.OsmPrimitive;
    11 import org.openstreetmap.josm.data.osm.Track;
     10import org.openstreetmap.josm.data.osm.Way;
    1211
    1312/**
    14  * Helper that collect all line segments a node is part of, all tracks
     13 * Helper that collect all line segments a node is part of, all waies
    1514 * a node or line segment is part of and all areas a node is part of.
    1615 *
     
    3837       
    3938        public void visit(Node n) {
    40                 for (Track t : ds.tracks) {
     39                for (Way t : ds.waies) {
    4140                        if (t.isDeleted())
    4241                                continue;
     
    5655        }
    5756        public void visit(LineSegment ls) {
    58                 for (Track t : ds.tracks) {
     57                for (Way t : ds.waies) {
    5958                        if (t.isDeleted())
    6059                                continue;
     
    6362                }
    6463        }
    65         public void visit(Track t) {}
    66         public void visit(Key k) {}
     64        public void visit(Way t) {}
    6765}
  • src/org/openstreetmap/josm/data/osm/visitor/CsvVisitor.java

    r30 r64  
    55import java.util.Map.Entry;
    66
    7 import org.openstreetmap.josm.data.osm.Key;
    87import org.openstreetmap.josm.data.osm.LineSegment;
    98import org.openstreetmap.josm.data.osm.Node;
    109import org.openstreetmap.josm.data.osm.OsmPrimitive;
    11 import org.openstreetmap.josm.data.osm.Track;
     10import org.openstreetmap.josm.data.osm.Way;
    1211
    1312/**
     
    3837        }
    3938
    40         public void visit(Track t) {
     39        public void visit(Way t) {
    4140                out.print("t,"+common(t)+","+t.segments.size());
    4241                for (LineSegment ls : t.segments) {
     
    4443                        visit(ls);
    4544                }
    46         }
    47 
    48         public void visit(Key k) {
    49                 //TODO
    5045        }
    5146
     
    6055                if (osm.keys != null) {
    6156                        b.append(","+osm.keys.size());
    62                         for (Entry<Key, String> e : osm.keys.entrySet())
    63                                 b.append(e.getKey().name+","+encode(e.getValue()));
     57                        for (Entry<String, String> e : osm.keys.entrySet())
     58                                b.append(e.getKey()+","+encode(e.getValue()));
    6459                } else
    6560                        b.append(",0");
  • src/org/openstreetmap/josm/data/osm/visitor/DeleteVisitor.java

    r40 r64  
    44
    55import org.openstreetmap.josm.data.osm.DataSet;
    6 import org.openstreetmap.josm.data.osm.Key;
    76import org.openstreetmap.josm.data.osm.LineSegment;
    87import org.openstreetmap.josm.data.osm.Node;
    9 import org.openstreetmap.josm.data.osm.Track;
     8import org.openstreetmap.josm.data.osm.Way;
    109
    1110/**
     
    3029                ds.lineSegments.remove(ls);
    3130        }
    32         public void visit(Track t) {
    33                 ds.tracks.remove(t);
     31        public void visit(Way t) {
     32                ds.waies.remove(t);
    3433        }
    35         public void visit(Key k) {}
    3634}
  • src/org/openstreetmap/josm/data/osm/visitor/MergeVisitor.java

    r60 r64  
    77
    88import org.openstreetmap.josm.data.osm.DataSet;
    9 import org.openstreetmap.josm.data.osm.Key;
    109import org.openstreetmap.josm.data.osm.LineSegment;
    1110import org.openstreetmap.josm.data.osm.Node;
    1211import org.openstreetmap.josm.data.osm.OsmPrimitive;
    13 import org.openstreetmap.josm.data.osm.Track;
     12import org.openstreetmap.josm.data.osm.Way;
    1413
    1514/**
     
    9796
    9897        /**
    99          * Merge the track if id matches or if all line segments matches and the
    100          * id is zero of either track.
    101          */
    102         public void visit(Track otherTrack) {
    103                 Track myTrack = null;
    104                 for (Track t : ds.tracks) {
    105                         if (match(otherTrack, t)) {
    106                                 myTrack = t;
     98         * Merge the way if id matches or if all line segments matches and the
     99         * id is zero of either way.
     100         */
     101        public void visit(Way otherWay) {
     102                Way myWay = null;
     103                for (Way t : ds.waies) {
     104                        if (match(otherWay, t)) {
     105                                myWay = t;
    107106                                break;
    108107                        }
    109108                }
    110                 if (myTrack == null)
    111                         ds.tracks.add(otherTrack);
     109                if (myWay == null)
     110                        ds.waies.add(otherWay);
    112111                else {
    113                         mergeCommon(myTrack, otherTrack);
    114                         if (myTrack.modified && !otherTrack.modified)
     112                        mergeCommon(myWay, otherWay);
     113                        if (myWay.modified && !otherWay.modified)
    115114                                return;
    116115                        boolean same = true;
    117                         Iterator<LineSegment> it = otherTrack.segments.iterator();
    118                         for (LineSegment ls : myTrack.segments) {
     116                        Iterator<LineSegment> it = otherWay.segments.iterator();
     117                        for (LineSegment ls : myWay.segments) {
    119118                                if (!match(ls, it.next()))
    120119                                        same = false;
    121120                        }
    122121                        if (!same) {
    123                                 myTrack.segments.clear();
    124                                 myTrack.segments.addAll(otherTrack.segments);
    125                                 myTrack.modified = otherTrack.modified;
    126                         }
    127                 }
    128         }
    129 
    130         public void visit(Key k) {
    131                 //TODO: Key doesn't really fit the OsmPrimitive concept!
    132         }
    133        
     122                                myWay.segments.clear();
     123                                myWay.segments.addAll(otherWay.segments);
     124                                myWay.modified = otherWay.modified;
     125                        }
     126                }
     127        }
     128
    134129        /**
    135130         * Postprocess the dataset and fix all merged references to point to the actual
     
    143138                                ls.end = mergedNodes.get(ls.end);
    144139                }
    145                 for (Track t : ds.tracks) {
     140                for (Way t : ds.waies) {
    146141                        boolean replacedSomething = false;
    147142                        LinkedList<LineSegment> newSegments = new LinkedList<LineSegment>();
     
    184179
    185180        /**
    186          * @return Whether the tracks matches (in sense of "be mergable").
    187          */
    188         private boolean match(Track t1, Track t2) {
     181         * @return Whether the waies matches (in sense of "be mergable").
     182         */
     183        private boolean match(Way t1, Way t2) {
    189184                if (t1.id == 0 || t2.id == 0) {
    190185                        if (t1.segments.size() != t2.segments.size())
  • src/org/openstreetmap/josm/data/osm/visitor/SelectionComponentVisitor.java

    r23 r64  
    88import javax.swing.Icon;
    99
    10 import org.openstreetmap.josm.data.osm.Key;
    1110import org.openstreetmap.josm.data.osm.LineSegment;
    1211import org.openstreetmap.josm.data.osm.Node;
    13 import org.openstreetmap.josm.data.osm.Track;
     12import org.openstreetmap.josm.data.osm.Way;
    1413import org.openstreetmap.josm.gui.ImageProvider;
    1514
     
    3130       
    3231       
    33         /**
    34          * A key icon and the name of the key.
    35          */
    36         public void visit(Key k) {
    37                 name = k.name;
    38                 icon = ImageProvider.get("data", "key");
    39         }
    40 
    4132        /**
    4233         * If the line segment has a key named "name", its value is displayed.
     
    6758
    6859        /**
    69          * If the track has a name-key or id-key, this is displayed. If not, (x nodes)
    70          * is displayed with x beeing the number of nodes in the track.
     60         * If the way has a name-key or id-key, this is displayed. If not, (x nodes)
     61         * is displayed with x beeing the number of nodes in the way.
    7162         */
    72         public void visit(Track t) {
     63        public void visit(Way t) {
    7364                String name = getName(t.keys);
    7465                if (name == null) {
     
    8273               
    8374                this.name = name;
    84                 icon = ImageProvider.get("data", "track");
     75                icon = ImageProvider.get("data", "way");
    8576        }
    8677
     
    9182         * @return If a name could be found, return it here.
    9283         */
    93         public String getName(Map<Key, String> keys) {
     84        public String getName(Map<String, String> keys) {
    9485                String name = null;
    9586                if (keys != null) {
    96                         name = keys.get(Key.get("name"));
     87                        name = keys.get("name");
    9788                        if (name == null)
    98                                 name = keys.get(Key.get("id"));
     89                                name = keys.get("id");
    9990                }
    10091                return name;
  • src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java

    r41 r64  
    55import java.awt.Point;
    66
    7 import org.openstreetmap.josm.data.osm.Key;
    87import org.openstreetmap.josm.data.osm.LineSegment;
    98import org.openstreetmap.josm.data.osm.Node;
    10 import org.openstreetmap.josm.data.osm.Track;
     9import org.openstreetmap.josm.data.osm.Way;
    1110import org.openstreetmap.josm.gui.NavigatableComponent;
    1211
     
    6160        /**
    6261         * Draw a darkblue line for all line segments.
    63          * @param t The track to draw.
     62         * @param t The way to draw.
    6463         */
    65         public void visit(Track t) {
     64        public void visit(Way t) {
    6665                // only to overwrite with blue
    6766                for (LineSegment ls : t.segments)
     
    7069        }
    7170
    72         /**
    73          * Do not draw a key.
    74          */
    75         public void visit(Key k) {
    76         }
    77        
    7871        /**
    7972         * Draw the node as small rectangle with the given color.
  • src/org/openstreetmap/josm/data/osm/visitor/Visitor.java

    r21 r64  
    11package org.openstreetmap.josm.data.osm.visitor;
    22
    3 import org.openstreetmap.josm.data.osm.Key;
    43import org.openstreetmap.josm.data.osm.LineSegment;
    54import org.openstreetmap.josm.data.osm.Node;
    6 import org.openstreetmap.josm.data.osm.Track;
     5import org.openstreetmap.josm.data.osm.Way;
    76
    87/**
     
    1514        void visit(Node n);
    1615        void visit(LineSegment ls);
    17         void visit(Track t);
    18         void visit(Key k);
     16        void visit(Way t);
    1917}
Note: See TracChangeset for help on using the changeset viewer.