Changeset 9925 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2016-03-05T10:22:33+01:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/OrthogonalizeAction.java
r9923 r9925 180 180 nodeList.add((Node) p); 181 181 } else if (p instanceof Way) { 182 wayDataList.add(new WayData(( Way) p));183 } else 182 wayDataList.add(new WayData(((Way) p).getNodes())); 183 } else { 184 184 throw new InvalidUserInputException(tr("Selection must consist only of ways and nodes.")); 185 } 186 if (wayDataList.isEmpty()) { 185 } 186 } 187 if (wayDataList.isEmpty() && !nodeList.isEmpty()) { 188 final WayData data = new WayData(nodeList); 189 final Collection<Command> commands = orthogonalize(Collections.singletonList(data), Collections.<Node>emptyList()); 190 return new SequenceCommand(tr("Orthogonalize"), commands); 191 } else if (wayDataList.isEmpty()) { 187 192 throw new InvalidUserInputException("usage"); 188 193 } else { … … 235 240 WayData candidate = remaining.get(i); 236 241 if (candidate == null) continue; 237 if (!Collections.disjoint(candidate.way .getNodes(), newGroupMember.way.getNodes())) {242 if (!Collections.disjoint(candidate.wayNodes, newGroupMember.wayNodes)) { 238 243 remaining.set(i, null); 239 244 extendGroupRec(group, candidate, remaining); … … 300 305 final Set<Node> allNodes = new HashSet<>(); 301 306 for (WayData w : wayDataList) { 302 for (Node n : w.way .getNodes()) {307 for (Node n : w.wayNodes) { 303 308 allNodes.add(n); 304 309 } … … 345 350 for (WayData w : wayDataList) { 346 351 for (int i = 0; i < w.nSeg; ++i) { 347 Node n1 = w.way .getNodes().get(i);348 Node n2 = w.way .getNodes().get(i+1);352 Node n1 = w.wayNodes.get(i); 353 Node n2 = w.wayNodes.get(i+1); 349 354 if (Arrays.asList(orientation).contains(w.segDirections[i])) { 350 355 if (cs.contains(n1) && !cs.contains(n2)) { … … 417 422 */ 418 423 private static class WayData { 419 public final Way way; // The assigned way424 public final List<Node> wayNodes; // The assigned way 420 425 public final int nSeg; // Number of Segments of the Way 421 426 public final int nNode; // Number of Nodes of the Way … … 426 431 public double heading; // heading of segSum == approximate heading of the way 427 432 428 WayData( Way pWay) {429 way = pWay;430 nNode = way.getNodes().size();431 nSeg = nNode - 1;433 WayData(List<Node> wayNodes) { 434 this.wayNodes = wayNodes; 435 this.nNode = wayNodes.size(); 436 this.nSeg = nNode - 1; 432 437 } 433 438 … … 441 446 */ 442 447 public void calcDirections(Direction pInitialDirection) throws InvalidUserInputException { 443 final EastNorth[] en = new EastNorth[nNode]; // alias: way .getNodes().get(i).getEastNorth() ---> en[i]448 final EastNorth[] en = new EastNorth[nNode]; // alias: wayNodes.get(i).getEastNorth() ---> en[i] 444 449 for (int i = 0; i < nNode; i++) { 445 en[i] = new EastNorth(way.getNodes().get(i).getEastNorth().east(), way.getNodes().get(i).getEastNorth().north());450 en[i] = wayNodes.get(i).getEastNorth(); 446 451 } 447 452 segDirections = new Direction[nSeg];
Note:
See TracChangeset
for help on using the changeset viewer.