Changeset 64 in josm for src/org/openstreetmap
- Timestamp:
- 2006-03-16T19:35:44+01:00 (19 years ago)
- 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 13 13 import org.openstreetmap.josm.data.osm.LineSegment; 14 14 import org.openstreetmap.josm.data.osm.OsmPrimitive; 15 import org.openstreetmap.josm.data.osm. Track;15 import org.openstreetmap.josm.data.osm.Way; 16 16 import org.openstreetmap.josm.gui.MapFrame; 17 17 18 18 /** 19 * Add a new trackfrom all selected line segments.19 * Add a new way from all selected line segments. 20 20 * 21 21 * 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. 23 23 * 24 * The user can click on a line segment. If he holds down Shift, no trackis25 * created yet. If he holds down Alt, the whole trackis considered instead of26 * the clicked line segment. If the user holds down Ctrl, no trackis created24 * 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 27 27 * and the clicked line segment get removed from the list. 28 28 * 29 29 * Also, the user may select a rectangle as in selection mode. No node, area or 30 * trackcan be selected this way.30 * way can be selected this way. 31 31 * 32 32 * @author imi … … 49 49 @Override 50 50 public void actionPerformed(ActionEvent e) { 51 make Track();51 makeWay(); 52 52 super.actionPerformed(e); 53 53 mapFrame.selectMapMode(followMode); … … 55 55 56 56 /** 57 * Just make a trackof all selected items.57 * Just make a way of all selected items. 58 58 */ 59 private void make Track() {59 private void makeWay() { 60 60 Collection<OsmPrimitive> selection = Main.main.ds.getSelected(); 61 61 if (selection.isEmpty()) 62 62 return; 63 63 64 // form a new track64 // form a new way 65 65 LinkedList<LineSegment> lineSegments = new LinkedList<LineSegment>(); 66 66 int numberOfSelectedWays = 0; 67 67 for (OsmPrimitive osm : selection) { 68 if (osm instanceof Track)68 if (osm instanceof Way) 69 69 numberOfSelectedWays++; 70 70 else if (osm instanceof LineSegment) … … 80 80 if (answer == JOptionPane.YES_OPTION) { 81 81 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); 84 84 } 85 85 } … … 114 114 } 115 115 116 Trackt = newTrack();116 Way t = new Way(); 117 117 for (LineSegment ls : sortedLineSegments) 118 118 t.segments.add(ls); -
src/org/openstreetmap/josm/actions/mapmode/DeleteAction.java
r32 r64 26 26 * @see #deleteWithReferences(OsmPrimitive) 27 27 * 28 * Pressing Alt will select the trackinstead of a line segment, as usual.28 * Pressing Alt will select the way instead of a line segment, as usual. 29 29 * 30 30 * If the user did not press Ctrl and the object has any references, the user … … 94 94 * Delete the primitives and everything they references. 95 95 * 96 * If a node is deleted, the node and all line segments, tracks and areas96 * If a node is deleted, the node and all line segments, waies and areas 97 97 * the node is part of are deleted as well. 98 98 * 99 * If a line segment is deleted, all tracks the line segment is part of99 * If a line segment is deleted, all waies the line segment is part of 100 100 * are deleted as well. No nodes are deleted. 101 101 * 102 * If a trackis deleted, only thetrackand no line segments or nodes are102 * If a way is deleted, only the way and no line segments or nodes are 103 103 * deleted. 104 104 * -
src/org/openstreetmap/josm/actions/mapmode/SelectionAction.java
r23 r64 27 27 * If Alt key was hold, select all objects that are touched by the 28 28 * 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 thetrackare29 * completly within (e.g. for waies mean: only if all nodes of the way are 30 30 * within). 31 31 * -
src/org/openstreetmap/josm/command/ChangeKeyValueCommand.java
r35 r64 8 8 import java.util.Map; 9 9 10 import org.openstreetmap.josm.data.osm.Key;11 10 import org.openstreetmap.josm.data.osm.OsmPrimitive; 12 11 … … 26 25 * The key that is subject to change. 27 26 */ 28 private final Keykey;27 private final String key; 29 28 /** 30 29 * The key value. If it is <code>null</code>, delete all key references with the given … … 37 36 * These are the old values of the objects to do a proper undo. 38 37 */ 39 private List<Map< Key, String>> oldProperties;38 private List<Map<String, String>> oldProperties; 40 39 41 40 /** … … 44 43 private List<Boolean> oldModified = new LinkedList<Boolean>(); 45 44 46 public ChangeKeyValueCommand(Collection<OsmPrimitive> objects, Keykey, String value) {45 public ChangeKeyValueCommand(Collection<OsmPrimitive> objects, String key, String value) { 47 46 this.objects = new LinkedList<OsmPrimitive>(objects); 48 47 this.key = key; … … 52 51 public void executeCommand() { 53 52 // save old 54 oldProperties = new LinkedList<Map< Key, String>>();53 oldProperties = new LinkedList<Map<String, String>>(); 55 54 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)); 57 56 oldModified.add(osm.modifiedProperties); 58 57 osm.modifiedProperties = true; … … 70 69 for (OsmPrimitive osm : objects) { 71 70 if (osm.keys == null) 72 osm.keys = new HashMap< Key, String>();71 osm.keys = new HashMap<String, String>(); 73 72 osm.keys.put(key, value); 74 73 } … … 77 76 78 77 public void undoCommand() { 79 Iterator<Map< Key, String>> it = oldProperties.iterator();78 Iterator<Map<String, String>> it = oldProperties.iterator(); 80 79 Iterator<Boolean> itMod = oldModified.iterator(); 81 80 for (OsmPrimitive osm : objects) { -
src/org/openstreetmap/josm/data/Preferences.java
r58 r64 42 42 43 43 /** 44 * Whether lines should be drawn between trackpoints of raw gps data.44 * Whether lines should be drawn between way points of raw gps data. 45 45 */ 46 46 private boolean drawRawGpsLines = false; -
src/org/openstreetmap/josm/data/osm/DataSet.java
r40 r64 21 21 22 22 /** 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). 24 24 * This enables the instant conversion of the whole DataSet by iterating over 25 25 * this data structure. … … 28 28 29 29 /** 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. 31 31 */ 32 32 public Collection<LineSegment> lineSegments = new LinkedList<LineSegment>(); 33 33 34 34 /** 35 * All tracks (Streets etc.) in the DataSet.35 * All waies (Streets etc.) in the DataSet. 36 36 * 37 * The nodes of the tracksegments of thistrackmust be objects from38 * the nodes list, however the tracksegments are stored only in the39 * tracklist.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. 40 40 */ 41 public Collection< Track> tracks = new LinkedList<Track>();41 public Collection<Way> waies = new LinkedList<Way>(); 42 42 43 43 /** … … 49 49 o.addAll(nodes); 50 50 o.addAll(lineSegments); 51 o.addAll( tracks);51 o.addAll(waies); 52 52 return o; 53 53 } … … 133 133 clearSelection(nodes); 134 134 clearSelection(lineSegments); 135 clearSelection( tracks);135 clearSelection(waies); 136 136 } 137 137 … … 144 144 Collection<OsmPrimitive> sel = getSelected(nodes); 145 145 sel.addAll(getSelected(lineSegments)); 146 sel.addAll(getSelected( tracks));146 sel.addAll(getSelected(waies)); 147 147 return sel; 148 148 } … … 155 155 if (list == null) 156 156 return; 157 for (OsmPrimitive osm : list) {157 for (OsmPrimitive osm : list) 158 158 osm.setSelected(false); 159 if (osm.keys != null)160 clearSelection(osm.keys.keySet());161 }162 159 } 163 160 … … 170 167 if (list == null) 171 168 return sel; 172 for (OsmPrimitive osm : list) {169 for (OsmPrimitive osm : list) 173 170 if (osm.isSelected() && !osm.isDeleted()) 174 171 sel.add(osm); 175 if (osm.keys != null)176 sel.addAll(getSelected(osm.keys.keySet()));177 }178 172 return sel; 179 173 } -
src/org/openstreetmap/josm/data/osm/LineSegment.java
r36 r64 6 6 7 7 /** 8 * One trackline segment consisting of a pair of nodes (start/end)8 * One way line segment consisting of a pair of nodes (start/end) 9 9 * 10 10 * @author imi -
src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
r61 r64 24 24 * The key/value list for this primitive. 25 25 */ 26 public Map< Key, String> keys;26 public Map<String, String> keys; 27 27 28 28 /** … … 78 78 79 79 if (keys != null) { 80 for ( Keyk : keys.keySet())80 for (String k : keys.keySet()) 81 81 if (other.keys.containsKey(k) && !keys.get(k).equals(other.keys.get(k))) 82 82 return false; 83 for ( Keyk : other.keys.keySet())83 for (String k : other.keys.keySet()) 84 84 if (keys.containsKey(k) && !other.keys.get(k).equals(keys.get(k))) 85 85 return false; … … 140 140 * @param value The value for the key. 141 141 */ 142 public void put( Keykey, String value) {142 public void put(String key, String value) { 143 143 if (keys == null) 144 keys = new HashMap< Key, String>();144 keys = new HashMap<String, String>(); 145 145 keys.put(key, value); 146 146 } 147 147 148 public String get( Keykey) {148 public String get(String key) { 149 149 return (keys == null) ? null : keys.get(key); 150 150 } -
src/org/openstreetmap/josm/data/osm/Way.java
r63 r64 7 7 8 8 /** 9 * One full track, consisting of severaltracksegments chained together.9 * One full way, consisting of several way segments chained together. 10 10 * 11 11 * @author imi 12 12 */ 13 public class Trackextends OsmPrimitive {13 public class Way extends OsmPrimitive { 14 14 15 15 /** 16 * All tracksegments in thistrack16 * All way segments in this way 17 17 */ 18 18 public final List<LineSegment> segments = new ArrayList<LineSegment>(); … … 20 20 21 21 /** 22 * Return the last node in the track. This is the node, which no line segment22 * Return the last node in the way. This is the node, which no line segment 23 23 * has as start, but at least one has it as end. If there are not exact one 24 24 * such nodes found, <code>null</code> is returned. … … 45 45 46 46 /** 47 * Return the first node in the track. This is the node, which no line segment47 * Return the first node in the way. This is the node, which no line segment 48 48 * has as end, but at least one as starting node. If there are not exact one 49 49 * such nodes found, <code>null</code> is returned. -
src/org/openstreetmap/josm/data/osm/visitor/AddVisitor.java
r40 r64 4 4 5 5 import org.openstreetmap.josm.data.osm.DataSet; 6 import org.openstreetmap.josm.data.osm.Key;7 6 import org.openstreetmap.josm.data.osm.LineSegment; 8 7 import org.openstreetmap.josm.data.osm.Node; 9 import org.openstreetmap.josm.data.osm. Track;8 import org.openstreetmap.josm.data.osm.Way; 10 9 11 10 /** … … 30 29 ds.lineSegments.add(ls); 31 30 } 32 public void visit( Trackt) {33 ds. tracks.add(t);31 public void visit(Way t) { 32 ds.waies.add(t); 34 33 } 35 public void visit(Key k) {}36 34 } -
src/org/openstreetmap/josm/data/osm/visitor/AllNodesVisitor.java
r23 r64 4 4 import java.util.HashSet; 5 5 6 import org.openstreetmap.josm.data.osm.Key;7 6 import org.openstreetmap.josm.data.osm.LineSegment; 8 7 import org.openstreetmap.josm.data.osm.Node; 9 8 import org.openstreetmap.josm.data.osm.OsmPrimitive; 10 import org.openstreetmap.josm.data.osm. Track;9 import org.openstreetmap.josm.data.osm.Way; 11 10 12 11 /** … … 38 37 39 38 /** 40 * Tracks have all nodes from their line segments.39 * Ways have all nodes from their line segments. 41 40 */ 42 public void visit( Trackt) {41 public void visit(Way t) { 43 42 for (LineSegment ls : t.segments) { 44 43 nodes.add(ls.start); 45 44 nodes.add(ls.end); 46 45 } 47 }48 49 /**50 * Keys have no nodes.51 */52 public void visit(Key k) {53 46 } 54 47 -
src/org/openstreetmap/josm/data/osm/visitor/BoundingVisitor.java
r35 r64 2 2 3 3 import org.openstreetmap.josm.data.Bounds; 4 import org.openstreetmap.josm.data.osm.Key;5 4 import org.openstreetmap.josm.data.osm.LineSegment; 6 5 import org.openstreetmap.josm.data.osm.Node; 7 import org.openstreetmap.josm.data.osm. Track;6 import org.openstreetmap.josm.data.osm.Way; 8 7 9 8 /** … … 53 52 } 54 53 55 public void visit( Trackt) {54 public void visit(Way t) { 56 55 for (LineSegment ls : t.segments) 57 56 visit(ls); 58 57 } 59 60 public void visit(Key k) {61 // do nothing62 }63 58 } 64 59 -
src/org/openstreetmap/josm/data/osm/visitor/CollectBackReferencesVisitor.java
r40 r64 5 5 6 6 import org.openstreetmap.josm.data.osm.DataSet; 7 import org.openstreetmap.josm.data.osm.Key;8 7 import org.openstreetmap.josm.data.osm.LineSegment; 9 8 import org.openstreetmap.josm.data.osm.Node; 10 9 import org.openstreetmap.josm.data.osm.OsmPrimitive; 11 import org.openstreetmap.josm.data.osm. Track;10 import org.openstreetmap.josm.data.osm.Way; 12 11 13 12 /** 14 * Helper that collect all line segments a node is part of, all tracks13 * Helper that collect all line segments a node is part of, all waies 15 14 * a node or line segment is part of and all areas a node is part of. 16 15 * … … 38 37 39 38 public void visit(Node n) { 40 for ( Trackt : ds.tracks) {39 for (Way t : ds.waies) { 41 40 if (t.isDeleted()) 42 41 continue; … … 56 55 } 57 56 public void visit(LineSegment ls) { 58 for ( Trackt : ds.tracks) {57 for (Way t : ds.waies) { 59 58 if (t.isDeleted()) 60 59 continue; … … 63 62 } 64 63 } 65 public void visit(Track t) {} 66 public void visit(Key k) {} 64 public void visit(Way t) {} 67 65 } -
src/org/openstreetmap/josm/data/osm/visitor/CsvVisitor.java
r30 r64 5 5 import java.util.Map.Entry; 6 6 7 import org.openstreetmap.josm.data.osm.Key;8 7 import org.openstreetmap.josm.data.osm.LineSegment; 9 8 import org.openstreetmap.josm.data.osm.Node; 10 9 import org.openstreetmap.josm.data.osm.OsmPrimitive; 11 import org.openstreetmap.josm.data.osm. Track;10 import org.openstreetmap.josm.data.osm.Way; 12 11 13 12 /** … … 38 37 } 39 38 40 public void visit( Trackt) {39 public void visit(Way t) { 41 40 out.print("t,"+common(t)+","+t.segments.size()); 42 41 for (LineSegment ls : t.segments) { … … 44 43 visit(ls); 45 44 } 46 }47 48 public void visit(Key k) {49 //TODO50 45 } 51 46 … … 60 55 if (osm.keys != null) { 61 56 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())); 64 59 } else 65 60 b.append(",0"); -
src/org/openstreetmap/josm/data/osm/visitor/DeleteVisitor.java
r40 r64 4 4 5 5 import org.openstreetmap.josm.data.osm.DataSet; 6 import org.openstreetmap.josm.data.osm.Key;7 6 import org.openstreetmap.josm.data.osm.LineSegment; 8 7 import org.openstreetmap.josm.data.osm.Node; 9 import org.openstreetmap.josm.data.osm. Track;8 import org.openstreetmap.josm.data.osm.Way; 10 9 11 10 /** … … 30 29 ds.lineSegments.remove(ls); 31 30 } 32 public void visit( Trackt) {33 ds. tracks.remove(t);31 public void visit(Way t) { 32 ds.waies.remove(t); 34 33 } 35 public void visit(Key k) {}36 34 } -
src/org/openstreetmap/josm/data/osm/visitor/MergeVisitor.java
r60 r64 7 7 8 8 import org.openstreetmap.josm.data.osm.DataSet; 9 import org.openstreetmap.josm.data.osm.Key;10 9 import org.openstreetmap.josm.data.osm.LineSegment; 11 10 import org.openstreetmap.josm.data.osm.Node; 12 11 import org.openstreetmap.josm.data.osm.OsmPrimitive; 13 import org.openstreetmap.josm.data.osm. Track;12 import org.openstreetmap.josm.data.osm.Way; 14 13 15 14 /** … … 97 96 98 97 /** 99 * Merge the trackif id matches or if all line segments matches and the100 * id is zero of either track.101 */ 102 public void visit( Track otherTrack) {103 Track myTrack= null;104 for ( Trackt : ds.tracks) {105 if (match(other Track, t)) {106 my Track= 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; 107 106 break; 108 107 } 109 108 } 110 if (my Track== null)111 ds. tracks.add(otherTrack);109 if (myWay == null) 110 ds.waies.add(otherWay); 112 111 else { 113 mergeCommon(my Track, otherTrack);114 if (my Track.modified && !otherTrack.modified)112 mergeCommon(myWay, otherWay); 113 if (myWay.modified && !otherWay.modified) 115 114 return; 116 115 boolean same = true; 117 Iterator<LineSegment> it = other Track.segments.iterator();118 for (LineSegment ls : my Track.segments) {116 Iterator<LineSegment> it = otherWay.segments.iterator(); 117 for (LineSegment ls : myWay.segments) { 119 118 if (!match(ls, it.next())) 120 119 same = false; 121 120 } 122 121 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 134 129 /** 135 130 * Postprocess the dataset and fix all merged references to point to the actual … … 143 138 ls.end = mergedNodes.get(ls.end); 144 139 } 145 for ( Trackt : ds.tracks) {140 for (Way t : ds.waies) { 146 141 boolean replacedSomething = false; 147 142 LinkedList<LineSegment> newSegments = new LinkedList<LineSegment>(); … … 184 179 185 180 /** 186 * @return Whether the tracks matches (in sense of "be mergable").187 */ 188 private boolean match( Track t1, Trackt2) {181 * @return Whether the waies matches (in sense of "be mergable"). 182 */ 183 private boolean match(Way t1, Way t2) { 189 184 if (t1.id == 0 || t2.id == 0) { 190 185 if (t1.segments.size() != t2.segments.size()) -
src/org/openstreetmap/josm/data/osm/visitor/SelectionComponentVisitor.java
r23 r64 8 8 import javax.swing.Icon; 9 9 10 import org.openstreetmap.josm.data.osm.Key;11 10 import org.openstreetmap.josm.data.osm.LineSegment; 12 11 import org.openstreetmap.josm.data.osm.Node; 13 import org.openstreetmap.josm.data.osm. Track;12 import org.openstreetmap.josm.data.osm.Way; 14 13 import org.openstreetmap.josm.gui.ImageProvider; 15 14 … … 31 30 32 31 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 41 32 /** 42 33 * If the line segment has a key named "name", its value is displayed. … … 67 58 68 59 /** 69 * If the trackhas 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. 71 62 */ 72 public void visit( Trackt) {63 public void visit(Way t) { 73 64 String name = getName(t.keys); 74 65 if (name == null) { … … 82 73 83 74 this.name = name; 84 icon = ImageProvider.get("data", " track");75 icon = ImageProvider.get("data", "way"); 85 76 } 86 77 … … 91 82 * @return If a name could be found, return it here. 92 83 */ 93 public String getName(Map< Key, String> keys) {84 public String getName(Map<String, String> keys) { 94 85 String name = null; 95 86 if (keys != null) { 96 name = keys.get( Key.get("name"));87 name = keys.get("name"); 97 88 if (name == null) 98 name = keys.get( Key.get("id"));89 name = keys.get("id"); 99 90 } 100 91 return name; -
src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java
r41 r64 5 5 import java.awt.Point; 6 6 7 import org.openstreetmap.josm.data.osm.Key;8 7 import org.openstreetmap.josm.data.osm.LineSegment; 9 8 import org.openstreetmap.josm.data.osm.Node; 10 import org.openstreetmap.josm.data.osm. Track;9 import org.openstreetmap.josm.data.osm.Way; 11 10 import org.openstreetmap.josm.gui.NavigatableComponent; 12 11 … … 61 60 /** 62 61 * Draw a darkblue line for all line segments. 63 * @param t The trackto draw.62 * @param t The way to draw. 64 63 */ 65 public void visit( Trackt) {64 public void visit(Way t) { 66 65 // only to overwrite with blue 67 66 for (LineSegment ls : t.segments) … … 70 69 } 71 70 72 /**73 * Do not draw a key.74 */75 public void visit(Key k) {76 }77 78 71 /** 79 72 * Draw the node as small rectangle with the given color. -
src/org/openstreetmap/josm/data/osm/visitor/Visitor.java
r21 r64 1 1 package org.openstreetmap.josm.data.osm.visitor; 2 2 3 import org.openstreetmap.josm.data.osm.Key;4 3 import org.openstreetmap.josm.data.osm.LineSegment; 5 4 import org.openstreetmap.josm.data.osm.Node; 6 import org.openstreetmap.josm.data.osm. Track;5 import org.openstreetmap.josm.data.osm.Way; 7 6 8 7 /** … … 15 14 void visit(Node n); 16 15 void visit(LineSegment ls); 17 void visit(Track t); 18 void visit(Key k); 16 void visit(Way t); 19 17 } -
src/org/openstreetmap/josm/gui/ImageProvider.java
r41 r64 43 43 subdir += "/"; 44 44 URL path = Main.class.getResource("/images/"+subdir+name+".png"); 45 if (path == null) 46 throw new NullPointerException("/images/"+subdir+name+".png not found"); 45 47 ImageIcon icon = cache.get(path); 46 48 if (icon == null) { -
src/org/openstreetmap/josm/gui/MapStatus.java
r56 r64 28 28 import org.openstreetmap.josm.Main; 29 29 import org.openstreetmap.josm.data.GeoPoint; 30 import org.openstreetmap.josm.data.osm.Key;31 30 import org.openstreetmap.josm.data.osm.OsmPrimitive; 32 31 import org.openstreetmap.josm.data.osm.visitor.SelectionComponentVisitor; … … 141 140 text.append("<br>id="+osm.id); 142 141 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()); 145 144 final JLabel l = new JLabel("<html>"+text.toString()+"</html>", visitor.icon, JLabel.HORIZONTAL); 146 145 l.setFont(l.getFont().deriveFont(Font.PLAIN)); -
src/org/openstreetmap/josm/gui/NavigatableComponent.java
r42 r64 12 12 import org.openstreetmap.josm.data.osm.Node; 13 13 import org.openstreetmap.josm.data.osm.OsmPrimitive; 14 import org.openstreetmap.josm.data.osm. Track;14 import org.openstreetmap.josm.data.osm.Way; 15 15 import org.openstreetmap.josm.data.projection.Projection; 16 16 … … 118 118 * If no such line segment is found, and a non-pending line segment is 119 119 * within 10 pixel to p, this segment is returned, except when 120 * <code>whole Track</code> is <code>true</code>, in which case the121 * corresponding Trackis returned.120 * <code>wholeWay</code> is <code>true</code>, in which case the 121 * corresponding Way is returned. 122 122 * 123 123 * If no line segment is found and the point is within an area, return that … … 127 127 * 128 128 * @param p The point on screen. 129 * @param lsInstead TrackWhether the line segment (true) or only the whole130 * trackshould be returned.129 * @param lsInsteadWay Whether the line segment (true) or only the whole 130 * way should be returned. 131 131 * @return The primitive, that is nearest to the point p. 132 132 */ 133 public OsmPrimitive getNearest(Point p, boolean lsInstead Track) {133 public OsmPrimitive getNearest(Point p, boolean lsInsteadWay) { 134 134 double minDistanceSq = Double.MAX_VALUE; 135 135 OsmPrimitive minPrimitive = null; … … 149 149 return minPrimitive; 150 150 151 // for whole tracks, try thetracks first151 // for whole waies, try the waies first 152 152 minDistanceSq = Double.MAX_VALUE; 153 if (!lsInstead Track) {154 for ( Trackt : Main.main.ds.tracks) {153 if (!lsInsteadWay) { 154 for (Way t : Main.main.ds.waies) { 155 155 if (t.isDeleted()) 156 156 continue; … … 201 201 * If its a node, return all line segments and 202 202 * streets the node is part of, as well as all nodes 203 * (with their line segments and tracks) with the same203 * (with their line segments and waies) with the same 204 204 * location. 205 205 * 206 * If its a line segment, return all tracks this segment206 * If its a line segment, return all waies this segment 207 207 * 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. 209 209 * 210 210 * @return A collection of all items or <code>null</code> … … 235 235 } 236 236 if (osm instanceof Node || osm instanceof LineSegment) { 237 for ( Trackt : Main.main.ds.tracks) {237 for (Way t : Main.main.ds.waies) { 238 238 if (t.isDeleted()) 239 239 continue; -
src/org/openstreetmap/josm/gui/PreferenceDialog.java
r43 r64 177 177 "An example: \"ignore ignore lat lon\" will use ' ' as delimiter, skip the first two values and read then lat/lon.<br>" + 178 178 "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."); 180 180 drawRawGpsLines.setSelected(Main.pref.isDrawRawGpsLines()); 181 181 forceRawGpsLines.setToolTipText("Force drawing of lines if the imported data contain no line information."); -
src/org/openstreetmap/josm/gui/SelectionManager.java
r42 r64 19 19 import org.openstreetmap.josm.data.osm.Node; 20 20 import org.openstreetmap.josm.data.osm.OsmPrimitive; 21 import org.openstreetmap.josm.data.osm. Track;21 import org.openstreetmap.josm.data.osm.Way; 22 22 23 23 /** … … 257 257 * @param alt Whether the alt key was pressed, which means select all objects 258 258 * 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. 260 260 */ 261 261 public Collection<OsmPrimitive> getObjectsInRectangle(Rectangle r, boolean alt) { … … 282 282 selection.add(ls); 283 283 284 // tracks285 for ( Trackt : Main.main.ds.tracks) {286 boolean whole TrackSelected = !t.segments.isEmpty();284 // waies 285 for (Way t : Main.main.ds.waies) { 286 boolean wholeWaySelected = !t.segments.isEmpty(); 287 287 for (LineSegment ls : t.segments) 288 288 if (rectangleContainLineSegment(r, alt, ls)) 289 289 selection.add(ls); 290 290 else 291 whole TrackSelected = false;292 if (whole TrackSelected)291 wholeWaySelected = false; 292 if (wholeWaySelected) 293 293 selection.add(t); 294 294 } -
src/org/openstreetmap/josm/gui/dialogs/PropertiesDialog.java
r62 r64 14 14 import java.awt.event.WindowFocusListener; 15 15 import java.util.Collection; 16 import java.util.HashMap;17 16 import java.util.Iterator; 18 17 import java.util.TreeMap; … … 37 36 import org.openstreetmap.josm.command.ChangeKeyValueCommand; 38 37 import org.openstreetmap.josm.data.SelectionChangedListener; 39 import org.openstreetmap.josm.data.osm.Key;40 38 import org.openstreetmap.josm.data.osm.OsmPrimitive; 41 39 import org.openstreetmap.josm.gui.ImageProvider; … … 125 123 if (value.equals("")) 126 124 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)); 128 126 129 127 if (value == null) … … 143 141 p.add(new JLabel("<html>This will change "+sel.size()+" object"+(sel.size()==1?"":"s")+".<br><br>"+ 144 142 "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()); 146 147 for (Iterator<String> it = allKeys.iterator(); it.hasNext();) { 147 148 String s = it.next(); … … 170 171 if (value.equals("")) 171 172 return; 172 mv.editLayer().add(new ChangeKeyValueCommand(sel, Key.get(key), value));173 mv.editLayer().add(new ChangeKeyValueCommand(sel, key, value)); 173 174 selectionChanged(sel); // update table 174 175 } … … 181 182 String key = data.getValueAt(row, 0).toString(); 182 183 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)); 184 185 selectionChanged(sel); // update table 185 186 } … … 293 294 data.setRowCount(0); 294 295 TreeMap<String, Collection<String>> props = new TreeMap<String, Collection<String>>(); 295 HashMap<String, Integer> valueCounts = new HashMap<String, Integer>();296 296 for (OsmPrimitive osm : newSelection) { 297 297 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()); 300 300 if (value == null) { 301 301 value = new TreeSet<String>(); 302 props.put(e.getKey() .name, value);302 props.put(e.getKey(), value); 303 303 } 304 304 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);310 305 } 311 306 } 312 307 } 313 int selCount = newSelection.size();314 308 for (Entry<String, Collection<String>> e : props.entrySet()) { 315 309 JComboBox value = new JComboBox(e.getValue().toArray()); 316 310 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()); 319 312 data.addRow(new Object[]{e.getKey(), value}); 320 313 } -
src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java
r62 r64 23 23 import org.openstreetmap.josm.Main; 24 24 import org.openstreetmap.josm.data.SelectionChangedListener; 25 import org.openstreetmap.josm.data.osm.Key;26 25 import org.openstreetmap.josm.data.osm.OsmPrimitive; 27 26 import org.openstreetmap.josm.gui.ImageProvider; … … 95 94 for (OsmPrimitive osm : Main.main.ds.allNonDeletedPrimitives()) { 96 95 if (osm.keys != null) { 97 for (Entry< Key, String> ent : osm.keys.entrySet()) {96 for (Entry<String, String> ent : osm.keys.entrySet()) { 98 97 if (match(lastSearch, ent.getKey(), ent.getValue())) { 99 98 osm.setSelected(true); … … 106 105 Main.main.getMapFrame().repaint(); 107 106 } 108 private boolean match(String search, Keykey, String value) {107 private boolean match(String search, String key, String value) { 109 108 int colon = search.indexOf(':'); 110 109 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; 113 112 } 114 113 }); -
src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
r57 r64 20 20 import org.openstreetmap.josm.data.osm.Node; 21 21 import org.openstreetmap.josm.data.osm.OsmPrimitive; 22 import org.openstreetmap.josm.data.osm. Track;22 import org.openstreetmap.josm.data.osm.Way; 23 23 import org.openstreetmap.josm.data.osm.visitor.BoundingVisitor; 24 24 import org.openstreetmap.josm.data.osm.visitor.MergeVisitor; … … 113 113 if (!osm.isDeleted()) 114 114 osm.visit(visitor); 115 for (OsmPrimitive osm : data. tracks)115 for (OsmPrimitive osm : data.waies) 116 116 if (!osm.isDeleted()) 117 117 osm.visit(visitor); … … 128 128 return undeletedSize(data.nodes)+" nodes, "+ 129 129 undeletedSize(data.lineSegments)+" segments, "+ 130 undeletedSize(data. tracks)+" streets.";130 undeletedSize(data.waies)+" streets."; 131 131 } 132 132 … … 238 238 for (Iterator<LineSegment> it = data.lineSegments.iterator(); it.hasNext();) 239 239 cleanIterator(it, processedSet); 240 for (Iterator< Track> it = data.tracks.iterator(); it.hasNext();)240 for (Iterator<Way> it = data.waies.iterator(); it.hasNext();) 241 241 cleanIterator(it, processedSet); 242 242 } -
src/org/openstreetmap/josm/gui/layer/RawGpsDataLayer.java
r38 r64 28 28 29 29 /** 30 * A list of tracks which containing a list of points.30 * A list of waies which containing a list of points. 31 31 */ 32 32 private final Collection<Collection<GeoPoint>> data; … … 78 78 @Override 79 79 public String getToolTipText() { 80 return data.size()+" tracks.";80 return data.size()+" waies."; 81 81 } 82 82 -
src/org/openstreetmap/josm/io/GpxReader.java
r49 r64 14 14 import org.openstreetmap.josm.data.GeoPoint; 15 15 import org.openstreetmap.josm.data.osm.DataSet; 16 import org.openstreetmap.josm.data.osm.Key;17 16 import org.openstreetmap.josm.data.osm.LineSegment; 18 17 import org.openstreetmap.josm.data.osm.Node; 19 18 import org.openstreetmap.josm.data.osm.OsmPrimitive; 20 import org.openstreetmap.josm.data.osm. Track;19 import org.openstreetmap.josm.data.osm.Way; 21 20 22 21 /** … … 99 98 private DataSet parseDataSet(Element e) { 100 99 DataSet data = new DataSet(); 101 // read waypoints not contained in tracks or areas100 // read waypoints not contained in waies or areas 102 101 for (Object o : e.getChildren("wpt", GPX)) { 103 102 Node node = parseWaypoint((Element)o); … … 105 104 } 106 105 107 // read tracks (and line segments)108 for (Object trackElement : e.getChildren("trk", GPX))109 parse Track((Element)trackElement, data);106 // read waies (and line segments) 107 for (Object wayElement : e.getChildren("trk", GPX)) 108 parseWay((Element)wayElement, data); 110 109 111 110 // reset new created ids to zero … … 118 117 119 118 /** 120 * Parse and read a trackfrom the element. Store it in the dataSet, as well119 * Parse and read a way from the element. Store it in the dataSet, as well 121 120 * as all nodes in it. 122 121 * 123 * @param e The element that contain the track.122 * @param e The element that contain the way. 124 123 * @param ds The DataSet to store the data in. 125 124 */ 126 private void parse Track(Element e, DataSet ds) {127 Track track= newTrack();128 boolean realLineSegment = false; // is this trackjust 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? 129 128 130 129 for (Object o : e.getChildren()) { … … 141 140 parseKeyValueExtensions(lineSegment, child.getChild("extensions", GPX)); 142 141 lineSegment = (LineSegment)getNewIfSeenBefore(lineSegment); 143 track.segments.add(lineSegment);142 way.segments.add(lineSegment); 144 143 start = node; 145 144 } 146 145 } 147 146 } else if (child.getName().equals("extensions")) { 148 parseKeyValueExtensions( track, child);147 parseKeyValueExtensions(way, child); 149 148 if (child.getChild("segment", JOSM) != null) 150 149 realLineSegment = true; 151 150 } else if (child.getName().equals("link")) 152 parseKeyValueLink( track, child);151 parseKeyValueLink(way, child); 153 152 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); 158 157 if (!realLineSegment) 159 ds. tracks.add(track);158 ds.waies.add(way); 160 159 } 161 160 … … 202 201 for (Object o : e.getChildren("property", OSM)) { 203 202 if (osm.keys == null) 204 osm.keys = new HashMap< Key, String>();203 osm.keys = new HashMap<String, String>(); 205 204 Element child = (Element)o; 206 205 String keyname = child.getAttributeValue("key"); 207 206 if (keyname != null) { 208 Key key = Key.get(keyname);209 207 String value = child.getAttributeValue("value"); 210 208 if (value == null) 211 209 value = ""; 212 osm.keys.put(key, value); 210 osm.keys.put(keyname, value); 213 211 } 214 212 } … … 235 233 */ 236 234 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()); 242 237 } 243 238 … … 257 252 if (e != null) { 258 253 if (osm.keys == null) 259 osm.keys = new HashMap< Key, String>();254 osm.keys = new HashMap<String, String>(); 260 255 String link = e.getChildText("type") + ";" + e.getChildText("text"); 261 osm.keys.put( Key.get("link"), link);256 osm.keys.put("link", link); 262 257 } 263 258 } -
src/org/openstreetmap/josm/io/GpxWriter.java
r49 r64 16 16 import org.jdom.output.XMLOutputter; 17 17 import org.openstreetmap.josm.data.osm.DataSet; 18 import org.openstreetmap.josm.data.osm.Key;19 18 import org.openstreetmap.josm.data.osm.LineSegment; 20 19 import org.openstreetmap.josm.data.osm.Node; 21 20 import org.openstreetmap.josm.data.osm.OsmPrimitive; 22 import org.openstreetmap.josm.data.osm. Track;21 import org.openstreetmap.josm.data.osm.Way; 23 22 24 23 /** … … 27 26 * <code><extensions></code> instead. 28 27 * 29 * GPX- Tracksegments are stored as 2-node-pairs, so no <trkseg> with more28 * GPX-Way segments are stored as 2-node-pairs, so no <trkseg> with more 30 29 * or less than 2 <trkpt> are exported. 31 30 * … … 107 106 LinkedList<LineSegment> unrefLs = new LinkedList<LineSegment>(ds.lineSegments); 108 107 109 // tracks110 for ( Trackt : ds.tracks) {108 // waies 109 for (Way t : ds.waies) { 111 110 if (t.isDeleted() && t.id == 0) 112 111 continue; 113 112 Element tElem = new Element("trk", GPX); 114 HashMap< Key, String> keys = null;113 HashMap<String, String> keys = null; 115 114 if (t.keys != null) { 116 keys = new HashMap< Key, String>(t.keys);115 keys = new HashMap<String, String>(t.keys); 117 116 addAndRemovePropertyTag("name", tElem, keys); 118 117 addAndRemovePropertyTag("cmt", tElem, keys); … … 136 135 } 137 136 138 // encode pending line segments as tracks137 // encode pending line segments as waies 139 138 for (LineSegment ls : unrefLs) { 140 139 if (ls.isDeleted() && ls.id == 0) … … 198 197 e.setAttribute("lat", Double.toString(n.coor.lat)); 199 198 e.setAttribute("lon", Double.toString(n.coor.lon)); 200 HashMap< Key, String> keys = null;199 HashMap<String, String> keys = null; 201 200 if (n.keys != null) { 202 keys = new HashMap< Key, String>(n.keys);201 keys = new HashMap<String, String>(n.keys); 203 202 addAndRemovePropertyTag("ele", e, keys); 204 203 addAndRemovePropertyTag("time", e, keys); … … 234 233 */ 235 234 @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"); 239 237 if (value != null) { 240 238 StringTokenizer st = new StringTokenizer(value, ";"); … … 245 243 link.getChildren().add(0,new Element("text", GPX).setText(st.nextToken())); 246 244 e.getChildren().add(link); 247 keys.remove( key);245 keys.remove("link"); 248 246 } 249 247 } … … 263 261 */ 264 262 @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); 268 265 if (value != null) { 269 266 e.getChildren().add(new Element(name, GPX).setText(value)); 270 keys.remove( key);267 keys.remove(name); 271 268 } 272 269 } … … 278 275 */ 279 276 @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) { 281 278 LinkedList<Element> extensions = new LinkedList<Element>(); 282 279 if (keys != null && !keys.isEmpty()) { 283 for (Entry< Key, String> prop : keys.entrySet()) {280 for (Entry<String, String> prop : keys.entrySet()) { 284 281 Element propElement = new Element("property", OSM); 285 propElement.setAttribute("key", prop.getKey() .name);282 propElement.setAttribute("key", prop.getKey()); 286 283 propElement.setAttribute("value", prop.getValue()); 287 284 extensions.add(propElement); -
src/org/openstreetmap/josm/io/OsmReader.java
r61 r64 8 8 import org.openstreetmap.josm.data.GeoPoint; 9 9 import org.openstreetmap.josm.data.osm.DataSet; 10 import org.openstreetmap.josm.data.osm.Key;11 10 import org.openstreetmap.josm.data.osm.LineSegment; 12 11 import org.openstreetmap.josm.data.osm.Node; 13 12 import org.openstreetmap.josm.data.osm.OsmPrimitive; 14 import org.openstreetmap.josm.data.osm. Track;13 import org.openstreetmap.josm.data.osm.Way; 15 14 import org.openstreetmap.josm.data.osm.visitor.AddVisitor; 16 15 import org.xml.sax.Attributes; … … 91 90 lineSegments.put(current.id, (LineSegment)current); 92 91 } else if (qName.equals("way")) { 93 current = new Track();92 current = new Way(); 94 93 readCommon(atts); 95 94 } else if (qName.equals("seg")) { 96 if (current instanceof Track) {95 if (current instanceof Way) { 97 96 LineSegment ls = lineSegments.get(getLong(atts, "id")); 98 97 if (ls == null) 99 98 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); 101 100 } 102 101 } 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")); 104 103 } 105 104 } catch (NumberFormatException x) { -
src/org/openstreetmap/josm/io/OsmReaderOld.java
r58 r64 12 12 import org.openstreetmap.josm.data.GeoPoint; 13 13 import org.openstreetmap.josm.data.osm.DataSet; 14 import org.openstreetmap.josm.data.osm.Key;15 14 import org.openstreetmap.josm.data.osm.LineSegment; 16 15 import org.openstreetmap.josm.data.osm.Node; 17 16 import org.openstreetmap.josm.data.osm.OsmPrimitive; 18 import org.openstreetmap.josm.data.osm. Track;17 import org.openstreetmap.josm.data.osm.Way; 19 18 import org.openstreetmap.josm.data.osm.visitor.AddVisitor; 20 19 … … 84 83 else if (e.getName().equals("segment")) 85 84 return parseLineSegment(e, data); 86 else if (e.getName().equals(" track"))87 return parse Track(e, data);85 else if (e.getName().equals("way")) 86 return parseWay(e, data); 88 87 else if (e.getName().equals("property")) { 89 88 parseProperty(e, data); … … 144 143 145 144 /** 146 * Parse and read a trackfrom the element.145 * Parse and read a way from the element. 147 146 * 148 * @param e The element that contain the track.147 * @param e The element that contain the way. 149 148 * @param data The DataSet to get segment information from. 150 * @return The parsed track.149 * @return The parsed way. 151 150 * @throws JDOMException In case of a parsing error. 152 151 */ 153 private Track parseTrack(Element e, DataSet data) throws JDOMException {154 Track track= newTrack();155 parseCommon( track, e);152 private Way parseWay(Element e, DataSet data) throws JDOMException { 153 Way way = new Way(); 154 parseCommon(way, e); 156 155 for (Object o : e.getChildren("segment")) { 157 156 Element child = (Element)o; 158 157 long id = Long.parseLong(child.getAttributeValue("uid")); 159 158 LineSegment ls = findLineSegment(data.lineSegments, id); 160 track.segments.add(ls);161 } 162 return track;159 way.segments.add(ls); 160 } 161 return way; 163 162 } 164 163 … … 176 175 String propStr = e.getAttributeValue("tags"); 177 176 if (propStr != null && !propStr.equals("")) { 178 data.keys = new HashMap< Key, String>();177 data.keys = new HashMap<String, String>(); 179 178 StringTokenizer st = new StringTokenizer(propStr, ";"); 180 179 while (st.hasMoreTokens()) { … … 184 183 int equalPos = next.indexOf('='); 185 184 if (equalPos == -1) 186 data.keys.put( Key.get(next), "");185 data.keys.put(next, ""); 187 186 else { 188 187 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)); 190 189 } 191 190 } … … 209 208 long id = Long.parseLong(e.getAttributeValue("uid")); 210 209 OsmPrimitive osm = findObject(data, id); 211 Keykey =Key.get(e.getAttributeValue("key"));210 String key = e.getAttributeValue("key"); 212 211 String value = e.getAttributeValue("value"); 213 212 if (value != null) { 214 213 if (osm.keys == null) 215 osm.keys = new HashMap< Key, String>();214 osm.keys = new HashMap<String, String>(); 216 215 osm.keys.put(key, value); 217 216 } … … 228 227 if (osm.id == id) 229 228 return osm; 230 for (OsmPrimitive osm : data. tracks)229 for (OsmPrimitive osm : data.waies) 231 230 if (osm.id == id) 232 231 return osm; -
src/org/openstreetmap/josm/io/OsmServerReader.java
r58 r64 42 42 43 43 /** 44 * Retrieve raw gps trackpoints from the server API.44 * Retrieve raw gps waypoints from the server API. 45 45 * @return A list of all primitives retrieved. Currently, the list of lists 46 46 * contain only one list, since the server cannot distinguish between 47 * tracks.47 * waies. 48 48 */ 49 49 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="; 51 51 Collection<Collection<GeoPoint>> data = new LinkedList<Collection<GeoPoint>>(); 52 52 Collection<GeoPoint> list = new LinkedList<GeoPoint>(); … … 57 57 break; 58 58 RawGpsReader gpsReader = new RawGpsReader(r); 59 Collection<Collection<GeoPoint>> all Tracks = gpsReader.parse();59 Collection<Collection<GeoPoint>> allWays = gpsReader.parse(); 60 60 boolean foundSomething = false; 61 for (Collection<GeoPoint> t : all Tracks) {61 for (Collection<GeoPoint> t : allWays) { 62 62 if (!t.isEmpty()) { 63 63 foundSomething = true; -
src/org/openstreetmap/josm/io/OsmServerWriter.java
r63 r64 17 17 import org.jdom.JDOMException; 18 18 import org.openstreetmap.josm.Main; 19 import org.openstreetmap.josm.data.osm.Key;20 19 import org.openstreetmap.josm.data.osm.LineSegment; 21 20 import org.openstreetmap.josm.data.osm.Node; 22 21 import org.openstreetmap.josm.data.osm.OsmPrimitive; 23 import org.openstreetmap.josm.data.osm. Track;22 import org.openstreetmap.josm.data.osm.Way; 24 23 import org.openstreetmap.josm.data.osm.visitor.Visitor; 25 24 … … 96 95 * Upload a whole way with the complete line segment id list. 97 96 */ 98 public void visit( Trackw) {97 public void visit(Way w) { 99 98 if (w.id == 0 && !w.isDeleted()) { 100 99 setCredits(w); … … 115 114 private void setCredits(OsmPrimitive osm) { 116 115 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"); 119 118 } 120 119 121 122 public void visit(Key k) {123 // not implemented in server124 }125 120 126 121 /** -
src/org/openstreetmap/josm/io/OsmWriter.java
r61 r64 7 7 8 8 import org.openstreetmap.josm.data.osm.DataSet; 9 import org.openstreetmap.josm.data.osm.Key;10 9 import org.openstreetmap.josm.data.osm.LineSegment; 11 10 import org.openstreetmap.josm.data.osm.Node; 12 11 import org.openstreetmap.josm.data.osm.OsmPrimitive; 13 import org.openstreetmap.josm.data.osm. Track;12 import org.openstreetmap.josm.data.osm.Way; 14 13 import org.openstreetmap.josm.data.osm.visitor.Visitor; 15 14 import org.xml.sax.SAXException; … … 73 72 for (LineSegment ls : ds.lineSegments) 74 73 writer.visit(ls); 75 for ( Trackw : ds.tracks)74 for (Way w : ds.waies) 76 75 writer.visit(w); 77 76 writer.out.println("</osm>"); … … 110 109 } 111 110 112 public void visit( Trackw) {111 public void visit(Way w) { 113 112 addCommon(w, "way"); 114 113 out.println(">"); … … 116 115 out.println(" <seg id='"+getUsedId(ls)+"' />"); 117 116 addTags(w, "way", false); 118 }119 120 public void visit(Key k) {121 117 } 122 118 … … 138 134 if (tagOpen) 139 135 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()) + 142 138 "' v='"+encode(e.getValue())+ "' />"); 143 139 out.println(" </" + tagname + ">"); -
src/org/openstreetmap/josm/io/RawGpsReader.java
r44 r64 14 14 15 15 /** 16 * Read raw gps data from a gpx file. Only trackpoints with theirtracks segments16 * Read raw gps data from a gpx file. Only way points with their waies segments 17 17 * and waypoints are imported. 18 18 * @author imi … … 96 96 97 97 /** 98 * Parse the list of trackpoint - elements and return a collection with the98 * Parse the list of waypoint - elements and return a collection with the 99 99 * points read. 100 100 */
Note:
See TracChangeset
for help on using the changeset viewer.