Changeset 32751 in osm for applications/editors
- Timestamp:
- 2016-08-01T19:49:55+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/SegmentChecker.java
r32747 r32751 631 631 initialFix.add(startPTWay); 632 632 initialFixes.add(initialFix); 633 List<PTWay> fix = findWaysForFix(initialFixes, initialFix, previousNode, endPTWay).get(0); 634 635 if (!fix.isEmpty() && fix.get(fix.size() - 1).equals(endPTWay)) { 636 wrongSegment.addFixVariant(fix); 637 } 638 639 } 640 641 /** 642 * 633 634 List<List<PTWay>> allFixes = findWaysForFix(initialFixes, initialFix, previousNode, endPTWay); 635 for (List<PTWay> fix : allFixes) { 636 if (!fix.isEmpty() && fix.get(fix.size() - 1).equals(endPTWay)) { 637 wrongSegment.addFixVariant(fix); 638 } 639 } 640 641 642 } 643 644 /** 645 * Recursive method to parse the route segment 643 646 * @param allFixes 644 647 * @param currentFix … … 647 650 * @return 648 651 */ 649 private List<List<PTWay>> findWaysForFix 652 private List<List<PTWay>> findWaysForFix(List<List<PTWay>> allFixes, List<PTWay> currentFix, Node previousNode, 650 653 PTWay endWay) { 651 654 … … 653 656 Node nextNode = getOppositeEndNode(currentWay, previousNode); 654 657 655 List<PTWay> potentialNextWays = this.findNextPTWaysInDirectionOfTravel(currentWay, nextNode); 656 List<PTWay> nextWays = new ArrayList<>(); 657 for (PTWay potentianNextWay : potentialNextWays) { 658 if (unusedWays.contains(potentianNextWay)) { 659 nextWays.add(potentianNextWay); 658 List<PTWay> nextWays = this.findNextPTWaysInDirectionOfTravel(currentWay, nextNode); 659 660 if (nextWays.size() > 1) { 661 for (int i = 1; i < nextWays.size(); i++) { 662 List<PTWay> newFix = new ArrayList<>(); 663 newFix.addAll(currentFix); 664 newFix.add(nextWays.get(i)); 665 allFixes.add(newFix); 666 if (!nextWays.get(i).equals(endWay) && !currentFix.contains(nextWays.get(i))) { 667 allFixes = findWaysForFix(allFixes, newFix, nextNode, endWay); 668 } 660 669 } 661 670 } 662 671 663 672 if (!nextWays.isEmpty()) { 673 boolean contains = currentFix.contains(nextWays.get(0)); 664 674 currentFix.add(nextWays.get(0)); 665 if (!nextWays.get(0).equals(endWay) ) {675 if (!nextWays.get(0).equals(endWay) && !contains) { 666 676 allFixes = findWaysForFix(allFixes, currentFix, nextNode, endWay); 667 677 } 668 678 } 669 679 670 // if (nextWays.size() > 1) { 671 // for (int i = 1; i < nextWays.size(); i++) { 672 // List<PTWay> newList = new ArrayList<>(); 673 // newList.addAll(currentFix); 674 // newList.add(nextWays.get(i)); 675 // allFixes.add(newList); 676 // // TODO: go on 677 // } 678 // } 680 679 681 680 682 return allFixes; … … 758 760 759 761 } else if (!wrongSegment.getFixVariants().isEmpty()) { 762 760 763 // 2) try to fix by using the sort & remove method: 761 764 // TODO: ask user if the change should be undertaken … … 794 797 for (int i = 0; i < waysOfOriginalRelation.size(); i++) { 795 798 if (waysOfOriginalRelation.get(i).getWay() == wrongSegment.getPTWays().get(0).getWays().get(0)) { 796 for (PTWay ptway : wrongSegment.getFixVariants().get(0)) { 799 for (PTWay ptway : wrongSegment.getFixVariants().get(0)) { // FIXME 797 800 if (ptway.getRole().equals("forward") || ptway.getRole().equals("backward")) { 798 801 modifiedRelationMembers.add(new RelationMember("", ptway.getMember())); … … 811 814 } 812 815 } 816 813 817 modifiedRelation.setMembers(modifiedRelationMembers); 814 818 // TODO: change the data model too
Note:
See TracChangeset
for help on using the changeset viewer.