Changeset 29124 in osm for applications/editors/josm/plugins/utilsplugin2
- Timestamp:
- 2012-12-26T16:22:48+01:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/curves/CircleArcMaker.java
r28028 r29124 3 3 4 4 import java.util.ArrayList; 5 import java.util.Arrays; 5 6 import java.util.Collection; 7 import java.util.Collections; 8 import java.util.Comparator; 6 9 import java.util.HashSet; 7 10 import java.util.Iterator; … … 60 63 Set<Way> targetWays = new HashSet<Way>(); 61 64 62 boolean nodesHa sBeenChoosen = false;65 boolean nodesHaveBeenChoosen = false; 63 66 if (selectedNodes.size() == 3) { 64 67 Iterator<Node> nodeIter = selectedNodes.iterator(); … … 66 69 n2 = nodeIter.next(); 67 70 n3 = nodeIter.next(); 68 nodesHa sBeenChoosen = true;71 nodesHaveBeenChoosen = true; 69 72 if (selectedWays.isEmpty()) { // Create a brand new way 70 73 Way newWay = new Way(); … … 76 79 } 77 80 } 78 if ( selectedWays.isEmpty() == false) {81 if (!selectedWays.isEmpty()) { 79 82 // TODO: use only two nodes inferring the orientation from the parent way. 80 83 81 if ( nodesHasBeenChoosen == false) {84 if (!nodesHaveBeenChoosen) { 82 85 // Use the three last nodes in the way as anchors. This is intended to be used with the 83 86 // built in draw mode … … 89 92 n2 = w.getNode(nodeCount - 2); 90 93 n1 = w.getNode(nodeCount - 3); 91 nodesHasBeenChoosen = true; 92 } 93 targetWays.addAll(OsmPrimitive.getFilteredList(n1.getReferrers(), Way.class)); 94 targetWays.addAll(OsmPrimitive.getFilteredList(n2.getReferrers(), Way.class)); 95 targetWays.addAll(OsmPrimitive.getFilteredList(n3.getReferrers(), Way.class)); 96 // for(Way w : selectedWays) { 97 // targetWays.add(w); 98 // } 99 100 } 101 if (nodesHasBeenChoosen == false) { 94 nodesHaveBeenChoosen = true; 95 } 96 // Fix #7341. Find the first way having all nodes in common to sort them in its nodes order 97 List<Node> consideredNodes = Arrays.asList(new Node[]{n1,n2,n3}); 98 for (Way w : selectedWays) { 99 final List<Node> nodes = w.getNodes(); 100 if (nodes.containsAll(consideredNodes)) { 101 Collections.sort(consideredNodes, new Comparator<Node>() { 102 @Override 103 public int compare(Node a, Node b) { 104 return nodes.indexOf(a) - nodes.indexOf(b); 105 } 106 }); 107 n1 = consideredNodes.get(0); 108 n2 = consideredNodes.get(1); 109 n3 = consideredNodes.get(2); 110 break; 111 } 112 } 113 114 for (Node n : consideredNodes) { 115 targetWays.addAll(OsmPrimitive.getFilteredList(n.getReferrers(), Way.class)); 116 } 117 } 118 if (!nodesHaveBeenChoosen) { 102 119 return null; 103 120 }
Note:
See TracChangeset
for help on using the changeset viewer.