Changeset 1912 in josm
- Timestamp:
- 2009-08-05T10:25:23+02:00 (15 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/AlignInCircleAction.java
r1862 r1912 113 113 // distance between two nodes. 114 114 if (nodes.size() > 0) { 115 if (nodes.size() == 1 && way. getNodes().contains(nodes.get(0))) {115 if (nodes.size() == 1 && way.containsNode(nodes.get(0))) { 116 116 regular = true; 117 117 } else { 118 118 119 center = nodes.get(way. getNodes().contains(nodes.get(0)) ? 1 : 0).getEastNorth();119 center = nodes.get(way.containsNode(nodes.get(0)) ? 1 : 0).getEastNorth(); 120 120 if (nodes.size() == 2) { 121 121 radius = distance(nodes.get(0).getEastNorth(), nodes.get(1).getEastNorth()); -
trunk/src/org/openstreetmap/josm/actions/MergeNodesAction.java
r1862 r1912 225 225 continue; 226 226 } 227 if (w. getNodes().contains(sn)) {227 if (w.containsNode(sn)) { 228 228 modify = true; 229 229 } -
trunk/src/org/openstreetmap/josm/actions/UnGlueAction.java
r1899 r1912 70 70 continue; 71 71 } 72 if (!w. getNodes().contains(selectedNode)) {72 if (!w.containsNode(selectedNode)) { 73 73 continue; 74 74 } … … 95 95 continue; 96 96 } 97 if (!w. getNodes().contains(n)) {97 if (!w.containsNode(n)) { 98 98 continue; 99 99 } … … 191 191 boolean isPartOfWay = false; 192 192 for(Way w : getCurrentDataSet().ways) { 193 if(w. getNodes().contains(n)) {193 if(w.containsNode((Node)n)) { 194 194 isPartOfWay = true; 195 195 break; … … 232 232 selectedNode = (Node) p; 233 233 if (size == 1 || selectedWay != null) 234 return size == 1 || selectedWay. getNodes().contains(selectedNode);234 return size == 1 || selectedWay.containsNode(selectedNode); 235 235 } else if (p instanceof Way) { 236 236 selectedWay = (Way) p; 237 237 if (size == 2 && selectedNode != null) 238 return selectedWay. getNodes().contains(selectedNode);238 return selectedWay.containsNode(selectedNode); 239 239 } 240 240 } … … 276 276 if (p instanceof Node) { 277 277 Node n = (Node) p; 278 if (!selectedWay. getNodes().contains(n))278 if (!selectedWay.containsNode(n)) 279 279 return false; 280 280 selectedNodes.add(n); … … 372 372 continue; 373 373 } 374 if (!w. getNodes().contains(selectedNode)) {374 if (!w.containsNode(selectedNode)) { 375 375 continue; 376 376 } -
trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java
r1899 r1912 128 128 return; 129 129 switch(c) { 130 case way: 131 Main.map.mapView.setCursor(cursorJoinWay); 130 case way: 131 Main.map.mapView.setCursor(cursorJoinWay); 132 break; 133 case node: 134 Main.map.mapView.setCursor(cursorJoinNode); 135 break; 136 default: 137 Main.map.mapView.setCursor(cursorCrosshair); 132 138 break; 133 case node:134 Main.map.mapView.setCursor(cursorJoinNode);135 break;136 default:137 Main.map.mapView.setCursor(cursorCrosshair);138 break;139 139 } 140 140 } … … 503 503 504 504 // Connected to a node that's already in the way 505 if(way. getNodes().contains(n)) {505 if(way.containsNode(n)) { 506 506 wayIsFinished = true; 507 507 selection.clear(); … … 810 810 811 811 switch (segs.size()) { 812 case 0: 813 return; 814 case 2: 815 // This computes the intersection between 816 // the two segments and adjusts the node position. 817 Iterator<Pair<Node,Node>> i = segs.iterator(); 818 Pair<Node,Node> seg = i.next(); 819 EastNorth A = seg.a.getEastNorth(); 820 EastNorth B = seg.b.getEastNorth(); 821 seg = i.next(); 822 EastNorth C = seg.a.getEastNorth(); 823 EastNorth D = seg.b.getEastNorth(); 824 825 double u=det(B.east() - A.east(), B.north() - A.north(), C.east() - D.east(), C.north() - D.north()); 826 827 // Check for parallel segments and do nothing if they are 828 // In practice this will probably only happen when a way has been duplicated 829 830 if (u == 0) return; 831 832 // q is a number between 0 and 1 833 // It is the point in the segment where the intersection occurs 834 // if the segment is scaled to lenght 1 835 836 double q = det(B.north() - C.north(), B.east() - C.east(), D.north() - C.north(), D.east() - C.east()) / u; 837 EastNorth intersection = new EastNorth( 838 B.east() + q * (A.east() - B.east()), 839 B.north() + q * (A.north() - B.north())); 840 841 int snapToIntersectionThreshold 842 = Main.pref.getInteger("edit.snap-intersection-threshold",10); 843 844 // only adjust to intersection if within snapToIntersectionThreshold pixel of mouse click; otherwise 845 // fall through to default action. 846 // (for semi-parallel lines, intersection might be miles away!) 847 if (Main.map.mapView.getPoint(n).distance(Main.map.mapView.getPoint(intersection)) < snapToIntersectionThreshold) { 848 n.setEastNorth(intersection); 812 case 0: 849 813 return; 850 } 851 852 default: 853 EastNorth P = n.getEastNorth(); 854 seg = segs.iterator().next(); 855 A = seg.a.getEastNorth(); 856 B = seg.b.getEastNorth(); 857 double a = P.distanceSq(B); 858 double b = P.distanceSq(A); 859 double c = A.distanceSq(B); 860 q = (a - b + c) / (2*c); 861 n.setEastNorth(new EastNorth(B.east() + q * (A.east() - B.east()), B.north() + q * (A.north() - B.north()))); 814 case 2: 815 // This computes the intersection between 816 // the two segments and adjusts the node position. 817 Iterator<Pair<Node,Node>> i = segs.iterator(); 818 Pair<Node,Node> seg = i.next(); 819 EastNorth A = seg.a.getEastNorth(); 820 EastNorth B = seg.b.getEastNorth(); 821 seg = i.next(); 822 EastNorth C = seg.a.getEastNorth(); 823 EastNorth D = seg.b.getEastNorth(); 824 825 double u=det(B.east() - A.east(), B.north() - A.north(), C.east() - D.east(), C.north() - D.north()); 826 827 // Check for parallel segments and do nothing if they are 828 // In practice this will probably only happen when a way has been duplicated 829 830 if (u == 0) return; 831 832 // q is a number between 0 and 1 833 // It is the point in the segment where the intersection occurs 834 // if the segment is scaled to lenght 1 835 836 double q = det(B.north() - C.north(), B.east() - C.east(), D.north() - C.north(), D.east() - C.east()) / u; 837 EastNorth intersection = new EastNorth( 838 B.east() + q * (A.east() - B.east()), 839 B.north() + q * (A.north() - B.north())); 840 841 int snapToIntersectionThreshold 842 = Main.pref.getInteger("edit.snap-intersection-threshold",10); 843 844 // only adjust to intersection if within snapToIntersectionThreshold pixel of mouse click; otherwise 845 // fall through to default action. 846 // (for semi-parallel lines, intersection might be miles away!) 847 if (Main.map.mapView.getPoint(n).distance(Main.map.mapView.getPoint(intersection)) < snapToIntersectionThreshold) { 848 n.setEastNorth(intersection); 849 return; 850 } 851 852 default: 853 EastNorth P = n.getEastNorth(); 854 seg = segs.iterator().next(); 855 A = seg.a.getEastNorth(); 856 B = seg.b.getEastNorth(); 857 double a = P.distanceSq(B); 858 double b = P.distanceSq(A); 859 double c = A.distanceSq(B); 860 q = (a - b + c) / (2*c); 861 n.setEastNorth(new EastNorth(B.east() + q * (A.east() - B.east()), B.north() + q * (A.north() - B.north()))); 862 862 } 863 863 } -
trunk/test/functional/org/openstreetmap/josm/gui/dialogs/ConflictResolutionDialogTest.java
r1910 r1912 20 20 protected void populate() { 21 21 Way w1 = new Way(1); 22 23 22 w1.addNode(new Node(10)); 23 w1.addNode(new Node(11)); 24 24 25 25 Way w2 = new Way(1); 26 27 26 w2.addNode(new Node(10)); 27 w2.addNode(new Node(11)); 28 28 29 dialog.getConflictResolver().populate(w1, w2);29 dialog.getConflictResolver().populate(w1, w2); 30 30 } 31 31 -
trunk/test/unit/org/openstreetmap/josm/data/osm/visitor/MergeSourceBuildingVisitorTest.java
r1910 r1912 2 2 package org.openstreetmap.josm.data.osm.visitor; 3 3 4 import static org.junit.Assert.assertEquals;5 import static org.junit.Assert.assertNotNull;6 import static org.junit.Assert.assertNull;7 import static org.junit.Assert.assertTrue;8 9 4 import java.util.Collection; 10 5 6 import org.junit.Ignore; 11 7 import org.junit.Test; 12 8 import org.openstreetmap.josm.data.coor.LatLon; … … 17 13 import org.openstreetmap.josm.data.osm.RelationMember; 18 14 import org.openstreetmap.josm.data.osm.Way; 15 16 import static org.junit.Assert.*; 19 17 20 18 public class MergeSourceBuildingVisitorTest { … … 186 184 Node n = (Node)hull.getPrimitiveById(21); 187 185 assertNotNull(n); 188 assertTrue(w. getNodes().contains(n));186 assertTrue(w.containsNode(n)); 189 187 190 188 n = (Node)hull.getPrimitiveById(22); 191 189 assertNotNull(n); 192 assertTrue(w. getNodes().contains(n));190 assertTrue(w.containsNode(n)); 193 191 194 192 Relation r = (Relation)hull.getPrimitiveById(40); … … 310 308 Node n = (Node)lookupByName(hull.nodes, "n21"); 311 309 assertNotNull(n); 312 assertTrue(w. getNodes().contains(n));310 assertTrue(w.containsNode(n)); 313 311 314 312 n = (Node)lookupByName(hull.nodes, "n22"); 315 313 assertNotNull(n); 316 assertTrue(w. getNodes().contains(n));314 assertTrue(w.containsNode(n)); 317 315 318 316 Relation r = (Relation)lookupByName(hull.relations, "r40");
Note:
See TracChangeset
for help on using the changeset viewer.