Changeset 34236 in osm for applications
- Timestamp:
- 2018-05-30T20:13:19+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
r34235 r34236 536 536 JComboBox<String> values, int type) { 537 537 TagMap newKeys1 = affectedKeysList.get(0); 538 String prevValue = null; 538 539 539 540 if (keys.getSelectedItem() == "bridge") { 540 541 newKeys1.put(keys.getSelectedItem().toString(), values.getSelectedItem().toString()); 541 542 newKeys1.put("layer", "1"); 542 selectedWay.get(0).setKeys(newKeys1);543 543 } else if (keys.getSelectedItem() == "tunnel") { 544 544 newKeys1.put(keys.getSelectedItem().toString(), values.getSelectedItem().toString()); 545 545 if (!values.getSelectedItem().toString().equals("building_passage")) 546 546 newKeys1.put("layer", "-1"); 547 selectedWay.get(0).setKeys(newKeys1);548 547 } else { 549 548 if (newKeys1.containsKey("bus_bay")) { 550 String value = newKeys1.get("bus_bay"); 551 if (values.getSelectedItem().equals("left") && value.equals("right")) { 552 newKeys1.put(keys.getSelectedItem().toString(), "both"); 553 } else if (values.getSelectedItem().equals("right") && value.equals("left")) { 554 newKeys1.put(keys.getSelectedItem().toString(), "both"); 555 } else { 556 newKeys1.put(keys.getSelectedItem().toString(), values.getSelectedItem().toString()); 557 } 549 prevValue = newKeys1.get("bus_bay"); 550 newKeys1.put(keys.getSelectedItem().toString(), "both"); 558 551 } else { 559 552 newKeys1.put(keys.getSelectedItem().toString(), values.getSelectedItem().toString()); 560 553 } 561 if (type != 2) { 562 // selectedWay.get(0).setKeys(newKeys1); 563 MainApplication.undoRedo.add(new ChangePropertyCommand(Collections.singleton(selectedWay.get(0)), newKeys1)); 564 } else { 565 MainApplication.undoRedo.add(new ChangePropertyCommand(Collections.singleton(selectedWay.get(0)), newKeys1)); 566 } 554 // if (type != 2) { 555 // selectedWay.get(0).setKeys(newKeys1); 556 // 557 // } else { 558 // MainApplication.undoRedo.add(new 559 // ChangePropertyCommand(Collections.singleton(selectedWay.get(0)), newKeys1)); 560 // } 567 561 } 568 562 … … 573 567 newKeys2.put(keys.getSelectedItem().toString(), values.getSelectedItem().toString()); 574 568 newKeys2.put("layer", "1"); 575 selectedWay.get(1).setKeys(newKeys2);576 569 } else if (keys.getSelectedItem() == "tunnel") { 577 570 newKeys2.put(keys.getSelectedItem().toString(), values.getSelectedItem().toString()); 578 571 if (!values.getSelectedItem().toString().equals("building_passage")) 579 572 newKeys2.put("layer", "-1"); 580 selectedWay.get(1).setKeys(newKeys2);581 573 } else { 582 574 if (newKeys2.containsKey("bus_bay")) { 583 String value = newKeys2.get("bus_bay"); 584 if (values.getSelectedItem().equals("left") && value.equals("right")) { 585 newKeys2.put(keys.getSelectedItem().toString(), "both"); 586 } else if (values.getSelectedItem().equals("right") && value.equals("left")) { 587 newKeys2.put(keys.getSelectedItem().toString(), "both"); 575 prevValue = newKeys2.get("bus_bay"); 576 newKeys2.put(keys.getSelectedItem().toString(), "both"); 577 if (values.getSelectedItem().equals("left") && prevValue.equals("left")) 578 newKeys1.put("bus_bay", "right"); 579 else if (values.getSelectedItem().equals("right") && prevValue.equals("right")) 580 newKeys1.put("bus_bay", "left"); 581 } else { 582 if (newKeys1.get("bus_bay").equals("both")) { 583 if (values.getSelectedItem().equals("left") && prevValue.equals("left")) 584 newKeys2.put("bus_bay", "right"); 585 else if (values.getSelectedItem().equals("right") && prevValue.equals("right")) 586 newKeys2.put("bus_bay", "left"); 587 else 588 newKeys2.put(keys.getSelectedItem().toString(), values.getSelectedItem().toString()); 588 589 } else { 589 590 newKeys2.put(keys.getSelectedItem().toString(), values.getSelectedItem().toString()); 590 591 } 591 } else { 592 newKeys2.put(keys.getSelectedItem().toString(), values.getSelectedItem().toString()); 593 } 594 if (type != 2) { 595 // selectedWay.get(1).setKeys(newKeys2); 596 MainApplication.undoRedo.add(new ChangePropertyCommand(Collections.singleton(selectedWay.get(1)), newKeys2)); 597 } else { 598 MainApplication.undoRedo.add(new ChangePropertyCommand(Collections.singleton(selectedWay.get(1)), newKeys2)); 599 } 600 } 601 } 592 } 593 } 594 MainApplication.undoRedo 595 .add(new ChangePropertyCommand(Collections.singleton(selectedWay.get(1)), newKeys2)); 596 } 597 MainApplication.undoRedo.add(new ChangePropertyCommand(Collections.singleton(selectedWay.get(0)), newKeys1)); 602 598 resetLayer(); 603 599 } … … 723 719 724 720 rightHandTraffic = true; 725 for (Node n : atNodes) {726 727 728 729 730 721 for (Node n : atNodes) { 722 if (!RightAndLefthandTraffic.isRightHandTraffic(n.getCoor())) { 723 rightHandTraffic = false; 724 break; 725 } 726 } 731 727 732 728 setButtonIcons("ok", "cancel"); … … 762 758 763 759 if (rightHandTraffic) 764 values.setModel(new DefaultComboBoxModel<>(new String[] { "right", "left", "both"}));760 values.setModel(new DefaultComboBoxModel<>(new String[] { "right", "left", "both" })); 765 761 else 766 values.setModel(new DefaultComboBoxModel<>(new String[] { "left", "right", "both"}));762 values.setModel(new DefaultComboBoxModel<>(new String[] { "left", "right", "both" })); 767 763 768 764 // below code changes the list in values on the basis of key … … 773 769 values.setModel(new DefaultComboBoxModel<>(new String[] { "both", "right", "left" })); 774 770 if (rightHandTraffic) 775 values.setModel(new DefaultComboBoxModel<>(new String[] { "right", "left", "both"}));771 values.setModel(new DefaultComboBoxModel<>(new String[] { "right", "left", "both" })); 776 772 else 777 values.setModel(new DefaultComboBoxModel<>(new String[] { "left", "right", "both"}));773 values.setModel(new DefaultComboBoxModel<>(new String[] { "left", "right", "both" })); 778 774 } else if ("bridge".equals(keys.getSelectedItem())) { 779 775 values.setModel(new DefaultComboBoxModel<>(new String[] { "yes" })); 780 776 } else if ("tunnel".equals(keys.getSelectedItem())) { 781 777 if (previousAffectedWay.hasKey("waterway") || affected.hasKey("waterway")) 782 values.setModel(new DefaultComboBoxModel<>(new String[] { "culvert", "yes", "building_passage" })); 778 values.setModel( 779 new DefaultComboBoxModel<>(new String[] { "culvert", "yes", "building_passage" })); 783 780 else 784 values.setModel(new DefaultComboBoxModel<>(new String[] { "yes", "culvert", "building_passage" })); 781 values.setModel( 782 new DefaultComboBoxModel<>(new String[] { "yes", "culvert", "building_passage" })); 785 783 } 786 784 } … … 802 800 if ("tunnel".equals(keys.getSelectedItem())) { 803 801 if (previousAffectedWay.hasKey("waterway") || affected.hasKey("waterway")) 804 values.setModel(new DefaultComboBoxModel<>(new String[] { "culvert", "yes", "building_passage" })); 802 values.setModel( 803 new DefaultComboBoxModel<>(new String[] { "culvert", "yes", "building_passage" })); 805 804 else 806 values.setModel(new DefaultComboBoxModel<>(new String[] { "yes", "culvert", "building_passage" })); 805 values.setModel( 806 new DefaultComboBoxModel<>(new String[] { "yes", "culvert", "building_passage" })); 807 807 } else if ("bus_bay".equals(keys.getSelectedItem())) { 808 808 values.setModel(new DefaultComboBoxModel<>(new String[] { "both", "right", "left" })); 809 809 if (rightHandTraffic) 810 values.setModel(new DefaultComboBoxModel<>(new String[] { "right", "left", "both"}));810 values.setModel(new DefaultComboBoxModel<>(new String[] { "right", "left", "both" })); 811 811 else 812 values.setModel(new DefaultComboBoxModel<>(new String[] { "left", "right", "both"}));812 values.setModel(new DefaultComboBoxModel<>(new String[] { "left", "right", "both" })); 813 813 } else if ("bridge".equals(keys.getSelectedItem())) { 814 814 values.setModel(new DefaultComboBoxModel<>(new String[] { "yes" })); … … 819 819 820 820 private void setOptionsWithBridge() { 821 keys.setModel(new DefaultComboBoxModel<>(new String[] { "bridge", "bus_bay", "tunnel" }));821 keys.setModel(new DefaultComboBoxModel<>(new String[] { "bridge", "bus_bay", "tunnel" })); 822 822 823 823 values.setModel(new DefaultComboBoxModel<>(new String[] { "yes" })); … … 829 829 if ("tunnel".equals(keys.getSelectedItem())) { 830 830 if (previousAffectedWay.hasKey("waterway") || affected.hasKey("waterway")) 831 values.setModel(new DefaultComboBoxModel<>(new String[] { "culvert", "yes", "building_passage" })); 831 values.setModel( 832 new DefaultComboBoxModel<>(new String[] { "culvert", "yes", "building_passage" })); 832 833 else 833 values.setModel(new DefaultComboBoxModel<>(new String[] { "yes", "culvert", "building_passage" })); 834 values.setModel( 835 new DefaultComboBoxModel<>(new String[] { "yes", "culvert", "building_passage" })); 834 836 } else if ("bus_bay".equals(keys.getSelectedItem())) { 835 837 values.setModel(new DefaultComboBoxModel<>(new String[] { "both", "right", "left" })); 836 838 if (rightHandTraffic) 837 values.setModel(new DefaultComboBoxModel<>(new String[] { "right", "left", "both"}));839 values.setModel(new DefaultComboBoxModel<>(new String[] { "right", "left", "both" })); 838 840 else 839 values.setModel(new DefaultComboBoxModel<>(new String[] { "left", "right", "both"}));841 values.setModel(new DefaultComboBoxModel<>(new String[] { "left", "right", "both" })); 840 842 } else if ("bridge".equals(keys.getSelectedItem())) { 841 843 values.setModel(new DefaultComboBoxModel<>(new String[] { "yes" })); … … 846 848 847 849 private void findIntersection(Set<Way> newWays) { 848 DataSet ds = getLayerManager().getEditDataSet(); 849 NodeWayUtils.addWaysIntersectingWays( 850 ds.getWays(), 851 Arrays.asList(previousAffectedWay, affected), newWays); 852 Node n1 = previousAffectedWay.firstNode(); 853 Node n2 = previousAffectedWay.lastNode(); 854 Node n3 = affected.firstNode(); 855 Node n4 = affected.lastNode(); 856 List<Way> waysToBeRemoved = new ArrayList<>(); 857 for (Way way : newWays) { 858 int count = 0; 859 if (way.containsNode(n1)) 860 count++; 861 if (way.containsNode(n2)) 862 count++; 863 if (!previousAffectedWay.equals(affected)) { 864 if (way.containsNode(n3)) 865 count++; 866 if (way.containsNode(n4)) 867 count++; 868 } 869 if (count == 1) { 870 waysToBeRemoved.add(way); 871 } else { 872 if (!way.hasKey("highway") && !way.hasKey("waterway") && !way.hasKey("railway")) { 873 waysToBeRemoved.add(way); 874 } 875 } 876 } 877 newWays.removeAll(waysToBeRemoved); 850 DataSet ds = getLayerManager().getEditDataSet(); 851 NodeWayUtils.addWaysIntersectingWays(ds.getWays(), Arrays.asList(previousAffectedWay, affected), newWays); 852 Node n1 = previousAffectedWay.firstNode(); 853 Node n2 = previousAffectedWay.lastNode(); 854 Node n3 = affected.firstNode(); 855 Node n4 = affected.lastNode(); 856 List<Way> waysToBeRemoved = new ArrayList<>(); 857 for (Way way : newWays) { 858 int count = 0; 859 if (way.containsNode(n1)) 860 count++; 861 if (way.containsNode(n2)) 862 count++; 863 if (!previousAffectedWay.equals(affected)) { 864 if (way.containsNode(n3)) 865 count++; 866 if (way.containsNode(n4)) 867 count++; 868 } 869 if (count == 1) { 870 waysToBeRemoved.add(way); 871 } else { 872 if (!way.hasKey("highway") && !way.hasKey("waterway") && !way.hasKey("railway")) { 873 waysToBeRemoved.add(way); 874 } 875 } 876 } 877 newWays.removeAll(waysToBeRemoved); 878 878 } 879 879 … … 893 893 } 894 894 895 } else if (getValue() != 3) {895 } else if (getValue() != 3) { 896 896 resetLayer(); 897 897 }
Note:
See TracChangeset
for help on using the changeset viewer.