Changeset 2460 in josm
- Timestamp:
- 2009-11-15T15:28:15+01:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data/osm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
r2452 r2460 874 874 875 875 876 // TODO Should be part of validator 877 // This used to be OsmPrimitive.errors. I don't really like that such information is kept here, 878 // but at least it's not such memory waste as having it in (every) OsmPrimitive 876 // TODO Should be completely part of validator 879 877 private Map<OsmPrimitive, List<String>> errors = new HashMap<OsmPrimitive, List<String>>(); 880 878 881 void setErrors(OsmPrimitive primitive, List<String> errors) { 882 if (errors != null && !errors.isEmpty()) { 883 this.errors.put(primitive, errors); 884 } else { 885 this.errors.remove(primitive); 886 } 879 public void addError(OsmPrimitive primitive, String error) { 880 List<String> perrors = errors.get(primitive); 881 if (perrors == null) { 882 perrors = new ArrayList<String>(); 883 } 884 perrors.add(error); 885 errors.put(primitive, perrors); 887 886 } 888 887 … … 890 889 return errors.get(primitive); 891 890 } 891 892 public void clearErrors() 893 { 894 errors.clear(); 895 } 892 896 } -
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
r2459 r2460 99 99 public Integer mappaintDrawnCode = 0; 100 100 101 public void putError(String text, boolean isError)102 {103 checkDataset();104 List<String> errors = dataSet.getErrors(this);105 if (errors == null) {106 errors = new ArrayList<String>();107 }108 String s = isError ? tr("Error: {0}", text) : tr("Warning: {0}", text);109 errors.add(s);110 dataSet.setErrors(this, errors);111 }112 public void clearErrors()113 {114 if (dataSet != null) {115 dataSet.setErrors(this, null);116 }117 }118 119 public List<String> getErrors() {120 if (dataSet == null)121 return null;122 else123 return dataSet.getErrors(this);124 }125 101 /* This should not be called from outside. Fixing the UI to add relevant 126 102 get/set functions calling this implicitely is preferred, so we can have … … 154 130 155 131 /** 156 * 132 * 157 133 * @return DataSet this primitive is part of. 158 134 */ … … 736 712 * Find primitives that reference this primitive. Returns only primitives that are included in the same 737 713 * dataset as this primitive. <br> 738 * 714 * 739 715 * For example following code will add wnew as referer to all nodes of existingWay, but this method will 740 716 * not return wnew because it's not part of the dataset <br> 741 * 717 * 742 718 * <code>Way wnew = new Way(existingWay)</code> 743 * 719 * 744 720 * @return a collection of all primitives that reference this primitive. 745 721 */ … … 809 785 /** 810 786 * Merges the technical and semantical attributes from <code>other</code> onto this. 811 * 787 * 812 788 * Both this and other must be new, or both must be assigned an OSM ID. If both this and <code>other</code> 813 789 * have an assigend OSM id, the IDs have to be the same. 814 * 790 * 815 791 * @param other the other primitive. Must not be null. 816 792 * @throws IllegalArgumentException thrown if other is null. … … 1032 1008 /** 1033 1009 * Replies the unique primitive id for this primitive 1034 * 1010 * 1035 1011 * @return the unique primitive id for this primitive 1036 1012 */ -
trunk/src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java
r2452 r2460 217 217 return; 218 218 219 if(fillAreas > dist) {220 w.clearErrors();221 }222 223 219 if(wayStyle==null) 224 220 { … … 246 242 drawArea(w, data.isSelected(w) ? selectedColor : areaStyle.color); 247 243 if(!w.isClosed()) { 248 w.putError(tr("Area style way is not closed."), true);244 putError(w, tr("Area style way is not closed."), true); 249 245 } 250 246 } … … 479 475 if(errs != null) 480 476 { 481 errs.putError(tr("multipolygon way ''{0}'' is not closed.",477 putError(errs, tr("multipolygon way ''{0}'' is not closed.", 482 478 w.getDisplayName(DefaultNameFormatter.getInstance())), true); 483 479 } … … 556 552 // System.out.println("Restriction: " + r.keys.get("name") + " restriction " + r.keys.get("restriction")); 557 553 558 r.clearErrors();559 560 554 Way fromWay = null; 561 555 Way toWay = null; … … 569 563 570 564 if (m.getMember().isDeleted()) { 571 r.putError(tr("Deleted member ''{0}'' in relation.",565 putError(r, tr("Deleted member ''{0}'' in relation.", 572 566 m.getMember().getDisplayName(DefaultNameFormatter.getInstance())), true); 573 567 } else if(m.getMember().incomplete) … … 580 574 if(w.getNodesCount() < 2) 581 575 { 582 r.putError(tr("Way ''{0}'' with less than two points.",576 putError(r, tr("Way ''{0}'' with less than two points.", 583 577 w.getDisplayName(DefaultNameFormatter.getInstance())), true); 584 578 } 585 579 else if("from".equals(m.getRole())) { 586 580 if(fromWay != null) { 587 r.putError(tr("More than one \"from\" way found."), true);581 putError(r, tr("More than one \"from\" way found."), true); 588 582 } else { 589 583 fromWay = w; … … 591 585 } else if("to".equals(m.getRole())) { 592 586 if(toWay != null) { 593 r.putError(tr("More than one \"to\" way found."), true);587 putError(r, tr("More than one \"to\" way found."), true); 594 588 } else { 595 589 toWay = w; … … 597 591 } else if("via".equals(m.getRole())) { 598 592 if(via != null) { 599 r.putError(tr("More than one \"via\" found."), true);593 putError(r, tr("More than one \"via\" found."), true); 600 594 } else { 601 595 via = w; 602 596 } 603 597 } else { 604 r.putError(tr("Unknown role ''{0}''.", m.getRole()), true);598 putError(r, tr("Unknown role ''{0}''.", m.getRole()), true); 605 599 } 606 600 } … … 611 605 { 612 606 if(via != null) { 613 r.putError(tr("More than one \"via\" found."), true);607 putError(r, tr("More than one \"via\" found."), true); 614 608 } else { 615 609 via = n; 616 610 } 617 611 } else { 618 r.putError(tr("Unknown role ''{0}''.", m.getRole()), true);612 putError(r, tr("Unknown role ''{0}''.", m.getRole()), true); 619 613 } 620 614 } else { 621 r.putError(tr("Unknown member type for ''{0}''.", m.getMember().getDisplayName(DefaultNameFormatter.getInstance())), true);615 putError(r, tr("Unknown member type for ''{0}''.", m.getMember().getDisplayName(DefaultNameFormatter.getInstance())), true); 622 616 } 623 617 } … … 625 619 626 620 if (fromWay == null) { 627 r.putError(tr("No \"from\" way found."), true);621 putError(r, tr("No \"from\" way found."), true); 628 622 return; 629 623 } 630 624 if (toWay == null) { 631 r.putError(tr("No \"to\" way found."), true);625 putError(r, tr("No \"to\" way found."), true); 632 626 return; 633 627 } 634 628 if (via == null) { 635 r.putError(tr("No \"via\" node or way found."), true);629 putError(r, tr("No \"via\" node or way found."), true); 636 630 return; 637 631 } … … 642 636 viaNode = (Node) via; 643 637 if(!fromWay.isFirstLastNode(viaNode)) { 644 r.putError(tr("The \"from\" way doesn't start or end at a \"via\" node."), true);638 putError(r, tr("The \"from\" way doesn't start or end at a \"via\" node."), true); 645 639 return; 646 640 } 647 641 if(!toWay.isFirstLastNode(viaNode)) { 648 r.putError(tr("The \"to\" way doesn't start or end at a \"via\" node."), true);642 putError(r, tr("The \"to\" way doesn't start or end at a \"via\" node."), true); 649 643 } 650 644 } … … 673 667 viaNode = lastNode; 674 668 } else { 675 r.putError(tr("The \"from\" way doesn't start or end at the \"via\" way."), true);669 putError(r, tr("The \"from\" way doesn't start or end at the \"via\" way."), true); 676 670 return; 677 671 } 678 672 if(!toWay.isFirstLastNode(viaNode == firstNode ? lastNode : firstNode)) { 679 r.putError(tr("The \"to\" way doesn't start or end at the \"via\" way."), true);673 putError(r, tr("The \"to\" way doesn't start or end at the \"via\" way."), true); 680 674 } 681 675 } … … 800 794 801 795 if (nodeStyle == null) { 802 r.putError(tr("Style for restriction {0} not found.", r.get("restriction")), true);796 putError(r, tr("Style for restriction {0} not found.", r.get("restriction")), true); 803 797 return; 804 798 } … … 894 888 if(c > 1 && pdOuter.way != null && pdOuter.way.isClosed()) 895 889 { 896 r.putError(tr("Intersection between ways ''{0}'' and ''{1}''.",890 putError(r, tr("Intersection between ways ''{0}'' and ''{1}''.", 897 891 pdOuter.way.getDisplayName(DefaultNameFormatter.getInstance()), wInner.getDisplayName(DefaultNameFormatter.getInstance())), true); 898 892 } … … 906 900 if(!incomplete) 907 901 { 908 r.putError(tr("Inner way ''{0}'' is outside.",902 putError(r, tr("Inner way ''{0}'' is outside.", 909 903 wInner.getDisplayName(DefaultNameFormatter.getInstance())), true); 910 904 } … … 922 916 Boolean drawn = false; 923 917 924 r.clearErrors();925 926 918 for (RelationMember m : r.getMembers()) 927 919 { 928 920 if (m.getMember().isDeleted()) { 929 r.putError(tr("Deleted member ''{0}'' in relation.",921 putError(r, tr("Deleted member ''{0}'' in relation.", 930 922 m.getMember().getDisplayName(DefaultNameFormatter.getInstance())), true); 931 923 } else if(m.getMember().incomplete) { … … 935 927 Way w = m.getWay(); 936 928 if(w.getNodesCount() < 2) { 937 r.putError(tr("Way ''{0}'' with less than two points.",929 putError(r, tr("Way ''{0}'' with less than two points.", 938 930 w.getDisplayName(DefaultNameFormatter.getInstance())), true); 939 931 } … … 943 935 outer.add(w); 944 936 } else { 945 r.putError(tr("No useful role ''{0}'' for Way ''{1}''.",937 putError(r, tr("No useful role ''{0}'' for Way ''{1}''.", 946 938 m.getRole(), w.getDisplayName(DefaultNameFormatter.getInstance())), true); 947 939 if(!m.hasRole()) { … … 955 947 else 956 948 { 957 r.putError(tr("Non-Way ''{0}'' in multipolygon.",949 putError(r, tr("Non-Way ''{0}'' in multipolygon.", 958 950 m.getMember().getDisplayName(DefaultNameFormatter.getInstance())), true); 959 951 } … … 999 991 if(outerclosed.size() == 0 && outerjoin.size() == 0) 1000 992 { 1001 r.putError(tr("No outer way for multipolygon ''{0}''.",993 putError(r, tr("No outer way for multipolygon ''{0}''.", 1002 994 r.getDisplayName(DefaultNameFormatter.getInstance())), true); 1003 995 visible = true; /* prevent killing remaining ways */ … … 1059 1051 if(wayStyle.equals(innerStyle)) 1060 1052 { 1061 r.putError(tr("Style for inner way ''{0}'' equals multipolygon.",1053 putError(r, tr("Style for inner way ''{0}'' equals multipolygon.", 1062 1054 wInner.getDisplayName(DefaultNameFormatter.getInstance())), false); 1063 1055 if(!data.isSelected(r)) { … … 1089 1081 && !wayStyle.equals(outerStyle)) 1090 1082 { 1091 r.putError(tr("Style for outer way ''{0}'' mismatches.",1083 putError(r, tr("Style for outer way ''{0}'' mismatches.", 1092 1084 wOuter.getDisplayName(DefaultNameFormatter.getInstance())), true); 1093 1085 } … … 1464 1456 maxEN = nc.getEastNorth(nc.getWidth() - 1, 0); 1465 1457 1458 data.clearErrors(); 1466 1459 1467 1460 ++paintid; … … 1645 1638 drawOrderNumber(p1, p2, orderNumber); 1646 1639 } 1640 1641 public void putError(OsmPrimitive p, String text, boolean isError) 1642 { 1643 data.addError(p, isError ? tr("Error: {0}", text) : tr("Warning: {0}", text)); 1644 } 1647 1645 }
Note:
See TracChangeset
for help on using the changeset viewer.