Changeset 34245 in osm for applications/editors/josm
- Timestamp:
- 2018-06-04T12:07:50+02:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/actions/DoubleSplitAction.java
r34238 r34245 139 139 } 140 140 141 // check if both the nodes are starting and ending nodes of same way 141 142 private boolean startEndPoints(List<Command> commandList) { 142 143 … … 296 297 } 297 298 299 // calls the dialog box 298 300 private void dialogBox(int type, Node commonNode, Way affected, Way previousAffectedWay, 299 301 List<Command> commandList) { … … 301 303 final ExtendedDialog dialog = new SelectFromOptionDialog(type, commonNode, affected, previousAffectedWay, 302 304 commandList, atNodes); 303 dialog.toggleEnable("way.split.segment-selection-dialog"); 304 if (!dialog.toggleCheckState()) { 305 dialog.setModal(false); 306 dialog.showDialog(); 307 return; // splitting is performed in SegmentToKeepSelectionDialog.buttonAction() 308 } 309 310 } 311 305 dialog.setModal(false); 306 dialog.showDialog(); 307 return; // splitting is performed in SegmentToKeepSelectionDialog.buttonAction() 308 309 } 310 311 // create a node in the position that the user has marked 312 312 private Node createNode(ILatLon Pos, List<Command> commandList) { 313 313 Boolean newNode = false; … … 336 336 } 337 337 338 /* 339 * the function works if we have both nodes on a single way. It adds the nodes 340 * in the undoRedo, splits the ways if required, collects the existing keys of 341 * the ways and sends to addTags function 342 */ 338 343 private void addKeys(Way affected, List<Command> commandList, JComboBox<String> keys, JComboBox<String> values) { 339 344 List<TagMap> affectedKeysList = new ArrayList<>(); … … 367 372 } 368 373 374 // add the existing keys of the selected way to affectedKeysList 369 375 if (selectedWay != null) { 370 376 affectedKeysList.add(affected.getKeys()); … … 378 384 } 379 385 386 // this function is called when both nodes are in 2 adjacent ways 380 387 private void addKeysOnBothWays(Node commonNode, Way affected, Way previousAffectedWay, List<Command> commandList, 381 388 JComboBox<String> keys, JComboBox<String> values) { … … 482 489 } 483 490 491 // this function is called when both nodes are starting and ending points of 492 // same way, we dont split anything here 484 493 private void addKeysWhenStartEndPoint(Way affected, List<Command> commandList, JComboBox<String> keys, 485 494 JComboBox<String> values) { … … 498 507 } 499 508 509 // join the node to the way only if the node is new 500 510 private void addParentWay(Node node) { 501 511 if (node.getParentWays().size() == 0) { 502 512 MainApplication.getLayerManager().getEditLayer().data.setSelected(node); 503 // join the node to the way only if the node is new504 513 JoinNodeWayAction joinNodeWayAction = JoinNodeWayAction.createMoveNodeOntoWayAction(); 505 514 joinNodeWayAction.actionPerformed(null); … … 507 516 } 508 517 518 // check if a way is present in a relation, if not then add it 509 519 private void checkMembership(Way way, List<Relation> referrers, int Index) { 510 520 for (Relation r : referrers) { … … 523 533 } 524 534 535 // get index where the way is present in a relation 525 536 private int getIndex(Way way, List<Relation> referrers, Way previousAffectedWay) { 526 537 int Index = -1; … … 535 546 } 536 547 548 // take key value pair from the dialog box and add it to the existing ways 537 549 private void addTags(List<TagMap> affectedKeysList, List<Way> selectedWay, JComboBox<String> keys, 538 550 JComboBox<String> values, int type) { … … 554 566 newKeys1.put(keys.getSelectedItem().toString(), values.getSelectedItem().toString()); 555 567 } 556 // if (type != 2) {557 // selectedWay.get(0).setKeys(newKeys1);558 //559 // } else {560 // MainApplication.undoRedo.add(new561 // ChangePropertyCommand(Collections.singleton(selectedWay.get(0)), newKeys1));562 // }563 568 } 564 569 … … 637 642 } 638 643 639 int addWaysIntersectingWay(Collection<Way> ways, Way w, Set<Way> newWays) { 640 List<Pair<Node, Node>> nodePairs = w.getNodePairs(false); 641 int count = 0; 642 for (Way anyway: ways) { 643 if (Objects.equals(anyway, w)) continue; 644 if (newWays.contains(anyway)) continue; 645 List<Pair<Node, Node>> nodePairs2 = anyway.getNodePairs(false); 646 loop: for (Pair<Node, Node> p1 : nodePairs) { 647 for (Pair<Node, Node> p2 : nodePairs2) { 648 if (null != Geometry.getSegmentSegmentIntersection( 649 p1.a.getEastNorth(), p1.b.getEastNorth(), 650 p2.a.getEastNorth(), p2.b.getEastNorth())) { 651 newWays.add(anyway); 652 count++; 653 break loop; 654 } 655 } 656 } 657 } 658 return count; 659 } 660 661 int addWaysIntersectingWays(Collection<Way> allWays, Collection<Way> initWays, Set<Way> newWays) { 662 int count = 0; 663 for (Way w : initWays) { 664 count += addWaysIntersectingWay(allWays, w, newWays); 665 } 666 return count; 667 } 644 void addWaysIntersectingWay(Collection<Way> ways, Way w, Set<Way> newWays) { 645 List<Pair<Node, Node>> nodePairs = w.getNodePairs(false); 646 for (Way anyway : ways) { 647 if (Objects.equals(anyway, w)) 648 continue; 649 if (newWays.contains(anyway)) 650 continue; 651 List<Pair<Node, Node>> nodePairs2 = anyway.getNodePairs(false); 652 loop: for (Pair<Node, Node> p1 : nodePairs) { 653 for (Pair<Node, Node> p2 : nodePairs2) { 654 if (null != Geometry.getSegmentSegmentIntersection(p1.a.getEastNorth(), p1.b.getEastNorth(), 655 p2.a.getEastNorth(), p2.b.getEastNorth())) { 656 newWays.add(anyway); 657 break loop; 658 } 659 } 660 } 661 } 662 } 663 664 void addWaysIntersectingWays(Collection<Way> allWays, Collection<Way> initWays, Set<Way> newWays) { 665 for (Way w : initWays) { 666 addWaysIntersectingWay(allWays, w, newWays); 667 } 668 } 668 669 669 670 @Override … … 813 814 if (previousAffectedWay.hasKey("waterway") || affected.hasKey("waterway")) { 814 815 setOptionsWithTunnel(); 816 } else if (previousAffectedWay.hasKey("bus_bay") || affected.hasKey("bus_bay")) { 817 setOptionsWithBusBay(); 815 818 } else if (newWays != null && newWays.size() != 0) { 816 819 setOptionsWithBridge(); 817 820 } else { 818 setOptions Default();821 setOptionsWithBusBay(); 819 822 } 820 823 … … 826 829 } 827 830 828 private void setOptions Default() {831 private void setOptionsWithBusBay() { 829 832 keys.setModel(new DefaultComboBoxModel<>(new String[] { "bus_bay", "bridge", "tunnel" })); 830 833 831 if (rightHandTraffic) 834 if (affected.hasTag("bus_bay", "right") || previousAffectedWay.hasTag("bus_bay", "right")) { 835 values.setModel(new DefaultComboBoxModel<>(new String[] { "left", "right", "both" })); 836 } else if (affected.hasTag("bus_bay", "left") || previousAffectedWay.hasTag("bus_bay", "left")) { 832 837 values.setModel(new DefaultComboBoxModel<>(new String[] { "right", "left", "both" })); 833 else 838 } else if (rightHandTraffic) { 839 values.setModel(new DefaultComboBoxModel<>(new String[] { "right", "left", "both" })); 840 } else { 834 841 values.setModel(new DefaultComboBoxModel<>(new String[] { "left", "right", "both" })); 842 } 835 843 836 844 // below code changes the list in values on the basis of key
Note:
See TracChangeset
for help on using the changeset viewer.