Ticket #5706: 5706.patch
| File 5706.patch, 7.3 KB (added by , 15 years ago) |
|---|
-
data/defaultpresets.xml
diff --git a/data/defaultpresets.xml b/data/defaultpresets.xml index db9d63a..51ad2fc 100755
a b check: checkbox 78 78 value_off: the value to set when unchecked (default is 'no') 79 79 80 80 role: type to specify possible roles in relations 81 key: the role nameused in relation81 key: comma separated list of role names used in relation 82 82 text: fixed label to display 83 83 requisite: "optional" or "required" (default is optional) 84 84 count: how often can the role occur (if not given unlimited number is assumed) … … are supplied, then "values" will be treated as "display_values" and translated i 4160 4160 </optional> 4161 4161 <roles> 4162 4162 <role key="" text="route segment" requisite="optional" type="way" /> 4163 <role key="forward" text="forward segment" requisite="optional" type="way" /> 4164 <role key="backward" text="backward segment" requisite="optional" type="way" /> 4163 <role key="forward,backward" text="forward/backward segment" requisite="optional" type="way" /> 4165 4164 <role key="stop" text="halt point" requisite="optional" type="node" /> 4166 <role key="forward_stop " text="forwardhalt point" requisite="optional" type="node" />4167 <role key=" backward_stop" text="backward halt point" requisite="optional" type="node" />4165 <role key="forward_stop,backward_stop" text="forward/backward_stop halt point" requisite="optional" type="node" /> 4166 <role key="north,south,east,west" text="(for North America)" requisite="optional" type="way" /> 4168 4167 </roles> 4169 4168 </item> 4170 4169 <item name="Route network" icon="presets/path.png" type="relation"> -
src/org/openstreetmap/josm/data/validation/tests/RelationChecker.java
diff --git a/src/org/openstreetmap/josm/data/validation/tests/RelationChecker.java b/src/org/openstreetmap/josm/data/validation/tests/RelationChecker.java index 7279e34..a7fc790 100644
a b public class RelationChecker extends Test { 109 109 RoleInfo ri = map.get(s); 110 110 if (ri == null) { 111 111 ri = new RoleInfo(); 112 map.put(s, ri); 112 113 } 113 114 ri.total++; 114 115 if (m.isRelation()) { … … public class RelationChecker extends Test { 124 125 else if (m.isNode()) { 125 126 ri.nodes++; 126 127 } 127 map.put(s, ri);128 128 } 129 129 if(map.isEmpty()) { 130 130 errors.add( new TestError(this, Severity.ERROR, tr("Relation is empty"), … … public class RelationChecker extends Test { 132 132 } else { 133 133 LinkedList<String> done = new LinkedList<String>(); 134 134 for (TaggingPreset.Role r : allroles) { 135 done.add(r.key); 136 String keyname = r.key; 137 if ("".equals(keyname)) { 138 keyname = tr("<empty>"); 139 } 140 RoleInfo ri = map.get(r.key); 141 long count = (ri == null) ? 0 : ri.total; 142 long vc = r.getValidCount(count); 143 if (count != vc) { 144 if (count == 0) { 145 String s = marktr("Role {0} missing"); 146 errors.add(new TestError(this, Severity.WARNING, tr("Role verification problem"), 147 tr(s, keyname), MessageFormat.format(s, keyname), ROLE_MISSING, n)); 135 for (String keyname : r.key.split(",")) { 136 keyname = keyname.trim(); 137 done.add(keyname); 138 RoleInfo ri = map.get(keyname); 139 if ("".equals(keyname)) { 140 keyname = tr("<empty>"); 148 141 } 149 else if (vc > count) { 150 String s = marktr("Number of {0} roles too low ({1})"); 151 errors.add(new TestError(this, Severity.WARNING, tr("Role verification problem"), 152 tr(s, keyname, count), MessageFormat.format(s, keyname, count), LOW_COUNT, n)); 153 } else { 154 String s = marktr("Number of {0} roles too high ({1})"); 155 errors.add(new TestError(this, Severity.WARNING, tr("Role verification problem"), 156 tr(s, keyname, count), MessageFormat.format(s, keyname, count), HIGH_COUNT, n)); 142 long count = (ri == null) ? 0 : ri.total; 143 long vc = r.getValidCount(count); 144 if (count != vc) { 145 if (count == 0) { 146 String s = marktr("Role {0} missing"); 147 errors.add(new TestError(this, Severity.WARNING, tr("Role verification problem"), 148 tr(s, keyname), MessageFormat.format(s, keyname), ROLE_MISSING, n)); 149 } 150 else if (vc > count) { 151 String s = marktr("Number of {0} roles too low ({1})"); 152 errors.add(new TestError(this, Severity.WARNING, tr("Role verification problem"), 153 tr(s, keyname, count), MessageFormat.format(s, keyname, count), LOW_COUNT, n)); 154 } else { 155 String s = marktr("Number of {0} roles too high ({1})"); 156 errors.add(new TestError(this, Severity.WARNING, tr("Role verification problem"), 157 tr(s, keyname, count), MessageFormat.format(s, keyname, count), HIGH_COUNT, n)); 158 } 159 } 160 if (ri != null && ((!r.types.contains(PresetType.WAY) && (r.types.contains(PresetType.CLOSEDWAY) ? ri.openways > 0 : ri.ways > 0)) 161 || (!r.types.contains(PresetType.NODE) && ri.nodes > 0) || (!r.types.contains(PresetType.RELATION) && ri.relations > 0))) 162 { 163 String s = marktr("Member for role {0} of wrong type"); 164 errors.add( new TestError(this, Severity.WARNING, tr("Role verification problem"), 165 tr(s, keyname), MessageFormat.format(s, keyname), WRONG_TYPE, n) ); 157 166 } 158 }159 if (ri != null && ((!r.types.contains(PresetType.WAY) && (r.types.contains(PresetType.CLOSEDWAY) ? ri.openways > 0 : ri.ways > 0))160 || (!r.types.contains(PresetType.NODE) && ri.nodes > 0) || (!r.types.contains(PresetType.RELATION) && ri.relations > 0)))161 {162 String s = marktr("Member for role {0} of wrong type");163 errors.add( new TestError(this, Severity.WARNING, tr("Role verification problem"),164 tr(s, keyname), MessageFormat.format(s, keyname), WRONG_TYPE, n) );165 167 } 166 168 } 167 169 for (String key : map.keySet()) {
