Changeset 64 in josm for src/org


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
Files:
1 deleted
35 edited
1 moved

Legend:

Unmodified
Added
Removed
  • src/org/openstreetmap/josm/actions/mapmode/AddWayAction.java

    r62 r64  
    1313import org.openstreetmap.josm.data.osm.LineSegment;
    1414import org.openstreetmap.josm.data.osm.OsmPrimitive;
    15 import org.openstreetmap.josm.data.osm.Track;
     15import org.openstreetmap.josm.data.osm.Way;
    1616import org.openstreetmap.josm.gui.MapFrame;
    1717
    1818/**
    19  * Add a new track from all selected line segments.
     19 * Add a new way from all selected line segments.
    2020 *
    2121 * If there is a selection when the mode is entered, all line segments in this
    22  * selection form a new track, except the user holds down Shift.
     22 * selection form a new way, except the user holds down Shift.
    2323 *
    24  * The user can click on a line segment. If he holds down Shift, no track is
    25  * created yet. If he holds down Alt, the whole track is considered instead of
    26  * the clicked line segment. If the user holds down Ctrl, no track is created
     24 * The user can click on a line segment. If he holds down Shift, no way is
     25 * created yet. If he holds down Alt, the whole way is considered instead of
     26 * the clicked line segment. If the user holds down Ctrl, no way is created
    2727 * and the clicked line segment get removed from the list.
    2828 *
    2929 * Also, the user may select a rectangle as in selection mode. No node, area or
    30  * track can be selected this way.
     30 * way can be selected this way.
    3131 *
    3232 * @author imi
     
    4949        @Override
    5050        public void actionPerformed(ActionEvent e) {
    51                 makeTrack();
     51                makeWay();
    5252                super.actionPerformed(e);
    5353                mapFrame.selectMapMode(followMode);
     
    5555
    5656        /**
    57          * Just make a track of all selected items.
     57         * Just make a way of all selected items.
    5858         */
    59         private void makeTrack() {
     59        private void makeWay() {
    6060                Collection<OsmPrimitive> selection = Main.main.ds.getSelected();
    6161                if (selection.isEmpty())
    6262                        return;
    6363
    64                 // form a new track
     64                // form a new way
    6565                LinkedList<LineSegment> lineSegments = new LinkedList<LineSegment>();
    6666                int numberOfSelectedWays = 0;
    6767                for (OsmPrimitive osm : selection) {
    68                         if (osm instanceof Track)
     68                        if (osm instanceof Way)
    6969                                numberOfSelectedWays++;
    7070                        else if (osm instanceof LineSegment)
     
    8080                        if (answer == JOptionPane.YES_OPTION) {
    8181                                for (OsmPrimitive osm : selection)
    82                                         if (osm instanceof Track)
    83                                                 lineSegments.addAll(((Track)osm).segments);
     82                                        if (osm instanceof Way)
     83                                                lineSegments.addAll(((Way)osm).segments);
    8484                        }
    8585                }
     
    114114                }
    115115               
    116                 Track t = new Track();
     116                Way t = new Way();
    117117                for (LineSegment ls : sortedLineSegments)
    118118                        t.segments.add(ls);
  • src/org/openstreetmap/josm/actions/mapmode/DeleteAction.java

    r32 r64  
    2626 * @see #deleteWithReferences(OsmPrimitive)
    2727 *
    28  * Pressing Alt will select the track instead of a line segment, as usual.
     28 * Pressing Alt will select the way instead of a line segment, as usual.
    2929 *
    3030 * If the user did not press Ctrl and the object has any references, the user
     
    9494         * Delete the primitives and everything they references.
    9595         *
    96          * If a node is deleted, the node and all line segments, tracks and areas
     96         * If a node is deleted, the node and all line segments, waies and areas
    9797         * the node is part of are deleted as well.
    9898         *
    99          * If a line segment is deleted, all tracks the line segment is part of
     99         * If a line segment is deleted, all waies the line segment is part of
    100100         * are deleted as well. No nodes are deleted.
    101101         *
    102          * If a track is deleted, only the track and no line segments or nodes are
     102         * If a way is deleted, only the way and no line segments or nodes are
    103103         * deleted.
    104104         *
  • src/org/openstreetmap/josm/actions/mapmode/SelectionAction.java

    r23 r64  
    2727 * If Alt key was hold, select all objects that are touched by the
    2828 * selection rectangle. If the Alt key was not hold, select only those objects
    29  * completly within (e.g. for tracks mean: only if all nodes of the track are
     29 * completly within (e.g. for waies mean: only if all nodes of the way are
    3030 * within). 
    3131 *
  • src/org/openstreetmap/josm/command/ChangeKeyValueCommand.java

    r35 r64  
    88import java.util.Map;
    99
    10 import org.openstreetmap.josm.data.osm.Key;
    1110import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1211
     
    2625         * The key that is subject to change.
    2726         */
    28         private final Key key;
     27        private final String key;
    2928        /**
    3029         * The key value. If it is <code>null</code>, delete all key references with the given
     
    3736         * These are the old values of the objects to do a proper undo.
    3837         */
    39         private List<Map<Key, String>> oldProperties;
     38        private List<Map<String, String>> oldProperties;
    4039       
    4140        /**
     
    4443        private List<Boolean> oldModified = new LinkedList<Boolean>();
    4544
    46         public ChangeKeyValueCommand(Collection<OsmPrimitive> objects, Key key, String value) {
     45        public ChangeKeyValueCommand(Collection<OsmPrimitive> objects, String key, String value) {
    4746                this.objects = new LinkedList<OsmPrimitive>(objects);
    4847                this.key = key;
     
    5251        public void executeCommand() {
    5352                // save old
    54                 oldProperties = new LinkedList<Map<Key, String>>();
     53                oldProperties = new LinkedList<Map<String, String>>();
    5554                for (OsmPrimitive osm : objects) {
    56                         oldProperties.add(osm.keys == null ? null : new HashMap<Key, String>(osm.keys));
     55                        oldProperties.add(osm.keys == null ? null : new HashMap<String, String>(osm.keys));
    5756                        oldModified.add(osm.modifiedProperties);
    5857                        osm.modifiedProperties = true;
     
    7069                        for (OsmPrimitive osm : objects) {
    7170                                if (osm.keys == null)
    72                                         osm.keys = new HashMap<Key, String>();
     71                                        osm.keys = new HashMap<String, String>();
    7372                                osm.keys.put(key, value);
    7473                        }
     
    7776
    7877        public void undoCommand() {
    79                 Iterator<Map<Key, String>> it = oldProperties.iterator();
     78                Iterator<Map<String, String>> it = oldProperties.iterator();
    8079                Iterator<Boolean> itMod = oldModified.iterator();
    8180                for (OsmPrimitive osm : objects) {
  • 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}
  • src/org/openstreetmap/josm/gui/ImageProvider.java

    r41 r64  
    4343                        subdir += "/";
    4444                URL path = Main.class.getResource("/images/"+subdir+name+".png");
     45                if (path == null)
     46                        throw new NullPointerException("/images/"+subdir+name+".png not found");
    4547                ImageIcon icon = cache.get(path);
    4648                if (icon == null) {
  • src/org/openstreetmap/josm/gui/MapStatus.java

    r56 r64  
    2828import org.openstreetmap.josm.Main;
    2929import org.openstreetmap.josm.data.GeoPoint;
    30 import org.openstreetmap.josm.data.osm.Key;
    3130import org.openstreetmap.josm.data.osm.OsmPrimitive;
    3231import org.openstreetmap.josm.data.osm.visitor.SelectionComponentVisitor;
     
    141140                                                                text.append("<br>id="+osm.id);
    142141                                                        if (osm.keys != null)
    143                                                                 for (Entry<Key, String> e : osm.keys.entrySet())
    144                                                                         text.append("<br>"+e.getKey().name+"="+e.getValue());
     142                                                                for (Entry<String, String> e : osm.keys.entrySet())
     143                                                                        text.append("<br>"+e.getKey()+"="+e.getValue());
    145144                                                        final JLabel l = new JLabel("<html>"+text.toString()+"</html>", visitor.icon, JLabel.HORIZONTAL);
    146145                                                        l.setFont(l.getFont().deriveFont(Font.PLAIN));
  • src/org/openstreetmap/josm/gui/NavigatableComponent.java

    r42 r64  
    1212import org.openstreetmap.josm.data.osm.Node;
    1313import org.openstreetmap.josm.data.osm.OsmPrimitive;
    14 import org.openstreetmap.josm.data.osm.Track;
     14import org.openstreetmap.josm.data.osm.Way;
    1515import org.openstreetmap.josm.data.projection.Projection;
    1616
     
    118118         * If no such line segment is found, and a non-pending line segment is
    119119         * within 10 pixel to p, this segment is returned, except when
    120          * <code>wholeTrack</code> is <code>true</code>, in which case the
    121          * corresponding Track is returned.
     120         * <code>wholeWay</code> is <code>true</code>, in which case the
     121         * corresponding Way is returned.
    122122         *
    123123         * If no line segment is found and the point is within an area, return that
     
    127127         *
    128128         * @param p                              The point on screen.
    129          * @param lsInsteadTrack Whether the line segment (true) or only the whole
    130          *                                               track should be returned.
     129         * @param lsInsteadWay Whether the line segment (true) or only the whole
     130         *                                               way should be returned.
    131131         * @return      The primitive, that is nearest to the point p.
    132132         */
    133         public OsmPrimitive getNearest(Point p, boolean lsInsteadTrack) {
     133        public OsmPrimitive getNearest(Point p, boolean lsInsteadWay) {
    134134                double minDistanceSq = Double.MAX_VALUE;
    135135                OsmPrimitive minPrimitive = null;
     
    149149                        return minPrimitive;
    150150               
    151                 // for whole tracks, try the tracks first
     151                // for whole waies, try the waies first
    152152                minDistanceSq = Double.MAX_VALUE;
    153                 if (!lsInsteadTrack) {
    154                         for (Track t : Main.main.ds.tracks) {
     153                if (!lsInsteadWay) {
     154                        for (Way t : Main.main.ds.waies) {
    155155                                if (t.isDeleted())
    156156                                        continue;
     
    201201         * If its a node, return all line segments and
    202202         * streets the node is part of, as well as all nodes
    203          * (with their line segments and tracks) with the same
     203         * (with their line segments and waies) with the same
    204204         * location.
    205205         *
    206          * If its a line segment, return all tracks this segment
     206         * If its a line segment, return all waies this segment
    207207         * belongs to as well as all line segments that are between
    208          * the same nodes (in both direction) with all their tracks.
     208         * the same nodes (in both direction) with all their waies.
    209209         *
    210210         * @return A collection of all items or <code>null</code>
     
    235235                }
    236236                if (osm instanceof Node || osm instanceof LineSegment) {
    237                         for (Track t : Main.main.ds.tracks) {
     237                        for (Way t : Main.main.ds.waies) {
    238238                                if (t.isDeleted())
    239239                                        continue;
  • src/org/openstreetmap/josm/gui/PreferenceDialog.java

    r43 r64  
    177177                                "An example: \"ignore ignore lat lon\" will use ' ' as delimiter, skip the first two values and read then lat/lon.<br>" +
    178178                                "Other example: \"lat,lon\" will just read lat/lon values comma seperated.</html>");
    179                 drawRawGpsLines.setToolTipText("If your gps device draw to few lines, select this to draw lines along your track.");
     179                drawRawGpsLines.setToolTipText("If your gps device draw to few lines, select this to draw lines along your way.");
    180180                drawRawGpsLines.setSelected(Main.pref.isDrawRawGpsLines());
    181181                forceRawGpsLines.setToolTipText("Force drawing of lines if the imported data contain no line information.");
  • src/org/openstreetmap/josm/gui/SelectionManager.java

    r42 r64  
    1919import org.openstreetmap.josm.data.osm.Node;
    2020import org.openstreetmap.josm.data.osm.OsmPrimitive;
    21 import org.openstreetmap.josm.data.osm.Track;
     21import org.openstreetmap.josm.data.osm.Way;
    2222
    2323/**
     
    257257         * @param alt Whether the alt key was pressed, which means select all objects
    258258         *              that are touched, instead those which are completly covered. Also
    259          *              select whole tracks instead of line segments.
     259         *              select whole waies instead of line segments.
    260260         */
    261261        public Collection<OsmPrimitive> getObjectsInRectangle(Rectangle r, boolean alt) {
     
    282282                                        selection.add(ls);
    283283
    284                         // tracks
    285                         for (Track t : Main.main.ds.tracks) {
    286                                 boolean wholeTrackSelected = !t.segments.isEmpty();
     284                        // waies
     285                        for (Way t : Main.main.ds.waies) {
     286                                boolean wholeWaySelected = !t.segments.isEmpty();
    287287                                for (LineSegment ls : t.segments)
    288288                                        if (rectangleContainLineSegment(r, alt, ls))
    289289                                                selection.add(ls);
    290290                                        else
    291                                                 wholeTrackSelected = false;
    292                                 if (wholeTrackSelected)
     291                                                wholeWaySelected = false;
     292                                if (wholeWaySelected)
    293293                                        selection.add(t);
    294294                        }
  • src/org/openstreetmap/josm/gui/dialogs/PropertiesDialog.java

    r62 r64  
    1414import java.awt.event.WindowFocusListener;
    1515import java.util.Collection;
    16 import java.util.HashMap;
    1716import java.util.Iterator;
    1817import java.util.TreeMap;
     
    3736import org.openstreetmap.josm.command.ChangeKeyValueCommand;
    3837import org.openstreetmap.josm.data.SelectionChangedListener;
    39 import org.openstreetmap.josm.data.osm.Key;
    4038import org.openstreetmap.josm.data.osm.OsmPrimitive;
    4139import org.openstreetmap.josm.gui.ImageProvider;
     
    125123                if (value.equals(""))
    126124                        value = null; // delete the key
    127                 mv.editLayer().add(new ChangeKeyValueCommand(sel, Key.get(key), value));
     125                mv.editLayer().add(new ChangeKeyValueCommand(sel, key, value));
    128126
    129127                if (value == null)
     
    143141                p.add(new JLabel("<html>This will change "+sel.size()+" object"+(sel.size()==1?"":"s")+".<br><br>"+
    144142                "Please select a key"), BorderLayout.NORTH);
    145                 Vector<String> allKeys = new Vector<String>(Key.allKeys.keySet());
     143                Vector<String> allKeys = new Vector<String>();
     144                for (OsmPrimitive osm : Main.main.ds.allNonDeletedPrimitives())
     145                        if (osm.keys != null)
     146                                allKeys.addAll(osm.keys.keySet());
    146147                for (Iterator<String> it = allKeys.iterator(); it.hasNext();) {
    147148                        String s = it.next();
     
    170171                if (value.equals(""))
    171172                        return;
    172                 mv.editLayer().add(new ChangeKeyValueCommand(sel, Key.get(key), value));
     173                mv.editLayer().add(new ChangeKeyValueCommand(sel, key, value));
    173174                selectionChanged(sel); // update table
    174175        }
     
    181182                String key = data.getValueAt(row, 0).toString();
    182183                Collection<OsmPrimitive> sel = Main.main.ds.getSelected();
    183                 mv.editLayer().add(new ChangeKeyValueCommand(sel, Key.get(key), null));
     184                mv.editLayer().add(new ChangeKeyValueCommand(sel, key, null));
    184185                selectionChanged(sel); // update table
    185186        }
     
    293294                data.setRowCount(0);
    294295                TreeMap<String, Collection<String>> props = new TreeMap<String, Collection<String>>();
    295                 HashMap<String, Integer> valueCounts = new HashMap<String, Integer>();
    296296                for (OsmPrimitive osm : newSelection) {
    297297                        if (osm.keys != null) {
    298                                 for (Entry<Key, String> e : osm.keys.entrySet()) {
    299                                         Collection<String> value = props.get(e.getKey().name);
     298                                for (Entry<String, String> e : osm.keys.entrySet()) {
     299                                        Collection<String> value = props.get(e.getKey());
    300300                                        if (value == null) {
    301301                                                value = new TreeSet<String>();
    302                                                 props.put(e.getKey().name, value);
     302                                                props.put(e.getKey(), value);
    303303                                        }
    304304                                        value.add(e.getValue());
    305                                        
    306                                         Integer count = valueCounts.get(e.getValue());
    307                                         if (count == null)
    308                                                 count = 0;
    309                                         valueCounts.put(e.getValue(), count+1);
    310305                                }
    311306                        }
    312307                }
    313                 int selCount = newSelection.size();
    314308                for (Entry<String, Collection<String>> e : props.entrySet()) {
    315309                        JComboBox value = new JComboBox(e.getValue().toArray());
    316310                        value.setEditable(true);
    317                         if (e.getValue().size() > 1 || valueCounts.get(e.getValue().iterator().next()) != selCount)
    318                                 value.getEditor().setItem("<different>");
     311                        value.getEditor().setItem(e.getValue().size() > 1 ? "<different>" : e.getValue().iterator().next());
    319312                        data.addRow(new Object[]{e.getKey(), value});
    320313                }
  • src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java

    r62 r64  
    2323import org.openstreetmap.josm.Main;
    2424import org.openstreetmap.josm.data.SelectionChangedListener;
    25 import org.openstreetmap.josm.data.osm.Key;
    2625import org.openstreetmap.josm.data.osm.OsmPrimitive;
    2726import org.openstreetmap.josm.gui.ImageProvider;
     
    9594                                for (OsmPrimitive osm : Main.main.ds.allNonDeletedPrimitives()) {
    9695                                        if (osm.keys != null) {
    97                                                 for (Entry<Key, String> ent : osm.keys.entrySet()) {
     96                                                for (Entry<String, String> ent : osm.keys.entrySet()) {
    9897                                                        if (match(lastSearch, ent.getKey(), ent.getValue())) {
    9998                                                                osm.setSelected(true);
     
    106105                                Main.main.getMapFrame().repaint();
    107106                        }
    108                         private boolean match(String search, Key key, String value) {
     107                        private boolean match(String search, String key, String value) {
    109108                                int colon = search.indexOf(':');
    110109                                if (colon == -1)
    111                                         return key.name.indexOf(search) != -1 || value.indexOf(search) != -1;
    112                                 return key.name.equals(search.substring(0, colon)) && value.indexOf(search.substring(colon+1)) != -1;
     110                                        return key.indexOf(search) != -1 || value.indexOf(search) != -1;
     111                                return key.equals(search.substring(0, colon)) && value.indexOf(search.substring(colon+1)) != -1;
    113112                        }
    114113                });
  • src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java

    r57 r64  
    2020import org.openstreetmap.josm.data.osm.Node;
    2121import org.openstreetmap.josm.data.osm.OsmPrimitive;
    22 import org.openstreetmap.josm.data.osm.Track;
     22import org.openstreetmap.josm.data.osm.Way;
    2323import org.openstreetmap.josm.data.osm.visitor.BoundingVisitor;
    2424import org.openstreetmap.josm.data.osm.visitor.MergeVisitor;
     
    113113                        if (!osm.isDeleted())
    114114                                osm.visit(visitor);
    115                 for (OsmPrimitive osm : data.tracks)
     115                for (OsmPrimitive osm : data.waies)
    116116                        if (!osm.isDeleted())
    117117                                osm.visit(visitor);
     
    128128                return undeletedSize(data.nodes)+" nodes, "+
    129129                        undeletedSize(data.lineSegments)+" segments, "+
    130                         undeletedSize(data.tracks)+" streets.";
     130                        undeletedSize(data.waies)+" streets.";
    131131        }
    132132
     
    238238                        for (Iterator<LineSegment> it = data.lineSegments.iterator(); it.hasNext();)
    239239                                cleanIterator(it, processedSet);
    240                         for (Iterator<Track> it = data.tracks.iterator(); it.hasNext();)
     240                        for (Iterator<Way> it = data.waies.iterator(); it.hasNext();)
    241241                                cleanIterator(it, processedSet);
    242242                }
  • src/org/openstreetmap/josm/gui/layer/RawGpsDataLayer.java

    r38 r64  
    2828
    2929        /**
    30          * A list of tracks which containing a list of points.
     30         * A list of waies which containing a list of points.
    3131         */
    3232        private final Collection<Collection<GeoPoint>> data;
     
    7878        @Override
    7979        public String getToolTipText() {
    80                 return data.size()+" tracks.";
     80                return data.size()+" waies.";
    8181        }
    8282
  • src/org/openstreetmap/josm/io/GpxReader.java

    r49 r64  
    1414import org.openstreetmap.josm.data.GeoPoint;
    1515import org.openstreetmap.josm.data.osm.DataSet;
    16 import org.openstreetmap.josm.data.osm.Key;
    1716import org.openstreetmap.josm.data.osm.LineSegment;
    1817import org.openstreetmap.josm.data.osm.Node;
    1918import org.openstreetmap.josm.data.osm.OsmPrimitive;
    20 import org.openstreetmap.josm.data.osm.Track;
     19import org.openstreetmap.josm.data.osm.Way;
    2120
    2221/**
     
    9998        private DataSet parseDataSet(Element e) {
    10099                DataSet data = new DataSet();
    101                 // read waypoints not contained in tracks or areas
     100                // read waypoints not contained in waies or areas
    102101                for (Object o : e.getChildren("wpt", GPX)) {
    103102                        Node node = parseWaypoint((Element)o);
     
    105104                }
    106105       
    107                 // read tracks (and line segments)
    108                 for (Object trackElement : e.getChildren("trk", GPX))
    109                         parseTrack((Element)trackElement, data);
     106                // read waies (and line segments)
     107                for (Object wayElement : e.getChildren("trk", GPX))
     108                        parseWay((Element)wayElement, data);
    110109
    111110                // reset new created ids to zero
     
    118117
    119118        /**
    120          * Parse and read a track from the element. Store it in the dataSet, as well
     119         * Parse and read a way from the element. Store it in the dataSet, as well
    121120         * as all nodes in it.
    122121         *
    123          * @param e             The element that contain the track.
     122         * @param e             The element that contain the way.
    124123         * @param ds    The DataSet to store the data in.
    125124         */
    126         private void parseTrack(Element e, DataSet ds) {
    127                 Track track = new Track();
    128                 boolean realLineSegment = false; // is this track just a fake?
     125        private void parseWay(Element e, DataSet ds) {
     126                Way way = new Way();
     127                boolean realLineSegment = false; // is this way just a fake?
    129128
    130129                for (Object o : e.getChildren()) {
     
    141140                                                parseKeyValueExtensions(lineSegment, child.getChild("extensions", GPX));
    142141                                                lineSegment = (LineSegment)getNewIfSeenBefore(lineSegment);
    143                                                 track.segments.add(lineSegment);
     142                                                way.segments.add(lineSegment);
    144143                                                start = node;
    145144                                        }
    146145                                }
    147146                        } else if (child.getName().equals("extensions")) {
    148                                 parseKeyValueExtensions(track, child);
     147                                parseKeyValueExtensions(way, child);
    149148                                if (child.getChild("segment", JOSM) != null)
    150149                                        realLineSegment = true;
    151150                        } else if (child.getName().equals("link"))
    152                                 parseKeyValueLink(track, child);
     151                                parseKeyValueLink(way, child);
    153152                        else
    154                                 parseKeyValueTag(track, child);
    155                 }
    156                 track = (Track)getNewIfSeenBefore(track);
    157                 ds.lineSegments.addAll(track.segments);
     153                                parseKeyValueTag(way, child);
     154                }
     155                way = (Way)getNewIfSeenBefore(way);
     156                ds.lineSegments.addAll(way.segments);
    158157                if (!realLineSegment)
    159                         ds.tracks.add(track);
     158                        ds.waies.add(way);
    160159        }
    161160
     
    202201                        for (Object o : e.getChildren("property", OSM)) {
    203202                                if (osm.keys == null)
    204                                         osm.keys = new HashMap<Key, String>();
     203                                        osm.keys = new HashMap<String, String>();
    205204                                Element child = (Element)o;
    206205                                String keyname = child.getAttributeValue("key");
    207206                                if (keyname != null) {
    208                                         Key key = Key.get(keyname);
    209207                                        String value = child.getAttributeValue("value");
    210208                                        if (value == null)
    211209                                                value = "";
    212                                         osm.keys.put(key, value);
     210                                        osm.keys.put(keyname, value);
    213211                                }
    214212                        }
     
    235233         */
    236234        private void parseKeyValueTag(OsmPrimitive osm, Element e) {
    237                 if (e != null) {
    238                         if (osm.keys == null)
    239                                 osm.keys = new HashMap<Key, String>();
    240                         osm.keys.put(Key.get(e.getName()), e.getValue());
    241                 }
     235                if (e != null)
     236                        osm.put(e.getName(), e.getValue());
    242237        }
    243238
     
    257252                if (e != null) {
    258253                        if (osm.keys == null)
    259                                 osm.keys = new HashMap<Key, String>();
     254                                osm.keys = new HashMap<String, String>();
    260255                        String link = e.getChildText("type") + ";" + e.getChildText("text");
    261                         osm.keys.put(Key.get("link"), link);
     256                        osm.keys.put("link", link);
    262257                }
    263258        }
  • src/org/openstreetmap/josm/io/GpxWriter.java

    r49 r64  
    1616import org.jdom.output.XMLOutputter;
    1717import org.openstreetmap.josm.data.osm.DataSet;
    18 import org.openstreetmap.josm.data.osm.Key;
    1918import org.openstreetmap.josm.data.osm.LineSegment;
    2019import org.openstreetmap.josm.data.osm.Node;
    2120import org.openstreetmap.josm.data.osm.OsmPrimitive;
    22 import org.openstreetmap.josm.data.osm.Track;
     21import org.openstreetmap.josm.data.osm.Way;
    2322
    2423/**
     
    2726 * <code>&lt;extensions&gt;</code> instead.
    2827 *
    29  * GPX-Track segments are stored as 2-node-pairs, so no &lt;trkseg&gt; with more
     28 * GPX-Way segments are stored as 2-node-pairs, so no &lt;trkseg&gt; with more
    3029 * or less than 2 &lt;trkpt&gt; are exported.
    3130 *
     
    107106                LinkedList<LineSegment> unrefLs = new LinkedList<LineSegment>(ds.lineSegments);
    108107
    109                 // tracks
    110                 for (Track t : ds.tracks) {
     108                // waies
     109                for (Way t : ds.waies) {
    111110                        if (t.isDeleted() && t.id == 0)
    112111                                continue;
    113112                        Element tElem = new Element("trk", GPX);
    114                         HashMap<Key, String> keys = null;
     113                        HashMap<String, String> keys = null;
    115114                        if (t.keys != null) {
    116                                 keys = new HashMap<Key, String>(t.keys);
     115                                keys = new HashMap<String, String>(t.keys);
    117116                                addAndRemovePropertyTag("name", tElem, keys);
    118117                                addAndRemovePropertyTag("cmt", tElem, keys);
     
    136135                }
    137136               
    138                 // encode pending line segments as tracks
     137                // encode pending line segments as waies
    139138                for (LineSegment ls : unrefLs) {
    140139                        if (ls.isDeleted() && ls.id == 0)
     
    198197                e.setAttribute("lat", Double.toString(n.coor.lat));
    199198                e.setAttribute("lon", Double.toString(n.coor.lon));
    200                 HashMap<Key, String> keys = null;
     199                HashMap<String, String> keys = null;
    201200                if (n.keys != null) {
    202                         keys = new HashMap<Key, String>(n.keys);
     201                        keys = new HashMap<String, String>(n.keys);
    203202                        addAndRemovePropertyTag("ele", e, keys);
    204203                        addAndRemovePropertyTag("time", e, keys);
     
    234233         */
    235234        @SuppressWarnings("unchecked")
    236         private void addAndRemovePropertyLinkTag(Element e, Map<Key, String> keys) {
    237                 Key key = Key.get("link");
    238                 String value = keys.get(key);
     235        private void addAndRemovePropertyLinkTag(Element e, Map<String, String> keys) {
     236                String value = keys.get("link");
    239237                if (value != null) {
    240238                        StringTokenizer st = new StringTokenizer(value, ";");
     
    245243                        link.getChildren().add(0,new Element("text", GPX).setText(st.nextToken()));
    246244                        e.getChildren().add(link);
    247                         keys.remove(key);
     245                        keys.remove("link");
    248246                }
    249247        }
     
    263261         */
    264262        @SuppressWarnings("unchecked")
    265         private void addAndRemovePropertyTag(String name, Element e, Map<Key, String> keys) {
    266                 Key key = Key.get(name);
    267                 String value = keys.get(key);
     263        private void addAndRemovePropertyTag(String name, Element e, Map<String, String> keys) {
     264                String value = keys.get(name);
    268265                if (value != null) {
    269266                        e.getChildren().add(new Element(name, GPX).setText(value));
    270                         keys.remove(key);
     267                        keys.remove(name);
    271268                }
    272269        }
     
    278275         */
    279276        @SuppressWarnings("unchecked")
    280         private void addPropertyExtensions(Element e, Map<Key, String> keys, OsmPrimitive osm) {
     277        private void addPropertyExtensions(Element e, Map<String, String> keys, OsmPrimitive osm) {
    281278                LinkedList<Element> extensions = new LinkedList<Element>();
    282279                if (keys != null && !keys.isEmpty()) {
    283                         for (Entry<Key, String> prop : keys.entrySet()) {
     280                        for (Entry<String, String> prop : keys.entrySet()) {
    284281                                Element propElement = new Element("property", OSM);
    285                                 propElement.setAttribute("key", prop.getKey().name);
     282                                propElement.setAttribute("key", prop.getKey());
    286283                                propElement.setAttribute("value", prop.getValue());
    287284                                extensions.add(propElement);
  • src/org/openstreetmap/josm/io/OsmReader.java

    r61 r64  
    88import org.openstreetmap.josm.data.GeoPoint;
    99import org.openstreetmap.josm.data.osm.DataSet;
    10 import org.openstreetmap.josm.data.osm.Key;
    1110import org.openstreetmap.josm.data.osm.LineSegment;
    1211import org.openstreetmap.josm.data.osm.Node;
    1312import org.openstreetmap.josm.data.osm.OsmPrimitive;
    14 import org.openstreetmap.josm.data.osm.Track;
     13import org.openstreetmap.josm.data.osm.Way;
    1514import org.openstreetmap.josm.data.osm.visitor.AddVisitor;
    1615import org.xml.sax.Attributes;
     
    9190                                lineSegments.put(current.id, (LineSegment)current);
    9291                        } else if (qName.equals("way")) {
    93                                 current = new Track();
     92                                current = new Way();
    9493                                readCommon(atts);
    9594                        } else if (qName.equals("seg")) {
    96                                 if (current instanceof Track) {
     95                                if (current instanceof Way) {
    9796                                        LineSegment ls = lineSegments.get(getLong(atts, "id"));
    9897                                        if (ls == null)
    9998                                                fatalError(new SAXParseException("Line segment "+getLong(atts, "id")+"has not been transfered before.", null));
    100                                         ((Track)current).segments.add(ls);
     99                                        ((Way)current).segments.add(ls);
    101100                                }
    102101                        } else if (qName.equals("tag")) {
    103                                 current.put(Key.get(atts.getValue("k")), atts.getValue("v"));
     102                                current.put(atts.getValue("k"), atts.getValue("v"));
    104103                        }
    105104                } catch (NumberFormatException x) {
  • src/org/openstreetmap/josm/io/OsmReaderOld.java

    r58 r64  
    1212import org.openstreetmap.josm.data.GeoPoint;
    1313import org.openstreetmap.josm.data.osm.DataSet;
    14 import org.openstreetmap.josm.data.osm.Key;
    1514import org.openstreetmap.josm.data.osm.LineSegment;
    1615import org.openstreetmap.josm.data.osm.Node;
    1716import org.openstreetmap.josm.data.osm.OsmPrimitive;
    18 import org.openstreetmap.josm.data.osm.Track;
     17import org.openstreetmap.josm.data.osm.Way;
    1918import org.openstreetmap.josm.data.osm.visitor.AddVisitor;
    2019
     
    8483                else if (e.getName().equals("segment"))
    8584                        return parseLineSegment(e, data);
    86                 else if (e.getName().equals("track"))
    87                         return parseTrack(e, data);
     85                else if (e.getName().equals("way"))
     86                        return parseWay(e, data);
    8887                else if (e.getName().equals("property")) {
    8988                        parseProperty(e, data);
     
    144143
    145144        /**
    146          * Parse and read a track from the element.
     145         * Parse and read a way from the element.
    147146         *
    148          * @param e             The element that contain the track.
     147         * @param e             The element that contain the way.
    149148         * @param data  The DataSet to get segment information from.
    150          * @return              The parsed track.
     149         * @return              The parsed way.
    151150         * @throws JDOMException In case of a parsing error.
    152151         */
    153         private Track parseTrack(Element e, DataSet data) throws JDOMException {
    154                 Track track = new Track();
    155                 parseCommon(track, e);
     152        private Way parseWay(Element e, DataSet data) throws JDOMException {
     153                Way way = new Way();
     154                parseCommon(way, e);
    156155                for (Object o : e.getChildren("segment")) {
    157156                        Element child = (Element)o;
    158157                        long id = Long.parseLong(child.getAttributeValue("uid"));
    159158                        LineSegment ls = findLineSegment(data.lineSegments, id);
    160                         track.segments.add(ls);
    161                 }
    162                 return track;
     159                        way.segments.add(ls);
     160                }
     161                return way;
    163162        }
    164163       
     
    176175                String propStr = e.getAttributeValue("tags");
    177176                if (propStr != null && !propStr.equals("")) {
    178                         data.keys = new HashMap<Key, String>();
     177                        data.keys = new HashMap<String, String>();
    179178                        StringTokenizer st = new StringTokenizer(propStr, ";");
    180179                        while (st.hasMoreTokens()) {
     
    184183                                int equalPos = next.indexOf('=');
    185184                                if (equalPos == -1)
    186                                         data.keys.put(Key.get(next), "");
     185                                        data.keys.put(next, "");
    187186                                else {
    188187                                        String keyStr = next.substring(0, equalPos);
    189                                         data.keys.put(Key.get(keyStr), next.substring(equalPos+1));
     188                                        data.keys.put(keyStr, next.substring(equalPos+1));
    190189                                }
    191190                        }
     
    209208                long id = Long.parseLong(e.getAttributeValue("uid"));
    210209                OsmPrimitive osm = findObject(data, id);
    211                 Key key = Key.get(e.getAttributeValue("key"));
     210                String key = e.getAttributeValue("key");
    212211                String value = e.getAttributeValue("value");
    213212                if (value != null) {
    214213                        if (osm.keys == null)
    215                                 osm.keys = new HashMap<Key, String>();
     214                                osm.keys = new HashMap<String, String>();
    216215                        osm.keys.put(key, value);
    217216                }
     
    228227                        if (osm.id == id)
    229228                                return osm;
    230                 for (OsmPrimitive osm : data.tracks)
     229                for (OsmPrimitive osm : data.waies)
    231230                        if (osm.id == id)
    232231                                return osm;
  • src/org/openstreetmap/josm/io/OsmServerReader.java

    r58 r64  
    4242
    4343        /**
    44          * Retrieve raw gps trackpoints from the server API.
     44         * Retrieve raw gps waypoints from the server API.
    4545         * @return A list of all primitives retrieved. Currently, the list of lists
    4646         *              contain only one list, since the server cannot distinguish between
    47          *              tracks.
     47         *              waies.
    4848         */
    4949        public Collection<Collection<GeoPoint>> parseRawGps() throws IOException, JDOMException {
    50                 String url = Main.pref.osmDataServer+"/0.3/trackpoints?bbox="+lon1+","+lat1+","+lon2+","+lat2+"&page=";
     50                String url = Main.pref.osmDataServer+"/0.3/waypoints?bbox="+lon1+","+lat1+","+lon2+","+lat2+"&page=";
    5151                Collection<Collection<GeoPoint>> data = new LinkedList<Collection<GeoPoint>>();
    5252                Collection<GeoPoint> list = new LinkedList<GeoPoint>();
     
    5757                                break;
    5858                        RawGpsReader gpsReader = new RawGpsReader(r);
    59                         Collection<Collection<GeoPoint>> allTracks = gpsReader.parse();
     59                        Collection<Collection<GeoPoint>> allWays = gpsReader.parse();
    6060                        boolean foundSomething = false;
    61                         for (Collection<GeoPoint> t : allTracks) {
     61                        for (Collection<GeoPoint> t : allWays) {
    6262                                if (!t.isEmpty()) {
    6363                                        foundSomething = true;
  • src/org/openstreetmap/josm/io/OsmServerWriter.java

    r63 r64  
    1717import org.jdom.JDOMException;
    1818import org.openstreetmap.josm.Main;
    19 import org.openstreetmap.josm.data.osm.Key;
    2019import org.openstreetmap.josm.data.osm.LineSegment;
    2120import org.openstreetmap.josm.data.osm.Node;
    2221import org.openstreetmap.josm.data.osm.OsmPrimitive;
    23 import org.openstreetmap.josm.data.osm.Track;
     22import org.openstreetmap.josm.data.osm.Way;
    2423import org.openstreetmap.josm.data.osm.visitor.Visitor;
    2524
     
    9695         * Upload a whole way with the complete line segment id list.
    9796         */
    98         public void visit(Track w) {
     97        public void visit(Way w) {
    9998                if (w.id == 0 && !w.isDeleted()) {
    10099                        setCredits(w);
     
    115114        private void setCredits(OsmPrimitive osm) {
    116115                if (osm.keys == null)
    117                         osm.keys = new HashMap<Key, String>();
    118                 osm.keys.put(Key.get("created_by"), "JOSM");
     116                        osm.keys = new HashMap<String, String>();
     117                osm.keys.put("created_by", "JOSM");
    119118        }
    120119
    121 
    122         public void visit(Key k) {
    123                 // not implemented in server
    124         }
    125120
    126121        /**
  • src/org/openstreetmap/josm/io/OsmWriter.java

    r61 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;
    1413import org.openstreetmap.josm.data.osm.visitor.Visitor;
    1514import org.xml.sax.SAXException;
     
    7372                for (LineSegment ls : ds.lineSegments)
    7473                        writer.visit(ls);
    75                 for (Track w : ds.tracks)
     74                for (Way w : ds.waies)
    7675                        writer.visit(w);
    7776                writer.out.println("</osm>");
     
    110109        }
    111110
    112         public void visit(Track w) {
     111        public void visit(Way w) {
    113112                addCommon(w, "way");
    114113                out.println(">");
     
    116115                        out.println("    <seg id='"+getUsedId(ls)+"' />");
    117116                addTags(w, "way", false);
    118         }
    119 
    120         public void visit(Key k) {
    121117        }
    122118
     
    138134                        if (tagOpen)
    139135                                out.println(">");
    140                         for (Entry<Key, String> e : osm.keys.entrySet())
    141                                 out.println("    <tag k='"+ encode(e.getKey().name) +
     136                        for (Entry<String, String> e : osm.keys.entrySet())
     137                                out.println("    <tag k='"+ encode(e.getKey()) +
    142138                                                "' v='"+encode(e.getValue())+ "' />");
    143139                        out.println("  </" + tagname + ">");
  • src/org/openstreetmap/josm/io/RawGpsReader.java

    r44 r64  
    1414
    1515/**
    16  * Read raw gps data from a gpx file. Only track points with their tracks segments
     16 * Read raw gps data from a gpx file. Only way points with their waies segments
    1717 * and waypoints are imported.
    1818 * @author imi
     
    9696
    9797        /**
    98          * Parse the list of trackpoint - elements and return a collection with the
     98         * Parse the list of waypoint - elements and return a collection with the
    9999         * points read.
    100100         */
Note: See TracChangeset for help on using the changeset viewer.