Changeset 4769 in josm for trunk/src/org
- Timestamp:
- 2012-01-07T22:37:19+01:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/tests/RelationChecker.java
r3673 r4769 10 10 import java.util.LinkedList; 11 11 12 import org.openstreetmap.josm.data.osm.Node; 13 import org.openstreetmap.josm.data.osm.OsmPrimitive; 12 14 import org.openstreetmap.josm.data.osm.Relation; 13 15 import org.openstreetmap.josm.data.osm.RelationMember; 16 import org.openstreetmap.josm.data.osm.Way; 14 17 import org.openstreetmap.josm.data.validation.Severity; 15 18 import org.openstreetmap.josm.data.validation.Test; … … 69 72 public class RoleInfo { 70 73 int total = 0; 71 int nodes = 0;72 int ways = 0;73 int closedways = 0;74 int openways = 0;75 int relations = 0;74 Collection<Node> nodes = new LinkedList<Node>(); 75 Collection<Way> ways = new LinkedList<Way>(); 76 Collection<Way> closedways = new LinkedList<Way>(); 77 Collection<Way> openways = new LinkedList<Way>(); 78 Collection<Relation> relations = new LinkedList<Relation>(); 76 79 } 77 80 … … 113 116 ri.total++; 114 117 if (m.isRelation()) { 115 ri.relations ++;118 ri.relations.add(m.getRelation()); 116 119 } else if(m.isWay()) { 117 ri.ways ++;120 ri.ways.add(m.getWay()); 118 121 if (m.getWay().isClosed()) { 119 ri.closedways ++;122 ri.closedways.add(m.getWay()); 120 123 } else { 121 ri.openways ++;124 ri.openways.add(m.getWay()); 122 125 } 123 126 } 124 127 else if (m.isNode()) { 125 ri.nodes ++;128 ri.nodes.add(m.getNode()); 126 129 } 127 130 map.put(s, ri); … … 157 160 } 158 161 } 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) ); 162 if (ri != null) { 163 Collection<OsmPrimitive> wrongTypes = new LinkedList<OsmPrimitive>(); 164 if (!r.types.contains(PresetType.WAY)) { 165 wrongTypes.addAll(r.types.contains(PresetType.CLOSEDWAY) ? ri.openways : ri.ways); 166 } 167 if (!r.types.contains(PresetType.NODE)) { 168 wrongTypes.addAll(ri.nodes); 169 } 170 if (!r.types.contains(PresetType.RELATION)) { 171 wrongTypes.addAll(ri.relations); 172 } 173 if (!wrongTypes.isEmpty()) { 174 String s = marktr("Member for role {0} of wrong type"); 175 LinkedList<OsmPrimitive> highlight = new LinkedList<OsmPrimitive>(wrongTypes); 176 highlight.addFirst(n); 177 errors.add(new TestError(this, Severity.WARNING, tr("Role verification problem"), 178 tr(s, keyname), MessageFormat.format(s, keyname), WRONG_TYPE, 179 highlight, wrongTypes)); 180 } 165 181 } 166 182 }
Note:
See TracChangeset
for help on using the changeset viewer.