Changeset 64 in josm for src/org/openstreetmap/josm/data
- Timestamp:
- 2006-03-16T19:35:44+01:00 (18 years ago)
- Location:
- src/org/openstreetmap/josm/data
- Files:
-
- 1 deleted
- 14 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/data/Preferences.java
r58 r64 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 track segments of this trackmust 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 several tracksegments 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 track segments in this track16 * 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 ( Track t : 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 ( Track t : 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 ( Track t : 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 ( Track t : 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 }
Note:
See TracChangeset
for help on using the changeset viewer.