Changeset 32801 in osm
- Timestamp:
- 2016-08-12T02:33:42+02:00 (8 years ago)
- Location:
- applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/data/PTRouteSegment.java
r32776 r32801 61 61 return ptways.get(ptways.size() - 1); 62 62 } 63 64 public Way getFirstWay() { 65 if (ptways.isEmpty()) { 66 return null; 67 } 68 return ptways.get(0).getWays().get(0); 69 } 70 71 public Way getLastWay() { 72 if (ptways.isEmpty()) { 73 return null; 74 } 75 List<Way> waysOfLast = ptways.get(ptways.size() - 1).getWays(); 76 return waysOfLast.get(waysOfLast.size() - 1); 77 } 63 78 64 public void addFixVariant(List<PTWay> list) { 79 /** 80 * Adds the new fix variant if an identical fix variant (i.e. same ways) is 81 * not already contained in the list of the fix variants of this. 82 * 83 * @param list the PTWays of the new fix variant 84 */ 85 public synchronized void addFixVariant(List<PTWay> list) { 86 List<Way> otherWays = new ArrayList<>(); 87 for (PTWay ptway : list) { 88 otherWays.addAll(ptway.getWays()); 89 } 90 91 for (List<PTWay> fixVariant : this.fixVariants) { 92 List<Way> thisWays = new ArrayList<>(); 93 for (PTWay ptway : fixVariant) { 94 thisWays.addAll(ptway.getWays()); 95 } 96 boolean listsEqual = (thisWays.size() == otherWays.size()); 97 if (listsEqual) { 98 for (int i = 0; i < thisWays.size(); i++) { 99 if (thisWays.get(i).getId() != otherWays.get(i).getId()) { 100 listsEqual = false; 101 break; 102 } 103 } 104 } 105 if (listsEqual) { 106 return; 107 } 108 } 109 65 110 this.fixVariants.add(list); 66 111 } … … 77 122 */ 78 123 public boolean equalsRouteSegment(PTRouteSegment other) { 124 79 125 List<Way> thisWays = new ArrayList<>(); 80 126 for (PTWay ptway : this.ptways) { … … 85 131 otherWays.addAll(ptway.getWays()); 86 132 } 133 87 134 if (thisWays.size() != otherWays.size()) { 88 135 return false; 89 136 } 90 137 91 138 for (int i = 0; i < thisWays.size(); i++) { 92 if (thisWays.get(i) != otherWays.get(i)) {139 if (thisWays.get(i).getId() != otherWays.get(i).getId()) { 93 140 return false; 94 141 } 95 142 } 96 143 97 144 return true; 98 145 } -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/gui/PTAssistantLayer.java
r32797 r32801 82 82 public void addFixVariants(List<List<PTWay>> fixVariants) { 83 83 HashMap<List<PTWay>, Character> fixVariantLetterMap = new HashMap<>(); 84 84 85 85 char alphabet = 'A'; 86 for (int i = 0; i < fixVariants.size(); i++) { 87 if (i < 5) { 88 List<PTWay> fixVariant = fixVariants.get(i); 89 this.fixVariants.put(alphabet, fixVariant); 90 fixVariantLetterMap.put(fixVariant, alphabet); 91 alphabet++; 92 } 93 } 94 95 for (List<PTWay> fixVariant : fixVariants) { 96 Character currentFixVariantLetter = fixVariantLetterMap.get(fixVariant); 86 for (int i = 0; i < 5 && i < fixVariants.size(); i++) { 87 List<PTWay> fixVariant = fixVariants.get(i); 88 this.fixVariants.put(alphabet, fixVariant); 89 fixVariantLetterMap.put(fixVariant, alphabet); 90 alphabet++; 91 } 92 93 for (Character currentFixVariantLetter: this.fixVariants.keySet()) { 94 List<PTWay> fixVariant = this.fixVariants.get(currentFixVariantLetter); 97 95 for (PTWay ptway : fixVariant) { 98 96 for (Way way : ptway.getWays()) { 99 97 if (wayColoring.containsKey(way)) { 100 wayColoring.get(way).add(currentFixVariantLetter); 98 if (!wayColoring.get(way).contains(currentFixVariantLetter)) { 99 wayColoring.get(way).add(currentFixVariantLetter); 100 } 101 101 } else { 102 102 List<Character> letterList = new ArrayList<>(); -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/gui/PTAssistantPaintVisitor.java
r32797 r32801 434 434 * @param color 435 435 */ 436 @SuppressWarnings("unused") 436 437 private void drawFixVariant(List<PTWay> fixVariant, Color color) { 437 438 for (PTWay ptway : fixVariant) { … … 459 460 for (Way way : wayColoring.keySet()) { 460 461 List<Character> letterList = wayColoring.get(way); 461 // if (letterList.size() != numberOfFixVariants) { 462 List<Color> wayColors = new ArrayList<>(); 463 for (Character letter : letterList) { 464 wayColors.add(colors.get(letter)); 465 } 466 for (Pair<Node, Node> nodePair : way.getNodePairs(false)) { 467 drawSegmentWithParallelLines(nodePair.a, nodePair.b, wayColors); 468 } 469 // } 462 List<Color> wayColors = new ArrayList<>(); 463 for (Character letter : letterList) { 464 wayColors.add(colors.get(letter)); 465 } 466 for (Pair<Node, Node> nodePair : way.getNodePairs(false)) { 467 drawSegmentWithParallelLines(nodePair.a, nodePair.b, wayColors); 468 } 470 469 } 471 470 } … … 507 506 } else { 508 507 boolean iterate = true; 509 // while (Math.abs(p2.x - p1.x) > Math.abs(nextPointX - p1.x) && Math.abs(p2.y - p1.y) > Math.abs(nextPointY - p1.y)) {510 // while((p1.x < p2.x && nextPointX < p2.x) || (p1.x >= p2.x && nextPointX >= p2.x)) {511 508 while (iterate) { 512 // for (int i = 0; i < colors.size(); i++) {513 509 currentColor = colors.get(i % colors.size()); 514 // if (Math.abs(p2.x - p1.x) > Math.abs(nextPointX - p1.x)) {515 510 516 511 int[] xPoints = { (int) (prevPointX + cosT), (int) (nextPointX + cosT), (int) (nextPointX - cosT), … … 529 524 iterate = false; 530 525 } 531 532 // }533 // }534 526 } 535 527 … … 544 536 g.setColor(currentColor); 545 537 g.fillOval((int) (p2.x - 9), (int) (p2.y - 9), 18, 18); 546 547 // double cosT = 20*Math.cos(t);548 // double sinT = 20*Math.sin(t);549 // int[] xPointsBasic = { (int) (p1.x + cosT/colors.size()/2), (int)550 // (p2.x + cosT/colors.size()/2),551 // (int) (p2.x - cosT/colors.size()/2), (int) (p1.x -552 // cosT/colors.size()/2) };553 // int[] yPointsBasic = { (int) (p1.y - sinT/colors.size()/2), (int)554 // (p2.y - sinT/colors.size()/2),555 // (int) (p2.y + sinT/colors.size()/2), (int) (p1.y +556 // sinT/colors.size()/2) };557 //558 // for (int i = 0; i < colors.size(); i++) {559 // Polygon polygon = new Polygon(xPointsBasic, yPointsBasic, 4);560 // double halfStripeWidthCos = cosT/colors.size();561 // double halfStripeWidthSin = sinT/colors.size();562 //// polygon.translate((int)(-cosT + halfStripeWidthCos*(2*i+1)),563 // (int)(- sinT + halfStripeWidthSin*(2*i+1)));564 // int deltaX, deltaY;565 // if (cosT > 0) {566 // deltaX = (int)(-cosT + halfStripeWidthCos * (2*i+1));567 // } else {568 // deltaX = (int)(cosT - halfStripeWidthCos * (2*i+1));569 // }570 // if (sinT > 0) {571 // deltaY = (int)(- sinT + halfStripeWidthSin*(2*i+1));572 // } else {573 // deltaY = (int)(sinT - halfStripeWidthSin*(2*i+1));574 // }575 // polygon.translate(deltaX, deltaY);576 // g.setColor(colors.get(i));577 // g.fillPolygon(polygon);578 // }579 538 } 580 539 -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/SegmentChecker.java
r32784 r32801 99 99 * to add to the list of correct segments 100 100 */ 101 public s tatic void addCorrectSegment(PTRouteSegment segment) {101 public synchronized static void addCorrectSegment(PTRouteSegment segment) { 102 102 for (PTRouteSegment correctSegment : correctSegments) { 103 103 if (correctSegment.equalsRouteSegment(segment)) { … … 366 366 } 367 367 368 /** 369 * 370 * @param node 371 * @return 372 */ 368 373 private boolean isDeadendNode(Node node) { 369 374 int count = 0; … … 692 697 // layer, clear them: 693 698 ((PTAssistantValidatorTest) testError.getTester()).clearFixVariants(); 694 699 695 700 PTRouteSegment wrongSegment = wrongSegments.get(testError); 696 701 … … 698 703 List<PTRouteSegment> correctSegmentsForThisError = new ArrayList<>(); 699 704 for (PTRouteSegment segment : correctSegments) { 700 if (wrongSegment.getFirst Stop().equalsStop(segment.getFirstStop())701 && wrongSegment.getLast Stop().equalsStop(segment.getLastStop())) {705 if (wrongSegment.getFirstWay().getId() == segment.getFirstWay().getId() 706 && wrongSegment.getLastWay().getId() == segment.getLastWay().getId()) { 702 707 correctSegmentsForThisError.add(segment); 708 } 709 } 710 711 // if no correct segment found, apply less strict criteria to look for one: 712 if (correctSegmentsForThisError.isEmpty() && wrongSegment.getFixVariants().isEmpty()) { 713 for (PTRouteSegment segment : correctSegments) { 714 if (wrongSegment.getFirstStop().equalsStop(segment.getFirstStop()) 715 && wrongSegment.getLastStop().equalsStop(segment.getLastStop())) { 716 correctSegmentsForThisError.add(segment); 717 } 718 } 719 if (!correctSegmentsForThisError.isEmpty()) { 720 // display the notification: 721 if (SwingUtilities.isEventDispatchThread()) { 722 Notification notification = new Notification( 723 tr("Warning: the diplayed fix variants are based on less strict criteria")); 724 notification.show(); 725 } else { 726 SwingUtilities.invokeLater(new Runnable() { 727 @Override 728 public void run() { 729 Notification notification = new Notification( 730 tr("Warning: the diplayed fix variants are based on less strict criteria")); 731 notification.show(); 732 } 733 }); 734 } 703 735 } 704 736 } … … 835 867 PTRouteSegment wrongSegment = wrongSegments.get(testError); 836 868 wrongSegments.remove(testError); 837 wrongSegment.setPTWays( wrongSegment.getFixVariants().get(0));869 wrongSegment.setPTWays(fix); 838 870 addCorrectSegment(wrongSegment); 839 871 }
Note:
See TracChangeset
for help on using the changeset viewer.