Changeset 1910 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2009-08-05T08:19:02+02:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/CreateCircleAction.java
r1862 r1910 6 6 import java.awt.event.ActionEvent; 7 7 import java.awt.event.KeyEvent; 8 import java.util.ArrayList; 8 9 import java.util.Collection; 9 10 import java.util.LinkedList; … … 134 135 135 136 // build a way for the circle 136 Way wayToAdd; 137 if (existingWay == null) { 138 wayToAdd = new Way(); 139 } else { 140 // re-use existing way if it was selected 141 wayToAdd = new Way(existingWay); 142 wayToAdd.nodes.clear(); 143 } 137 List<Node> wayToAdd = new ArrayList<Node>(); 144 138 145 139 for (int i = 1; i <= numberOfNodesInCircle; i++) { … … 148 142 // insert existing nodes if they fit before this new node (999 means "already added this node") 149 143 if ((a1 < 999) && (a1 > a - 1E-9) && (a1 < a + 1E-9)) { 150 wayToAdd. nodes.add(n1);144 wayToAdd.add(n1); 151 145 a1 = 999; 152 146 } 153 147 else if ((a2 < 999) && (a2 > a - 1E-9) && (a2 < a + 1E-9)) { 154 wayToAdd. nodes.add(n2);148 wayToAdd.add(n2); 155 149 a2 = 999; 156 150 } … … 160 154 double y = yc + r*Math.sin(a); 161 155 Node n = new Node(Main.proj.eastNorth2latlon(new EastNorth(x,y))); 162 wayToAdd. nodes.add(n);156 wayToAdd.add(n); 163 157 cmds.add(new AddCommand(n)); 164 158 } 165 159 } 166 wayToAdd. nodes.add(wayToAdd.nodes.get(0)); // close the circle160 wayToAdd.add(wayToAdd.get(0)); // close the circle 167 161 if (existingWay == null) { 168 cmds.add(new AddCommand(wayToAdd)); 162 Way newWay = new Way(); 163 newWay.setNodes(wayToAdd); 164 cmds.add(new AddCommand(newWay)); 169 165 } else { 170 cmds.add(new ChangeCommand(existingWay, wayToAdd)); 166 Way newWay = new Way(existingWay); 167 newWay.setNodes(wayToAdd); 168 cmds.add(new ChangeCommand(existingWay, newWay)); 171 169 } 172 170 … … 229 227 230 228 // build a way for the circle 231 Way wayToAdd; 232 if (existingWay == null) { 233 wayToAdd = new Way(); 234 } else { 235 // re-use existing way if it was selected 236 wayToAdd = new Way(existingWay); 237 wayToAdd.nodes.clear(); 238 } 229 List<Node> wayToAdd = new ArrayList<Node>(); 239 230 for (int i = 1; i <= numberOfNodesInCircle; i++) { 240 231 double a = 2*Math.PI*(1.0 - i/(double)numberOfNodesInCircle); // "1-" to get it clock-wise 241 232 // insert existing nodes if they fit before this new node (999 means "already added this node") 242 233 if (a1 < 999 && a1 > a) { 243 wayToAdd. nodes.add(n1);234 wayToAdd.add(n1); 244 235 a1 = 999; 245 236 } 246 237 if (a2 < 999 && a2 > a) { 247 wayToAdd. nodes.add(n2);238 wayToAdd.add(n2); 248 239 a2 = 999; 249 240 } 250 241 if (a3 < 999 && a3 > a) { 251 wayToAdd. nodes.add(n3);242 wayToAdd.add(n3); 252 243 a3 = 999; 253 244 } … … 256 247 double y = yc + r*Math.sin(a); 257 248 Node n = new Node(Main.proj.eastNorth2latlon(new EastNorth(x,y))); 258 wayToAdd. nodes.add(n);249 wayToAdd.add(n); 259 250 cmds.add(new AddCommand(n)); 260 251 } 261 wayToAdd. nodes.add(wayToAdd.nodes.get(0)); // close the circle252 wayToAdd.add(wayToAdd.get(0)); // close the circle 262 253 if (existingWay == null) { 263 cmds.add(new AddCommand(wayToAdd)); 254 Way newWay = new Way(); 255 newWay.setNodes(wayToAdd); 256 cmds.add(new AddCommand(newWay)); 264 257 } else { 265 cmds.add(new ChangeCommand(existingWay, wayToAdd)); 258 Way newWay = new Way(existingWay); 259 newWay.setNodes(wayToAdd); 260 cmds.add(new ChangeCommand(existingWay, newWay)); 266 261 } 267 262 -
trunk/src/org/openstreetmap/josm/actions/JoinNodeWayAction.java
r1862 r1910 59 59 for (Map.Entry<Way, List<Integer>> insertPoint : insertPoints.entrySet()) { 60 60 Way w = insertPoint.getKey(); 61 Way wnew = new Way(w);61 List<Node> nodesToAdd = new ArrayList<Node>(); 62 62 List<Integer> is = insertPoint.getValue(); 63 63 pruneSuccsAndReverse(is); 64 64 for (int i : is) { 65 wnew.nodes.add(i+1, node);65 nodesToAdd.add(i+1, node); 66 66 } 67 Way wnew = new Way(w); 68 wnew.setNodes(nodesToAdd); 67 69 cmds.add(new ChangeCommand(w, wnew)); 68 70 } -
trunk/src/org/openstreetmap/josm/command/PurgePrimitivesCommand.java
r1898 r1910 186 186 Way w = (Way)pair.getParent(); 187 187 System.out.println(tr("removing reference from way {0}",w.id)); 188 w.nodes.remove(primitive); 188 List<Node> wayNodes = w.getNodes(); 189 wayNodes.remove(primitive); 190 w.setNodes(wayNodes); 189 191 // if a way ends up with less than two node we 190 192 // remember it on the "hive" -
trunk/src/org/openstreetmap/josm/command/WayNodesConflictResolverCommand.java
r1766 r1910 37 37 38 38 /** 39 * 39 * 40 40 * @param my my may 41 41 * @param their their way … … 68 68 // nodes 69 69 // 70 conflict.getMy().nodes.clear(); 71 for (int i=0; i<mergedNodeList.size();i++) { 72 Node n = mergedNodeList.get(i); 73 conflict.getMy().nodes.add(n); 70 for (Node n:mergedNodeList) { 74 71 if (! getLayer().data.nodes.contains(n)) { 75 72 logger.warning(tr("Main dataset does not include node {0}", n.toString())); 76 73 } 77 74 } 75 conflict.getMy().setNodes(mergedNodeList); 78 76 rememberConflict(conflict); 79 77 return true; -
trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
r1899 r1910 372 372 373 373 protected void deleteWay(Way way) { 374 way. nodes.clear();374 way.setNodes(null); 375 375 way.delete(true); 376 376 } … … 383 383 public void unlinkNodeFromWays(Node node) { 384 384 for (Way way: ways) { 385 if (way.nodes.contains(node)) {386 way.nodes.remove(node);387 if ( way.nodes.size() < 2) {385 List<Node> nodes = way.getNodes(); 386 if (nodes.remove(node)) { 387 if (nodes.size() < 2) { 388 388 deleteWay(way); 389 } else { 390 way.setNodes(nodes); 389 391 } 390 392 } -
trunk/src/org/openstreetmap/josm/data/osm/Way.java
r1900 r1910 24 24 /** 25 25 * All way nodes in this way 26 * 26 * 27 27 * @deprecated This public field will become private or protected in the future. 28 28 * Use the new public API instead. … … 43 43 44 44 /** 45 * @param nodes 45 * @param nodes New way nodes. Can be null, in that case all way nodes are removed 46 46 * @since 1862 47 47 */ 48 48 public void setNodes(List<Node> nodes) { 49 49 this.nodes.clear(); 50 this.nodes.addAll(nodes); 50 if (nodes != null) { 51 this.nodes.addAll(nodes); 52 } 53 clearCached(); 51 54 } 52 55 -
trunk/src/org/openstreetmap/josm/data/osm/visitor/MergeSourceBuildingVisitor.java
r1898 r1910 136 136 return; 137 137 Way clone = new Way(w); 138 clone. nodes.clear();138 clone.setNodes(null); 139 139 clone.incomplete = true; 140 140 mappedPrimitives.put(w, clone); -
trunk/src/org/openstreetmap/josm/gui/SelectionManager.java
r1898 r1910 289 289 continue; 290 290 if (alt) { 291 for (Node n : w. nodes) {291 for (Node n : w.getNodes()) { 292 292 if (!n.incomplete && r.contains(nc.getPoint(n))) { 293 293 selection.add(w); … … 297 297 } else { 298 298 boolean allIn = true; 299 for (Node n : w. nodes) {299 for (Node n : w.getNodes()) { 300 300 if (!n.incomplete && !r.contains(nc.getPoint(n))) { 301 301 allIn = false; -
trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java
r1890 r1910 710 710 for (GpxTrack trk : data.tracks) { 711 711 for (Collection<WayPoint> segment : trk.trackSegs) { 712 Way w = new Way();712 List<Node> nodes = new ArrayList<Node>(); 713 713 for (WayPoint p : segment) { 714 714 Node n = new Node(p.getCoor()); … … 718 718 } 719 719 ds.nodes.add(n); 720 w.nodes.add(n); 721 } 720 nodes.add(n); 721 } 722 Way w = new Way(); 723 w.setNodes(nodes); 722 724 ds.ways.add(w); 723 725 } … … 741 743 /** 742 744 * Action that issues a series of download requests to the API, following the GPX track. 743 * 745 * 744 746 * @author fred 745 747 */ … … 842 844 * can only download rectangles, so the following is an attempt at finding a number of 843 845 * rectangles to download. 844 * 846 * 845 847 * The idea is simply: Start out with the full bounding box. If it is too large, then 846 848 * split it in half and repeat recursively for each half until you arrive at something … … 1141 1143 * Makes a WayPoint at the projection of point P onto the track providing P is less than 1142 1144 * tolerance away from the track 1143 * 1145 * 1144 1146 * @param P : the point to determine the projection for 1145 1147 * @param tolerance : must be no further than this from the track … … 1151 1153 * assume the coordinates of P are xp,yp, and those of a section of track between two 1152 1154 * trackpoints are R=xr,yr and S=xs,ys. Let N be the projected point. 1153 * 1155 * 1154 1156 * The equation of RS is Ax + By + C = 0 where A = ys - yr B = xr - xs C = - Axr - Byr 1155 * 1157 * 1156 1158 * Also, note that the distance RS^2 is A^2 + B^2 1157 * 1159 * 1158 1160 * If RS^2 == 0.0 ignore the degenerate section of track 1159 * 1161 * 1160 1162 * PN^2 = (Axp + Byp + C)^2 / RS^2 that is the distance from P to the line 1161 * 1163 * 1162 1164 * so if PN^2 is less than PNmin^2 (initialized to tolerance) we can reject the line; 1163 1165 * otherwise... determine if the projected poijnt lies within the bounds of the line: PR^2 - 1164 1166 * PN^2 <= RS^2 and PS^2 - PN^2 <= RS^2 1165 * 1167 * 1166 1168 * where PR^2 = (xp - xr)^2 + (yp-yr)^2 and PS^2 = (xp - xs)^2 + (yp-ys)^2 1167 * 1169 * 1168 1170 * If so, calculate N as xn = xr + (RN/RS) B yn = y1 + (RN/RS) A 1169 * 1171 * 1170 1172 * where RN = sqrt(PR^2 - PN^2) 1171 1173 */ -
trunk/src/org/openstreetmap/josm/gui/layer/RawGpsLayer.java
r1890 r1910 14 14 import java.awt.event.ActionListener; 15 15 import java.io.File; 16 import java.util.ArrayList; 16 17 import java.util.Collection; 18 import java.util.List; 17 19 18 20 import javax.swing.AbstractAction; … … 73 75 DataSet ds = new DataSet(); 74 76 for (Collection<GpsPoint> c : data) { 75 Way w = new Way();77 List<Node> nodes = new ArrayList<Node>(); 76 78 for (GpsPoint p : c) { 77 79 Node n = new Node(p.latlon); 78 80 ds.nodes.add(n); 79 w.nodes.add(n); 80 } 81 nodes.add(n); 82 } 83 Way w = new Way(); 84 w.setNodes(nodes); 81 85 ds.ways.add(w); 82 86 } -
trunk/src/org/openstreetmap/josm/io/OsmReader.java
r1899 r1910 12 12 import java.util.HashMap; 13 13 import java.util.LinkedList; 14 import java.util.List; 14 15 import java.util.Map; 15 16 import java.util.Map.Entry; … … 330 331 Way w = new Way(e.getKey().id); 331 332 boolean incomplete = false; 333 List<Node> wayNodes = new ArrayList<Node>(); 332 334 for (long id : e.getValue()) { 333 335 Node n = findNode(id); … … 337 339 incomplete = true; 338 340 } 339 w.nodes.add(n); 340 } 341 wayNodes.add(n); 342 } 343 w.setNodes(wayNodes); 341 344 if (incomplete) { 342 logger.warning(tr("marked way {0} with {1} nodes incomplete because at least one node was missing in the loaded data and is therefore incomplete too", e.getKey().id, w.nodes.size())); 345 logger.warning(tr("marked way {0} with {1} nodes incomplete because at least one node was missing in the " + 346 "loaded data and is therefore incomplete too", e.getKey().id, w.getNodesCount())); 343 347 e.getKey().copyTo(w); 344 348 w.incomplete = true;
Note:
See TracChangeset
for help on using the changeset viewer.