- Timestamp:
- 2006-03-22T19:13:05+01:00 (18 years ago)
- Location:
- src/org/openstreetmap/josm
- Files:
-
- 1 deleted
- 28 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/actions/DownloadAction.java
r61 r66 207 207 } 208 208 b.name = JOptionPane.showInputDialog(Main.main, "Please enter a name for the location."); 209 if ( !b.name.equals("")) {209 if (b.name != null && !b.name.equals("")) { 210 210 ((DefaultListModel)bookmarks.getModel()).addElement(b); 211 211 bookmarks.save(); … … 245 245 246 246 /** 247 * Read the values from the edit fields and startthe download.247 * Read the values from the edit fields and from the download. 248 248 */ 249 249 private DownloadStatus startDownload() { -
src/org/openstreetmap/josm/actions/mapmode/AddLineSegmentAction.java
r39 r66 72 72 73 73 /** 74 * If user clicked on a node, startthe dragging with that node.74 * If user clicked on a node, from the dragging with that node. 75 75 */ 76 76 @Override … … 138 138 // try to find a line segment 139 139 for (LineSegment ls : Main.main.ds.lineSegments) 140 if ((start == ls. start && end == ls.end) || (end == ls.start && start == ls.end))140 if ((start == ls.from && end == ls.to) || (end == ls.from && start == ls.to)) 141 141 return; // already a line segment here - be happy, do nothing. 142 142 -
src/org/openstreetmap/josm/actions/mapmode/AddNodeAction.java
r40 r66 50 50 public void mouseClicked(MouseEvent e) { 51 51 if (e.getButton() == MouseEvent.BUTTON1) { 52 Node node = new Node(); 53 node.coor = mv.getPoint(e.getX(), e.getY(), true); 52 Node node = new Node(mv.getPoint(e.getX(), e.getY(), true)); 54 53 if (node.coor.isOutSideWorld()) { 55 54 JOptionPane.showMessageDialog(Main.main, "Can not add a node outside of the world."); -
src/org/openstreetmap/josm/actions/mapmode/AddWayAction.java
r64 r66 88 88 // 0 if no elements in list, quit 89 89 // 1 taking the first ls as pivot, remove it from list 90 // 2 searching for a connection at start or endof pivot90 // 2 searching for a connection at from or to of pivot 91 91 // 3 if found, attach it, remove it from list, goto 2 92 92 // 4 if not found, save the pivot-string and goto 0 … … 100 100 for (Iterator<LineSegment> it = lineSegments.iterator(); it.hasNext();) { 101 101 LineSegment ls = it.next(); 102 if (ls.start == pivotList.getLast().end) { 102 if (ls.incomplete) 103 continue; // incomplete segments are never added to a new way 104 if (ls.from == pivotList.getLast().to) { 103 105 pivotList.addLast(ls); 104 106 it.remove(); 105 107 found = true; 106 } else if (ls. end == pivotList.getFirst().start) {108 } else if (ls.to == pivotList.getFirst().from) { 107 109 pivotList.addFirst(ls); 108 110 it.remove(); … … 115 117 116 118 Way t = new Way(); 117 for (LineSegment ls : sortedLineSegments) 118 t.segments.add(ls); 119 t.segments.addAll(sortedLineSegments); 119 120 mv.editLayer().add(new AddCommand(Main.main.ds, t)); 120 121 Main.main.ds.clearSelection(); -
src/org/openstreetmap/josm/command/ChangeKeyValueCommand.java
r64 r66 59 59 60 60 if (value == null) { 61 for (OsmPrimitive osm : objects) { 62 if (osm.keys != null) { 63 osm.keys.remove(key); 64 if (osm.keys.isEmpty()) 65 osm.keys = null; 66 } 67 } 61 for (OsmPrimitive osm : objects) 62 osm.remove(key); 68 63 } else { 69 for (OsmPrimitive osm : objects) { 70 if (osm.keys == null) 71 osm.keys = new HashMap<String, String>(); 72 osm.keys.put(key, value); 73 } 64 for (OsmPrimitive osm : objects) 65 osm.put(key, value); 74 66 } 75 67 } -
src/org/openstreetmap/josm/data/osm/LineSegment.java
r64 r66 6 6 7 7 /** 8 * One way line segment consisting of a pair of nodes ( start/end)8 * One way line segment consisting of a pair of nodes (from/to) 9 9 * 10 10 * @author imi … … 15 15 * The starting node of the line segment 16 16 */ 17 public Node start;17 public Node from; 18 18 19 19 /** 20 20 * The ending node of the line segment 21 21 */ 22 public Node end; 22 public Node to; 23 24 /** 25 * If set to true, this object is incomplete, which means only the id 26 * and type is known (type is the objects instance class) 27 */ 28 public boolean incomplete; 23 29 24 30 /** 25 31 * Create an line segment from the given starting and ending node 26 * @param startStarting node of the line segment.27 * @param endEnding node of the line segment.32 * @param from Starting node of the line segment. 33 * @param to Ending node of the line segment. 28 34 */ 29 public LineSegment(Node start, Node end) { 30 this.start = start; 31 this.end = end; 35 public LineSegment(Node from, Node to) { 36 this.from = from; 37 this.to = to; 38 incomplete = false; 39 } 40 41 public LineSegment(long id) { 42 this.id = id; 43 incomplete = true; 32 44 } 33 45 … … 44 56 if (equals(ls)) 45 57 return true; 46 GeoPoint s1 = start.coor; 47 GeoPoint s2 = ls.start.coor; 48 GeoPoint e1 = end.coor; 49 GeoPoint e2 = ls.end.coor; 58 if (incomplete || ls.incomplete) 59 return false; 60 GeoPoint s1 = from.coor; 61 GeoPoint s2 = ls.from.coor; 62 GeoPoint e1 = to.coor; 63 GeoPoint e2 = ls.to.coor; 50 64 return ((s1.equalsLatLon(s2) && e1.equalsLatLon(e2)) || 51 65 (s1.equalsLatLon(e2) && e1.equalsLatLon(s2))); 52 66 } 67 68 @Override 69 public String toString() { 70 String s = "{LineSegment id="+id; 71 if (incomplete) 72 return s+",incomplete}"; 73 return s+",from="+from+",to="+to+"}"; 74 } 75 76 @Override 77 public void cloneFrom(OsmPrimitive osm) { 78 super.cloneFrom(osm); 79 LineSegment ls = ((LineSegment)osm); 80 from = ls.from; 81 to = ls.to; 82 incomplete = ls.incomplete; 83 } 53 84 } -
src/org/openstreetmap/josm/data/osm/Node.java
r23 r66 17 17 public GeoPoint coor; 18 18 19 public Node(GeoPoint coor) { 20 this.coor = coor; 21 } 22 19 23 @Override 20 24 public void visit(Visitor visitor) { 21 25 visitor.visit(this); 22 26 } 27 28 @Override 29 public String toString() { 30 return "{Node id="+id+",lat="+coor.lat+",lon="+coor.lon+"}"; 31 } 32 33 @Override 34 public void cloneFrom(OsmPrimitive osm) { 35 super.cloneFrom(osm); 36 GeoPoint g = ((Node)osm).coor; 37 coor = new GeoPoint(g.lat, g.lon, g.x, g.y); //TODO: Make GeoPoint immutable! 38 } 23 39 } -
src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
r64 r66 1 1 package org.openstreetmap.josm.data.osm; 2 2 3 import java.util.Collection; 4 import java.util.Collections; 3 5 import java.util.HashMap; 4 6 import java.util.Map; 7 import java.util.Map.Entry; 5 8 6 9 import org.openstreetmap.josm.Main; … … 64 67 */ 65 68 abstract public void visit(Visitor visitor); 66 69 67 70 /** 68 71 * Return <code>true</code>, if either <code>this.keys</code> and … … 119 122 * Equal, if the id (and class) is equal. If both ids are 0, use the super classes 120 123 * equal instead. 124 * 125 * An primitive is equal to its incomplete counter part. 121 126 */ 122 127 @Override … … 129 134 /** 130 135 * Return the id as hashcode or supers hashcode if 0. 136 * 137 * An primitive has the same hashcode as its incomplete counter part. 131 138 */ 132 139 @Override … … 145 152 keys.put(key, value); 146 153 } 154 /** 155 * Remove the given key from the list. 156 */ 157 public void remove(String key) { 158 if (keys != null) { 159 keys.remove(key); 160 if (keys.isEmpty()) 161 keys = null; 162 } 163 } 164 165 public String get(String key) { 166 return keys == null ? null : keys.get(key); 167 } 147 168 148 public String get(String key) { 149 return (keys == null) ? null : keys.get(key); 169 public Collection<Entry<String, String>> entrySet() { 170 if (keys == null) 171 return Collections.emptyList(); 172 return keys.entrySet(); 173 } 174 175 public Collection<String> keySet() { 176 if (keys == null) 177 return Collections.emptyList(); 178 return keys.keySet(); 179 } 180 181 /** 182 * Get and write all attributes from the parameter. Does not fire any listener, so 183 * use this only in the data initializing phase 184 */ 185 public void cloneFrom(OsmPrimitive osm) { 186 keys = osm.keys; 187 id = osm.id; 188 modified = osm.modified; 189 modifiedProperties = osm.modifiedProperties; 190 deleted = osm.deleted; 191 selected = osm.selected; 150 192 } 151 193 } -
src/org/openstreetmap/josm/data/osm/Way.java
r64 r66 18 18 public final List<LineSegment> segments = new ArrayList<LineSegment>(); 19 19 20 21 /**22 * Return the last node in the way. This is the node, which no line segment23 * has as start, but at least one has it as end. If there are not exact one24 * such nodes found, <code>null</code> is returned.25 *26 * TODO Currently does return just the end node in the list.27 *28 * @return The ending node, if there is one.29 */30 public Node getEndingNode() {31 if (segments.isEmpty())32 return null;33 return segments.get(segments.size()-1).end;34 }35 36 /**37 * Return the last segment.38 * @see #getEndingNode()39 */40 public LineSegment getEndingSegment() {41 if (segments.isEmpty())42 return null;43 return segments.get(segments.size()-1);44 }45 46 /**47 * Return the first node in the way. This is the node, which no line segment48 * has as end, but at least one as starting node. If there are not exact one49 * such nodes found, <code>null</code> is returned.50 *51 * TODO Currently does return just the first node in the list.52 *53 * @return The starting node, if there is one.54 */55 public Node getStartingNode() {56 if (segments.isEmpty())57 return null;58 return segments.get(0).start;59 }60 61 /**62 * Return the first segment.63 * @see #getStartingNode()64 */65 public LineSegment getStartingSegment() {66 if (segments.isEmpty())67 return null;68 return segments.get(0);69 }70 71 20 @Override 72 21 public void visit(Visitor visitor) { 73 22 visitor.visit(this); 74 23 } 24 25 @Override 26 public void cloneFrom(OsmPrimitive osm) { 27 super.cloneFrom(osm); 28 segments.clear(); 29 segments.addAll(((Way)osm).segments); 30 } 75 31 } -
src/org/openstreetmap/josm/data/osm/visitor/AllNodesVisitor.java
r64 r66 29 29 30 30 /** 31 * Line segments have exactly two nodes: start and end.31 * Line segments have exactly two nodes: from and to. 32 32 */ 33 33 public void visit(LineSegment ls) { 34 nodes.add(ls.start); 35 nodes.add(ls.end); 34 if (!ls.incomplete) { 35 visit(ls.from); 36 visit(ls.to); 37 } 36 38 } 37 39 … … 40 42 */ 41 43 public void visit(Way t) { 42 for (LineSegment ls : t.segments) { 43 nodes.add(ls.start); 44 nodes.add(ls.end); 45 } 44 for (LineSegment ls : t.segments) 45 visit(ls); 46 46 } 47 47 -
src/org/openstreetmap/josm/data/osm/visitor/BoundingVisitor.java
r64 r66 48 48 49 49 public void visit(LineSegment ls) { 50 visit(ls.start); 51 visit(ls.end); 50 if (!ls.incomplete) { 51 visit(ls.from); 52 visit(ls.to); 53 } 52 54 } 53 55 -
src/org/openstreetmap/josm/data/osm/visitor/CollectBackReferencesVisitor.java
r64 r66 41 41 continue; 42 42 for (LineSegment ls : t.segments) { 43 if (ls.start == n || ls.end == n) { 43 if (ls.incomplete) 44 continue; 45 if (ls.from == n || ls.to == n) { 44 46 data.add(t); 45 47 break; … … 48 50 } 49 51 for (LineSegment ls : ds.lineSegments) { 50 if (ls.isDeleted() )52 if (ls.isDeleted() || ls.incomplete) 51 53 continue; 52 if (ls. start == n || ls.end== n)54 if (ls.from == n || ls.to == n) 53 55 data.add(ls); 54 56 } -
src/org/openstreetmap/josm/data/osm/visitor/MergeVisitor.java
r64 r66 79 79 if (myLs == null) 80 80 ds.lineSegments.add(otherLs); 81 else { 81 else if (myLs.incomplete && !otherLs.incomplete) { 82 mergedLineSegments.put(otherLs, myLs); 83 myLs.cloneFrom(otherLs); 84 } else if (!otherLs.incomplete) { 82 85 mergedLineSegments.put(otherLs, myLs); 83 86 mergeCommon(myLs, otherLs); 84 87 if (myLs.modified && !otherLs.modified) 85 88 return; 86 if (!match(myLs. start, otherLs.start)) {87 myLs. start = otherLs.start;89 if (!match(myLs.from, otherLs.from)) { 90 myLs.from = otherLs.from; 88 91 myLs.modified = otherLs.modified; 89 92 } 90 if (!match(myLs. end, otherLs.end)) {91 myLs. end = otherLs.end;93 if (!match(myLs.to, otherLs.to)) { 94 myLs.to = otherLs.to; 92 95 myLs.modified = otherLs.modified; 93 96 } … … 133 136 public void fixReferences() { 134 137 for (LineSegment ls : ds.lineSegments) { 135 if (mergedNodes.containsKey(ls. start))136 ls. start = mergedNodes.get(ls.start);137 if (mergedNodes.containsKey(ls. end))138 ls. end = mergedNodes.get(ls.end);138 if (mergedNodes.containsKey(ls.from)) 139 ls.from = mergedNodes.get(ls.from); 140 if (mergedNodes.containsKey(ls.to)) 141 ls.to = mergedNodes.get(ls.to); 139 142 } 140 143 for (Way t : ds.waies) { … … 152 155 } 153 156 for (LineSegment ls : t.segments) { 154 if (mergedNodes.containsKey(ls. start))155 ls. start = mergedNodes.get(ls.start);156 if (mergedNodes.containsKey(ls. end))157 ls. end = mergedNodes.get(ls.end);157 if (mergedNodes.containsKey(ls.from)) 158 ls.from = mergedNodes.get(ls.from); 159 if (mergedNodes.containsKey(ls.to)) 160 ls.to = mergedNodes.get(ls.to); 158 161 } 159 162 } … … 173 176 */ 174 177 private boolean match(LineSegment ls1, LineSegment ls2) { 175 if (ls1.id == 0 || ls2.id == 0) 176 return match(ls1.start, ls2.start) && match(ls1.end, ls2.end); 177 return ls1.id == ls2.id; 178 if (ls1.id == ls2.id) 179 return true; 180 if (ls1.incomplete || ls2.incomplete) 181 return false; 182 return match(ls1.from, ls2.from) && match(ls1.to, ls2.to); 178 183 } 179 184 -
src/org/openstreetmap/josm/data/osm/visitor/SelectionComponentVisitor.java
r64 r66 3 3 4 4 import java.util.HashSet; 5 import java.util.Map;6 5 import java.util.Set; 7 6 … … 36 35 */ 37 36 public void visit(LineSegment ls) { 38 String name = getName(ls.keys); 37 name = ls.get("name"); 38 if (name == null && ls.incomplete) 39 name = ""+ls.id; 39 40 if (name == null) 40 name = "("+ls.start.coor.lat+","+ls.start.coor.lon+") -> ("+ls.end.coor.lat+","+ls.end.coor.lon+")"; 41 42 this.name = name; 41 name = "("+ls.from.coor.lat+","+ls.from.coor.lon+") -> ("+ls.to.coor.lat+","+ls.to.coor.lon+")"; 43 42 icon = ImageProvider.get("data", "linesegment"); 44 43 } … … 49 48 */ 50 49 public void visit(Node n) { 51 String name = getName(n.keys);50 name = n.get("name"); 52 51 if (name == null) 53 52 name = "("+n.coor.lat+","+n.coor.lon+")"; 54 55 this.name = name;56 53 icon = ImageProvider.get("data", "node"); 57 54 } … … 61 58 * is displayed with x beeing the number of nodes in the way. 62 59 */ 63 public void visit(Way t) {64 String name = getName(t.keys);60 public void visit(Way w) { 61 name = w.get("name"); 65 62 if (name == null) { 66 63 Set<Node> nodes = new HashSet<Node>(); 67 for (LineSegment ls : t.segments) { 68 nodes.add(ls.start); 69 nodes.add(ls.end); 64 for (LineSegment ls : w.segments) { 65 if (!ls.incomplete) { 66 nodes.add(ls.from); 67 nodes.add(ls.to); 68 } 70 69 } 71 70 name = "("+nodes.size()+" nodes)"; 72 71 } 73 74 this.name = name;75 72 icon = ImageProvider.get("data", "way"); 76 73 } 77 78 79 /**80 * Try to read a name from the given properties.81 * @param keys The properties to search for a name. Can be <code>null</code>.82 * @return If a name could be found, return it here.83 */84 public String getName(Map<String, String> keys) {85 String name = null;86 if (keys != null) {87 name = keys.get("name");88 if (name == null)89 name = keys.get("id");90 }91 return name;92 }93 94 74 } -
src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java
r64 r66 18 18 public class SimplePaintVisitor implements Visitor { 19 19 20 private final static Color darkerblue = new Color(0,0,96); 20 21 private final static Color darkblue = new Color(0,0,128); 21 22 private final static Color darkgreen = new Color(0,128,0); … … 64 65 public void visit(Way t) { 65 66 // only to overwrite with blue 67 Color wayColor = darkblue; 68 for (LineSegment ls : t.segments) { 69 if (ls.incomplete) { 70 wayColor = darkerblue; 71 break; 72 } 73 } 66 74 for (LineSegment ls : t.segments) 67 75 if (!ls.isSelected()) // selected already in good color 68 drawLineSegment(ls, t.isSelected() ? Color.WHITE : darkblue);76 drawLineSegment(ls, t.isSelected() ? Color.WHITE : wayColor); 69 77 } 70 78 … … 85 93 */ 86 94 private void drawLineSegment(LineSegment ls, Color col) { 95 if (ls.incomplete) 96 return; 87 97 if (ls.isSelected()) 88 98 col = Color.WHITE; 89 99 g.setColor(col); 90 Point p1 = nc.getScreenPoint(ls. start.coor);91 Point p2 = nc.getScreenPoint(ls. end.coor);100 Point p1 = nc.getScreenPoint(ls.from.coor); 101 Point p2 = nc.getScreenPoint(ls.to.coor); 92 102 g.drawLine(p1.x, p1.y, p2.x, p2.y); 93 103 } -
src/org/openstreetmap/josm/data/osm/visitor/Visitor.java
r64 r66 14 14 void visit(Node n); 15 15 void visit(LineSegment ls); 16 void visit(Way t);16 void visit(Way w); 17 17 } -
src/org/openstreetmap/josm/gui/MapMover.java
r65 r66 83 83 * Start movement by setting a new cursor and remember the current mouse 84 84 * position. 85 * @param e The mouse event that leat to the movement start.85 * @param e The mouse event that leat to the movement from. 86 86 */ 87 87 private void startMovement(MouseEvent e) { -
src/org/openstreetmap/josm/gui/MapStatus.java
r64 r66 139 139 if (osm.id != 0) 140 140 text.append("<br>id="+osm.id); 141 if (osm.keys != null) 142 for (Entry<String, String> e : osm.keys.entrySet()) 143 text.append("<br>"+e.getKey()+"="+e.getValue()); 141 for (Entry<String, String> e : osm.entrySet()) 142 text.append("<br>"+e.getKey()+"="+e.getValue()); 144 143 final JLabel l = new JLabel("<html>"+text.toString()+"</html>", visitor.icon, JLabel.HORIZONTAL); 145 144 l.setFont(l.getFont().deriveFont(Font.PLAIN)); -
src/org/openstreetmap/josm/gui/NavigatableComponent.java
r65 r66 156 156 continue; 157 157 for (LineSegment ls : w.segments) { 158 if (ls.isDeleted() )158 if (ls.isDeleted() || ls.incomplete) 159 159 continue; 160 Point A = getScreenPoint(ls. start.coor);161 Point B = getScreenPoint(ls. end.coor);160 Point A = getScreenPoint(ls.from.coor); 161 Point B = getScreenPoint(ls.to.coor); 162 162 double c = A.distanceSq(B); 163 163 double a = p.distanceSq(B); … … 177 177 // line segments 178 178 for (LineSegment ls : Main.main.ds.lineSegments) { 179 if (ls.isDeleted() )179 if (ls.isDeleted() || ls.incomplete) 180 180 continue; 181 Point A = getScreenPoint(ls. start.coor);182 Point B = getScreenPoint(ls. end.coor);181 Point A = getScreenPoint(ls.from.coor); 182 Point B = getScreenPoint(ls.to.coor); 183 183 double c = A.distanceSq(B); 184 184 double a = p.distanceSq(B); … … 225 225 for (LineSegment ls : Main.main.ds.lineSegments) 226 226 // line segments never match nodes, so they are skipped by contains 227 if (!ls.isDeleted() && (c.contains(ls.start) || c.contains(ls.end)))227 if (!ls.isDeleted() && !ls.incomplete && (c.contains(ls.from) || c.contains(ls.to))) 228 228 c.add(ls); 229 229 } … … 239 239 continue; 240 240 for (LineSegment ls : t.segments) { 241 if (!ls.isDeleted() && c.contains(ls)) {241 if (!ls.isDeleted() && !ls.incomplete && c.contains(ls)) { 242 242 c.add(t); 243 243 break; -
src/org/openstreetmap/josm/gui/SelectionManager.java
r64 r66 135 135 136 136 /** 137 * If the correct button, startthe "drawing rectangle" mode137 * If the correct button, from the "drawing rectangle" mode 138 138 */ 139 139 public void mousePressed(MouseEvent e) { … … 309 309 */ 310 310 private boolean rectangleContainLineSegment(Rectangle r, boolean alt, LineSegment ls) { 311 if (ls.incomplete) 312 return false; 311 313 if (alt) { 312 Point p1 = nc.getScreenPoint(ls. start.coor);313 Point p2 = nc.getScreenPoint(ls. end.coor);314 Point p1 = nc.getScreenPoint(ls.from.coor); 315 Point p2 = nc.getScreenPoint(ls.to.coor); 314 316 if (r.intersectsLine(p1.x, p1.y, p2.x, p2.y)) 315 317 return true; 316 318 } else { 317 if (r.contains(nc.getScreenPoint(ls. start.coor))318 && r.contains(nc.getScreenPoint(ls. end.coor)))319 if (r.contains(nc.getScreenPoint(ls.from.coor)) 320 && r.contains(nc.getScreenPoint(ls.to.coor))) 319 321 return true; 320 322 } -
src/org/openstreetmap/josm/gui/dialogs/PropertiesDialog.java
r64 r66 14 14 import java.awt.event.WindowFocusListener; 15 15 import java.util.Collection; 16 import java.util.HashMap; 16 17 import java.util.Iterator; 18 import java.util.Map; 17 19 import java.util.TreeMap; 18 20 import java.util.TreeSet; … … 61 63 62 64 /** 63 * Watches for double clicks and startediting or new property, depending on the65 * Watches for double clicks and from editing or new property, depending on the 64 66 * location, the click was. 65 67 * @author imi … … 78 80 } 79 81 } 80 82 81 83 /** 82 84 * Edit the value in the table row … … 143 145 Vector<String> allKeys = new Vector<String>(); 144 146 for (OsmPrimitive osm : Main.main.ds.allNonDeletedPrimitives()) 145 if (osm.keys != null) 146 allKeys.addAll(osm.keys.keySet()); 147 allKeys.addAll(osm.keySet()); 147 148 for (Iterator<String> it = allKeys.iterator(); it.hasNext();) { 148 149 String s = it.next(); … … 293 294 propertyTable.getCellEditor().cancelCellEditing(); 294 295 data.setRowCount(0); 296 297 Map<String, Integer> valueCount = new HashMap<String, Integer>(); 295 298 TreeMap<String, Collection<String>> props = new TreeMap<String, Collection<String>>(); 296 299 for (OsmPrimitive osm : newSelection) { 297 if (osm.keys != null) { 298 for (Entry<String, String> e : osm.keys.entrySet()) { 299 Collection<String> value = props.get(e.getKey()); 300 if (value == null) { 301 value = new TreeSet<String>(); 302 props.put(e.getKey(), value); 303 } 304 value.add(e.getValue()); 300 for (Entry<String, String> e : osm.entrySet()) { 301 Collection<String> value = props.get(e.getKey()); 302 if (value == null) { 303 value = new TreeSet<String>(); 304 props.put(e.getKey(), value); 305 305 } 306 value.add(e.getValue()); 307 valueCount.put(e.getKey(), valueCount.containsKey(e.getKey()) ? valueCount.get(e.getKey())+1 : 1); 306 308 } 307 309 } … … 309 311 JComboBox value = new JComboBox(e.getValue().toArray()); 310 312 value.setEditable(true); 311 value.getEditor().setItem( e.getValue().size() > 1? "<different>" : e.getValue().iterator().next());313 value.getEditor().setItem(valueCount.get(e.getKey()) != newSelection.size() ? "<different>" : e.getValue().iterator().next()); 312 314 data.addRow(new Object[]{e.getKey(), value}); 313 315 } -
src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java
r64 r66 93 93 Main.main.ds.clearSelection(); 94 94 for (OsmPrimitive osm : Main.main.ds.allNonDeletedPrimitives()) { 95 if (osm.keys != null) { 96 for (Entry<String, String> ent : osm.keys.entrySet()) { 97 if (match(lastSearch, ent.getKey(), ent.getValue())) { 98 osm.setSelected(true); 99 break; 100 } 95 for (Entry<String, String> ent : osm.entrySet()) { 96 if (match(lastSearch, ent.getKey(), ent.getValue())) { 97 osm.setSelected(true); 98 break; 101 99 } 102 100 } -
src/org/openstreetmap/josm/io/GpxReader.java
r64 r66 73 73 */ 74 74 private Node parseWaypoint(Element e) { 75 Node data = new Node(); 76 data.coor = new GeoPoint( 75 Node data = new Node(new GeoPoint( 77 76 Double.parseDouble(e.getAttributeValue("lat")), 78 Double.parseDouble(e.getAttributeValue("lon"))) ;77 Double.parseDouble(e.getAttributeValue("lon")))); 79 78 80 79 for (Object o : e.getChildren()) { … … 200 199 if (e != null) { 201 200 for (Object o : e.getChildren("property", OSM)) { 202 if (osm.keys == null)203 osm.keys = new HashMap<String, String>();204 201 Element child = (Element)o; 205 202 String keyname = child.getAttributeValue("key"); … … 208 205 if (value == null) 209 206 value = ""; 210 osm. keys.put(keyname, value);207 osm.put(keyname, value); 211 208 } 212 209 } … … 251 248 private void parseKeyValueLink(OsmPrimitive osm, Element e) { 252 249 if (e != null) { 253 if (osm.keys == null)254 osm.keys = new HashMap<String, String>();255 250 String link = e.getChildText("type") + ";" + e.getChildText("text"); 256 osm. keys.put("link", link);251 osm.put("link", link); 257 252 } 258 253 } -
src/org/openstreetmap/josm/io/GpxWriter.java
r64 r66 127 127 for (LineSegment ls : t.segments) { 128 128 tElem.getChildren().add(parseLineSegment(ls)); 129 unrefNodes.remove(ls. start);130 unrefNodes.remove(ls. end);129 unrefNodes.remove(ls.from); 130 unrefNodes.remove(ls.to); 131 131 unrefLs.remove(ls); 132 132 } … … 141 141 Element t = new Element("trk", GPX); 142 142 t.getChildren().add(parseLineSegment(ls)); 143 unrefNodes.remove(ls. start);144 unrefNodes.remove(ls. end);143 unrefNodes.remove(ls.from); 144 unrefNodes.remove(ls.to); 145 145 Element ext = new Element("extensions", GPX); 146 146 ext.getChildren().add(new Element("segment", JOSM)); … … 180 180 Element lsElem = new Element("trkseg", GPX); 181 181 addPropertyExtensions(lsElem, ls.keys, ls); 182 lsElem.getChildren().add(parseWaypoint(ls. start, "trkpt"));183 lsElem.getChildren().add(parseWaypoint(ls. end, "trkpt"));182 lsElem.getChildren().add(parseWaypoint(ls.from, "trkpt")); 183 lsElem.getChildren().add(parseWaypoint(ls.to, "trkpt")); 184 184 return lsElem; 185 185 } -
src/org/openstreetmap/josm/io/OsmReader.java
r65 r66 15 15 import org.xml.sax.Attributes; 16 16 import org.xml.sax.SAXException; 17 import org.xml.sax.SAXParseException;18 17 19 18 import uk.co.wilson.xml.MinML2; … … 77 76 throw new SAXException("Unknown version: "+atts.getValue("version")); 78 77 } else if (qName.equals("node")) { 79 Node n = new Node(); 80 n.coor = new GeoPoint(getDouble(atts, "lat"), getDouble(atts, "lon")); 78 Node n = new Node(new GeoPoint(getDouble(atts, "lat"), getDouble(atts, "lon"))); 81 79 current = n; 82 80 readCommon(atts); … … 94 92 } else if (qName.equals("seg")) { 95 93 if (current instanceof Way) { 96 LineSegment ls = lineSegments.get(getLong(atts, "id")); 97 if (ls == null) 98 fatalError(new SAXParseException("Line segment "+getLong(atts, "id")+" has not been transfered before.", null)); 94 long id = getLong(atts, "id"); 95 LineSegment ls = lineSegments.get(id); 96 if (ls == null) { 97 ls = new LineSegment(id); // incomplete line segment 98 lineSegments.put(id, ls); 99 adder.visit(ls); 100 } 99 101 ((Way)current).segments.add(ls); 100 102 } -
src/org/openstreetmap/josm/io/OsmReaderOld.java
r64 r66 4 4 import java.io.Reader; 5 5 import java.util.Collection; 6 import java.util.HashMap;7 6 import java.util.StringTokenizer; 8 7 … … 63 62 */ 64 63 private Node parseNode(Element e) throws JDOMException { 65 Node data = new Node(); 66 data.coor = new GeoPoint( 64 Node data = new Node(new GeoPoint( 67 65 Double.parseDouble(e.getAttributeValue("lat")), 68 Double.parseDouble(e.getAttributeValue("lon"))) ;66 Double.parseDouble(e.getAttributeValue("lon")))); 69 67 if (Double.isNaN(data.coor.lat) || 70 68 data.coor.lat < -90 || data.coor.lat > 90 || … … 175 173 String propStr = e.getAttributeValue("tags"); 176 174 if (propStr != null && !propStr.equals("")) { 177 data.keys = new HashMap<String, String>();178 175 StringTokenizer st = new StringTokenizer(propStr, ";"); 179 176 while (st.hasMoreTokens()) { … … 183 180 int equalPos = next.indexOf('='); 184 181 if (equalPos == -1) 185 data. keys.put(next, "");182 data.put(next, ""); 186 183 else { 187 184 String keyStr = next.substring(0, equalPos); 188 data. keys.put(keyStr, next.substring(equalPos+1));185 data.put(keyStr, next.substring(equalPos+1)); 189 186 } 190 187 } … … 210 207 String key = e.getAttributeValue("key"); 211 208 String value = e.getAttributeValue("value"); 212 if (value != null) { 213 if (osm.keys == null) 214 osm.keys = new HashMap<String, String>(); 215 osm.keys.put(key, value); 216 } 209 if (value != null) 210 osm.put(key, value); 217 211 } 218 212 -
src/org/openstreetmap/josm/io/OsmServerWriter.java
r64 r66 12 12 import java.net.UnknownHostException; 13 13 import java.util.Collection; 14 import java.util.HashMap;15 14 import java.util.LinkedList; 16 15 … … 67 66 public void visit(Node n) { 68 67 if (n.id == 0 && !n.isDeleted()) { 69 setCredits(n);68 n.put("created_by", "JOSM"); 70 69 sendRequest("PUT", "node", n, true); 71 70 } else if (n.isDeleted()) { … … 82 81 public void visit(LineSegment ls) { 83 82 if (ls.id == 0 && !ls.isDeleted()) { 84 setCredits(ls);83 ls.put("created_by", "JOSM"); 85 84 sendRequest("PUT", "segment", ls, true); 86 85 } else if (ls.isDeleted()) { … … 97 96 public void visit(Way w) { 98 97 if (w.id == 0 && !w.isDeleted()) { 99 setCredits(w);98 w.put("created_by", "JOSM"); 100 99 sendRequest("PUT", "way", w, true); 101 100 } else if (w.isDeleted()) { … … 106 105 processed.add(w); 107 106 } 108 109 /**110 * Add the created_by - property to indicate that JOSM was the111 * creating application.112 * @param osm The primitive to add the credits to113 */114 private void setCredits(OsmPrimitive osm) {115 if (osm.keys == null)116 osm.keys = new HashMap<String, String>();117 osm.keys.put("created_by", "JOSM");118 }119 120 107 121 108 /** -
src/org/openstreetmap/josm/io/OsmWriter.java
r64 r66 104 104 105 105 public void visit(LineSegment ls) { 106 if (ls.incomplete) 107 throw new IllegalArgumentException("Cannot write an incomplete LineSegment."); 106 108 addCommon(ls, "segment"); 107 out.print(" from='"+getUsedId(ls. start)+"' to='"+getUsedId(ls.end)+"'");109 out.print(" from='"+getUsedId(ls.from)+"' to='"+getUsedId(ls.to)+"'"); 108 110 addTags(ls, "segment", true); 109 111 } … … 164 166 165 167 /** 166 * Add the common part as the startof the tag as well as the id or the action tag.168 * Add the common part as the from of the tag as well as the id or the action tag. 167 169 */ 168 170 private void addCommon(OsmPrimitive osm, String tagname) {
Note:
See TracChangeset
for help on using the changeset viewer.