Changeset 8743 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2015-09-10T09:00:45+02:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data/validation/tests
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/tests/UntaggedNode.java
r8378 r8743 9 9 10 10 import org.openstreetmap.josm.command.Command; 11 import org.openstreetmap.josm.data.osm.AbstractPrimitive; 11 12 import org.openstreetmap.josm.data.osm.Node; 12 13 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 20 21 * @author frsantos 21 22 */ 22 public class UntaggedNode extends Test {23 public class UntaggedNode extends Test implements AbstractPrimitive.KeyValueVisitor { 23 24 24 25 protected static final int UNTAGGED_NODE_BLANK = 201; … … 29 30 protected static final int UNTAGGED_NODE_SOURCE = 206; 30 31 protected static final int UNTAGGED_NODE_OTHER = 207; 32 protected static final String ERROR_MESSAGE = tr("Unconnected nodes without physical tags"); 31 33 32 34 /** … … 50 52 public void visit(Node n) { 51 53 if (n.isUsable() && !n.isTagged() && n.getReferrers().isEmpty()) { 52 String errorMessage = tr("Unconnected nodes without physical tags"); 54 53 55 if (!n.hasKeys()) { 54 56 String msg = marktr("No tags"); 55 errors.add(new TestError(this, Severity.WARNING, errorMessage, tr(msg), msg, UNTAGGED_NODE_BLANK, n));57 errors.add(new TestError(this, Severity.WARNING, ERROR_MESSAGE, tr(msg), msg, UNTAGGED_NODE_BLANK, n)); 56 58 return; 57 59 } 58 for (Map.Entry<String, String> tag : n.getKeys().entrySet()) { 59 String key = tag.getKey(); 60 if (contains(tag, "fixme") || contains(tag, "FIXME")) { 61 /* translation note: don't translate quoted words */ 62 String msg = marktr("Has tag containing ''fixme'' or ''FIXME''"); 63 errors.add(new TestError(this, Severity.WARNING, errorMessage, tr(msg), msg, UNTAGGED_NODE_FIXME, n)); 64 return; 65 } 60 n.visitKeys(this); 61 } 62 } 66 63 67 String msg = null; 68 int code = 0; 69 if (key.startsWith("note") || key.startsWith("comment") || key.startsWith("description")) { 70 /* translation note: don't translate quoted words */ 71 msg = marktr("Has key ''note'' or ''comment'' or ''description''"); 72 code = UNTAGGED_NODE_NOTE; 73 } else if (key.startsWith("created_by") || key.startsWith("converted_by")) { 74 /* translation note: don't translate quoted words */ 75 msg = marktr("Has key ''created_by'' or ''converted_by''"); 76 code = UNTAGGED_NODE_CREATED_BY; 77 } else if (key.startsWith("watch")) { 78 /* translation note: don't translate quoted words */ 79 msg = marktr("Has key ''watch''"); 80 code = UNTAGGED_NODE_WATCH; 81 } else if (key.startsWith("source")) { 82 /* translation note: don't translate quoted words */ 83 msg = marktr("Has key ''source''"); 84 code = UNTAGGED_NODE_SOURCE; 85 } 86 if (msg != null) { 87 errors.add(new TestError(this, Severity.WARNING, errorMessage, tr(msg), msg, code, n)); 88 return; 89 } 90 } 91 // Does not happen, but just to be sure. Maybe definition of uninteresting tags changes in future. 92 errors.add(new TestError(this, Severity.WARNING, errorMessage, tr("Other"), "Other", UNTAGGED_NODE_OTHER, n)); 64 @Override 65 public void visitKeyValue(AbstractPrimitive n, String key, String value) { 66 if (key.toLowerCase().contains("fixme") || value.toLowerCase().contains("fixme")) { 67 /* translation note: don't translate quoted words */ 68 String msg = marktr("Has tag containing ''fixme'' or ''FIXME''"); 69 errors.add(new TestError(this, Severity.WARNING, ERROR_MESSAGE, tr(msg), msg, UNTAGGED_NODE_FIXME, (OsmPrimitive) n)); 70 return; 93 71 } 72 73 String msg = null; 74 int code = 0; 75 if (key.startsWith("note") || key.startsWith("comment") || key.startsWith("description")) { 76 /* translation note: don't translate quoted words */ 77 msg = marktr("Has key ''note'' or ''comment'' or ''description''"); 78 code = UNTAGGED_NODE_NOTE; 79 } else if (key.startsWith("created_by") || key.startsWith("converted_by")) { 80 /* translation note: don't translate quoted words */ 81 msg = marktr("Has key ''created_by'' or ''converted_by''"); 82 code = UNTAGGED_NODE_CREATED_BY; 83 } else if (key.startsWith("watch")) { 84 /* translation note: don't translate quoted words */ 85 msg = marktr("Has key ''watch''"); 86 code = UNTAGGED_NODE_WATCH; 87 } else if (key.startsWith("source")) { 88 /* translation note: don't translate quoted words */ 89 msg = marktr("Has key ''source''"); 90 code = UNTAGGED_NODE_SOURCE; 91 } 92 if (msg != null) { 93 errors.add(new TestError(this, Severity.WARNING, ERROR_MESSAGE, tr(msg), msg, code, (OsmPrimitive) n)); 94 return; 95 } 96 // Does not happen, but just to be sure. Maybe definition of uninteresting tags changes in future. 97 errors.add(new TestError(this, Severity.WARNING, ERROR_MESSAGE, tr("Other"), "Other", UNTAGGED_NODE_OTHER, (OsmPrimitive) n)); 94 98 } 95 99 -
trunk/src/org/openstreetmap/josm/data/validation/tests/UntaggedWay.java
r8510 r8743 83 83 boolean isJunction = false; 84 84 boolean hasName = false; 85 for (String key : w.keySet()) {85 for (String key : tags.keySet()) { 86 86 hasName = key.startsWith("name:") || key.endsWith("_name") || key.endsWith("_ref"); 87 87 if (hasName) {
Note:
See TracChangeset
for help on using the changeset viewer.