Changeset 6240 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2013-09-20T22:44:07+02:00 (11 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data/validation/tests
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/tests/Addresses.java
r6069 r6240 54 54 this(code, collection, message, null, null); 55 55 } 56 public AddressError(int code, Collection<OsmPrimitive> collection, String message, String description, String description_en) {57 super(Addresses.this, Severity.WARNING, message, description, description_en, code, collection);56 public AddressError(int code, Collection<OsmPrimitive> collection, String message, String description, String englishDescription) { 57 super(Addresses.this, Severity.WARNING, message, description, englishDescription, code, collection); 58 58 } 59 59 } … … 146 146 } 147 147 // Report duplicate house numbers 148 String description_en = marktr("House number ''{0}'' duplicated");148 String englishDescription = marktr("House number ''{0}'' duplicated"); 149 149 for (String key : map.keySet()) { 150 150 List<OsmPrimitive> list = map.get(key); 151 151 if (list.size() > 1) { 152 152 errors.add(new AddressError(DUPLICATE_HOUSE_NUMBER, list, 153 tr("Duplicate house numbers"), tr( description_en, key), description_en));153 tr("Duplicate house numbers"), tr(englishDescription, key), englishDescription)); 154 154 } 155 155 } -
trunk/src/org/openstreetmap/josm/data/validation/tests/BuildingInBuilding.java
r6069 r6240 25 25 import org.openstreetmap.josm.tools.Predicate; 26 26 27 /** 28 * Checks for building areas inside of buildings 29 * @since 4409 30 */ 27 31 public class BuildingInBuilding extends Test { 28 32 29 33 protected static final int BUILDING_INSIDE_BUILDING = 2001; 30 pr otectedList<OsmPrimitive> primitivesToCheck = new LinkedList<OsmPrimitive>();31 pr otectedQuadBuckets<Way> index = new QuadBuckets<Way>();34 private final List<OsmPrimitive> primitivesToCheck = new LinkedList<OsmPrimitive>(); 35 private final QuadBuckets<Way> index = new QuadBuckets<Way>(); 32 36 37 /** 38 * Constructs a new {@code BuildingInBuilding} test. 39 */ 33 40 public BuildingInBuilding() { 34 41 super(tr("Building inside building"), tr("Checks for building areas inside of buildings.")); … … 67 74 68 75 protected class MultiPolygonMembers { 69 p ublicfinal Set<Way> outers = new HashSet<Way>();70 p ublicfinal Set<Way> inners = new HashSet<Way>();76 private final Set<Way> outers = new HashSet<Way>(); 77 private final Set<Way> inners = new HashSet<Way>(); 71 78 public MultiPolygonMembers(Relation multiPolygon) { 72 79 for (RelationMember m : multiPolygon.getMembers()) { … … 144 151 // Else, test if w is inside one of the multipolygons 145 152 for (OsmPrimitive bmp : buildingMultiPolygons) { 146 if (bmp instanceof Relation) { 147 if (isWayInsideMultiPolygon(w, (Relation) bmp)) { 148 return true; 149 } 153 if (bmp instanceof Relation && isWayInsideMultiPolygon(w, (Relation) bmp)) { 154 return true; 150 155 } 151 156 } -
trunk/src/org/openstreetmap/josm/data/validation/tests/CrossingWays.java
r6089 r6240 12 12 import java.util.List; 13 13 import java.util.Map; 14 import java.util.Set; 14 15 15 16 import org.openstreetmap.josm.data.osm.Node; … … 32 33 33 34 /** All way segments, grouped by cells */ 34 Map<Point2D,List<ExtendedSegment>> cellSegments;35 private Map<Point2D,List<ExtendedSegment>> cellSegments; 35 36 /** The already detected errors */ 36 HashSet<WaySegment> errorSegments;37 private Set<WaySegment> errorSegments; 37 38 /** The already detected ways in error */ 38 Map<List<Way>, List<WaySegment>> ways_seen;39 private Map<List<Way>, List<WaySegment>> seenWays; 39 40 40 41 /** … … 51 52 cellSegments = new HashMap<Point2D,List<ExtendedSegment>>(1000); 52 53 errorSegments = new HashSet<WaySegment>(); 53 ways_seen= new HashMap<List<Way>, List<WaySegment>>(50);54 seenWays = new HashMap<List<Way>, List<WaySegment>>(50); 54 55 } 55 56 … … 59 60 cellSegments = null; 60 61 errorSegments = null; 61 ways_seen= null;62 seenWays = null; 62 63 } 63 64 … … 90 91 WaySegment ws = new WaySegment(w, i); 91 92 ExtendedSegment es1 = new ExtendedSegment(ws, layer1, railway1, isCoastline1, waterway1); 92 List<List<ExtendedSegment>> cellSegments = getSegments(es1.n1, es1.n2); 93 for (List<ExtendedSegment> segments : cellSegments) { 93 for (List<ExtendedSegment> segments : getSegments(es1.n1, es1.n2)) { 94 94 for (ExtendedSegment es2 : segments) { 95 95 List<Way> prims; … … 130 130 131 131 prims = Arrays.asList(es1.ws.way, es2.ws.way); 132 if ((highlight = ways_seen.get(prims)) == null) {132 if ((highlight = seenWays.get(prims)) == null) { 133 133 highlight = new ArrayList<WaySegment>(); 134 134 highlight.add(es1.ws); … … 152 152 prims, 153 153 highlight)); 154 ways_seen.put(prims, highlight);154 seenWays.put(prims, highlight); 155 155 } else { 156 156 highlight.add(es1.ws); … … 187 187 /** 188 188 * A way segment with some additional information 189 * @author frsantos190 189 */ 191 190 public static class ExtendedSegment { 192 p ublicNode n1, n2;193 194 p ublicWaySegment ws;191 private Node n1, n2; 192 193 private WaySegment ws; 195 194 196 195 /** The layer */ 197 p ublicString layer;196 private String layer; 198 197 199 198 /** The railway type */ 200 p ublicString railway;199 private String railway; 201 200 202 201 /** The waterway type */ 203 p ublicString waterway;202 private String waterway; 204 203 205 204 /** The coastline type */ 206 p ublicboolean coastline;205 private boolean coastline; 207 206 208 207 /** -
trunk/src/org/openstreetmap/josm/data/validation/tests/DeprecatedTags.java
r6238 r6240 155 155 private static class DeprecationCheck { 156 156 157 int code;158 List<Tag> test = new LinkedList<Tag>();159 List<Tag> change = new LinkedList<Tag>();160 List<Tag> alternatives = new LinkedList<Tag>();157 private int code; 158 private final List<Tag> test = new LinkedList<Tag>(); 159 private final List<Tag> change = new LinkedList<Tag>(); 160 private final List<Tag> alternatives = new LinkedList<Tag>(); 161 161 162 162 public DeprecationCheck(int code) { … … 230 230 private class DeprecationError extends TestError { 231 231 232 OsmPrimitive p;233 DeprecationCheck check;234 235 DeprecationError(OsmPrimitive p, DeprecationCheck check) {232 private OsmPrimitive p; 233 private DeprecationCheck check; 234 235 public DeprecationError(OsmPrimitive p, DeprecationCheck check) { 236 236 super(DeprecatedTags.this, Severity.WARNING, check.getDescription(), check.code, p); 237 237 this.p = p; -
trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateNode.java
r6069 r6240 43 43 private static class NodeHash implements Hash<Object, Object> { 44 44 45 double precision = Main.pref.getDouble("validator.duplicatenodes.precision", 0.);45 private double precision = Main.pref.getDouble("validator.duplicatenodes.precision", 0.); 46 46 47 47 private LatLon roundCoord(LatLon coor) { … … 104 104 * <pos, NodesByEqualTagsMap> 105 105 */ 106 Storage<Object> potentialDuplicates;106 private Storage<Object> potentialDuplicates; 107 107 108 108 /** -
trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateRelation.java
r6104 r6240 51 51 52 52 /** ID of the relation member in case it is a {@link Relation} */ 53 private long rel _id;53 private long relId; 54 54 55 55 @Override 56 56 public int hashCode() { 57 return role.hashCode()+(int)rel _id+tags.hashCode()+type.hashCode()+coor.hashCode();57 return role.hashCode()+(int)relId+tags.hashCode()+type.hashCode()+coor.hashCode(); 58 58 } 59 59 … … 62 62 if (!(obj instanceof RelMember)) return false; 63 63 RelMember rm = (RelMember) obj; 64 return rm.role.equals(role) && rm.type.equals(type) && rm.rel _id==rel_id && rm.tags.equals(tags) && rm.coor.equals(coor);64 return rm.role.equals(role) && rm.type.equals(type) && rm.relId==relId && rm.tags.equals(tags) && rm.coor.equals(coor); 65 65 } 66 66 … … 71 71 role = src.getRole(); 72 72 type = src.getType(); 73 rel _id = 0;73 relId = 0; 74 74 coor = new ArrayList<LatLon>(); 75 75 … … 92 92 Relation r = src.getRelation(); 93 93 tags = r.getKeys(); 94 rel _id = r.getId();94 relId = r.getId(); 95 95 coor = new ArrayList<LatLon>(); 96 96 } … … 103 103 private class RelationMembers { 104 104 /** List of member objects of the relation */ 105 p ublicList<RelMember> members;105 private List<RelMember> members; 106 106 107 107 /** Store relation information … … 133 133 private class RelationPair { 134 134 /** Member objects of the relation */ 135 p ublicRelationMembers members;135 private RelationMembers members; 136 136 /** Tags of the relation */ 137 p ublicMap<String, String> keys;137 private Map<String, String> keys; 138 138 139 139 /** Store relation information … … 166 166 167 167 /** MultiMap of all relations */ 168 MultiMap<RelationPair, OsmPrimitive> relations;168 private MultiMap<RelationPair, OsmPrimitive> relations; 169 169 170 170 /** MultiMap of all relations, regardless of keys */ 171 MultiMap<List<RelationMember>, OsmPrimitive> relations_nokeys;171 private MultiMap<List<RelationMember>, OsmPrimitive> relations_nokeys; 172 172 173 173 /** List of keys without useful information */ 174 Collection<String> ignoreKeys = new HashSet<String>(OsmPrimitive.getUninterestingKeys());174 private Collection<String> ignoreKeys = new HashSet<String>(OsmPrimitive.getUninterestingKeys()); 175 175 176 176 /** … … 229 229 if (testError.getCode() == SAME_RELATION) return null; 230 230 Collection<? extends OsmPrimitive> sel = testError.getPrimitives(); 231 HashSet<Relation> rel _fix = new HashSet<Relation>();231 HashSet<Relation> relFix = new HashSet<Relation>(); 232 232 233 233 for (OsmPrimitive osm : sel) 234 234 if (osm instanceof Relation && !osm.isDeleted()) { 235 rel _fix.add((Relation)osm);236 } 237 238 if ( rel_fix.size() < 2)235 relFix.add((Relation)osm); 236 } 237 238 if (relFix.size() < 2) 239 239 return null; 240 240 241 241 long idToKeep = 0; 242 Relation relationToKeep = rel _fix.iterator().next();242 Relation relationToKeep = relFix.iterator().next(); 243 243 // Only one relation will be kept - the one with lowest positive ID, if such exist 244 244 // or one "at random" if no such exists. Rest of the relations will be deleted 245 for (Relation w: rel_fix) { 246 if (!w.isNew()) { 247 if (idToKeep == 0 || w.getId() < idToKeep) { 248 idToKeep = w.getId(); 249 relationToKeep = w; 250 } 245 for (Relation w: relFix) { 246 if (!w.isNew() && (idToKeep == 0 || w.getId() < idToKeep)) { 247 idToKeep = w.getId(); 248 relationToKeep = w; 251 249 } 252 250 } … … 254 252 // Find the relation that is member of one or more relations. (If any) 255 253 Relation relationWithRelations = null; 256 List<Relation> rel _ref = null;257 for (Relation w : rel _fix) {254 List<Relation> relRef = null; 255 for (Relation w : relFix) { 258 256 List<Relation> rel = OsmPrimitive.getFilteredList(w.getReferrers(), Relation.class); 259 257 if (!rel.isEmpty()) { … … 261 259 throw new AssertionError("Cannot fix duplicate relations: More than one relation is member of another relation."); 262 260 relationWithRelations = w; 263 rel _ref = rel;261 relRef = rel; 264 262 } 265 263 } … … 269 267 // Fix relations. 270 268 if (relationWithRelations != null && relationToKeep != relationWithRelations) { 271 for (Relation rel : rel _ref) {269 for (Relation rel : relRef) { 272 270 Relation newRel = new Relation(rel); 273 271 for (int i = 0; i < newRel.getMembers().size(); ++i) { … … 282 280 283 281 //Delete all relations in the list 284 rel _fix.remove(relationToKeep);285 commands.add(new DeleteCommand(rel _fix));282 relFix.remove(relationToKeep); 283 commands.add(new DeleteCommand(relFix)); 286 284 return new SequenceCommand(tr("Delete duplicate relations"), commands); 287 285 } -
trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateWay.java
r6104 r6240 32 32 * Tests if there are duplicate ways 33 33 */ 34 public class DuplicateWay extends Test 35 { 34 public class DuplicateWay extends Test { 36 35 37 36 /** … … 40 39 */ 41 40 private static class WayPair { 42 public List<LatLon> coor; 43 public Map<String, String> keys; 44 public WayPair(List<LatLon> _coor, Map<String, String> _keys) { 45 coor=_coor; 46 keys=_keys; 41 private final List<LatLon> coor; 42 private final Map<String, String> keys; 43 44 public WayPair(List<LatLon> coor, Map<String, String> keys) { 45 this.coor = coor; 46 this.keys = keys; 47 47 } 48 48 … … 66 66 */ 67 67 private static class WayPairNoTags { 68 p ublicList<LatLon> coor;69 public WayPairNoTags(List<LatLon> _coor) {70 coor=_coor;68 private final List<LatLon> coor; 69 public WayPairNoTags(List<LatLon> coor) { 70 this.coor = coor; 71 71 } 72 72 @Override … … 242 242 // or one "at random" if no such exists. Rest of the ways will be deleted 243 243 for (Way w: ways) { 244 if (!w.isNew()) { 245 if (idToKeep == 0 || w.getId() < idToKeep) { 246 idToKeep = w.getId(); 247 wayToKeep = w; 248 } 244 if (!w.isNew() && (idToKeep == 0 || w.getId() < idToKeep)) { 245 idToKeep = w.getId(); 246 wayToKeep = w; 249 247 } 250 248 } -
trunk/src/org/openstreetmap/josm/data/validation/tests/Highways.java
r5902 r6240 53 53 @Override 54 54 public void visit(Way w) { 55 if (w.isUsable()) { 56 if (w.hasKey("highway") && w.hasKey("junction") && w.get("junction").equals("roundabout")) { 57 Map<String, List<Way>> map = new HashMap<String, List<Way>>(); 58 // Count all highways (per type) connected to this roundabout 59 // As roundabouts are closed ways, take care of not processing the first/last node twice 60 for (Node n : new HashSet<Node>(w.getNodes())) { 61 for (Way h : Utils.filteredCollection(n.getReferrers(), Way.class)) { 62 if (h != w && h.hasKey("highway")) { 63 List<Way> list = map.get(h.get("highway")); 64 if (list == null) { 65 map.put(h.get("highway"), list = new ArrayList<Way>()); 66 } 67 list.add(h); 55 if (w.isUsable() && w.hasKey("highway") && w.hasKey("junction") && w.get("junction").equals("roundabout")) { 56 Map<String, List<Way>> map = new HashMap<String, List<Way>>(); 57 // Count all highways (per type) connected to this roundabout 58 // As roundabouts are closed ways, take care of not processing the first/last node twice 59 for (Node n : new HashSet<Node>(w.getNodes())) { 60 for (Way h : Utils.filteredCollection(n.getReferrers(), Way.class)) { 61 if (h != w && h.hasKey("highway")) { 62 List<Way> list = map.get(h.get("highway")); 63 if (list == null) { 64 map.put(h.get("highway"), list = new ArrayList<Way>()); 68 65 } 66 list.add(h); 69 67 } 70 68 } 71 // The roundabout should carry the highway tag of its two biggest highways 72 for (String s : CLASSIFIED_HIGHWAYS) { 73 List<Way> list = map.get(s); 74 if (list != null && list.size() >= 2) { 75 // Except when a single road is connected, but with two oneway segments 76 Boolean oneway1 = OsmUtils.getOsmBoolean(list.get(0).get("oneway")); 77 Boolean oneway2 = OsmUtils.getOsmBoolean(list.get(1).get("oneway")); 78 if (list.size() > 2 || oneway1 == null || oneway2 == null || !oneway1 || !oneway2) { 79 // Error when the highway tags do not match 80 if (!w.get("highway").equals(s)) { 81 errors.add(new TestError(this, Severity.WARNING, 82 tr("Incorrect roundabout (highway: {0} instead of {1})", w.get("highway"), s), 83 WRONG_ROUNDABOUT_HIGHWAY, w)); 84 } 85 break; 69 } 70 // The roundabout should carry the highway tag of its two biggest highways 71 for (String s : CLASSIFIED_HIGHWAYS) { 72 List<Way> list = map.get(s); 73 if (list != null && list.size() >= 2) { 74 // Except when a single road is connected, but with two oneway segments 75 Boolean oneway1 = OsmUtils.getOsmBoolean(list.get(0).get("oneway")); 76 Boolean oneway2 = OsmUtils.getOsmBoolean(list.get(1).get("oneway")); 77 if (list.size() > 2 || oneway1 == null || oneway2 == null || !oneway1 || !oneway2) { 78 // Error when the highway tags do not match 79 if (!w.get("highway").equals(s)) { 80 errors.add(new TestError(this, Severity.WARNING, 81 tr("Incorrect roundabout (highway: {0} instead of {1})", w.get("highway"), s), 82 WRONG_ROUNDABOUT_HIGHWAY, w)); 86 83 } 84 break; 87 85 } 88 86 } -
trunk/src/org/openstreetmap/josm/data/validation/tests/MultipolygonTest.java
r6239 r6240 29 29 import org.openstreetmap.josm.gui.mappaint.MapPaintStyles; 30 30 31 /** 32 * Checks if multipolygons are valid 33 * @since 3669 34 */ 31 35 public class MultipolygonTest extends Test { 32 36 … … 47 51 private final List<List<Node>> nonClosedWays = new ArrayList<List<Node>>(); 48 52 49 private final double SCALE = 1.0; // arbitrary scale - we could test every possible scale, but this should suffice 50 53 /** 54 * Constructs a new {@code MultipolygonTest}. 55 */ 51 56 public MultipolygonTest() { 52 57 super(tr("Multipolygon"), … … 55 60 56 61 @Override 57 public void initialize() throws Exception{62 public void initialize() { 58 63 styles = MapPaintStyles.getStyles(); 59 64 } -
trunk/src/org/openstreetmap/josm/data/validation/tests/NameMismatch.java
r6085 r6240 33 33 protected static final int NAME_TRANSLATION_MISSING = 1502; 34 34 35 /** 36 * Constructs a new {@code NameMismatch} test. 37 */ 35 38 public NameMismatch() { 36 39 super(tr("Missing name:* translation"), … … 59 62 for (Entry<String, String> entry : p.getKeys().entrySet()) { 60 63 if (entry.getKey().startsWith("name:")) { 61 String n ame_s= entry.getValue();62 if (n ame_s!= null) {63 names.add(n ame_s);64 String n = entry.getValue(); 65 if (n != null) { 66 names.add(n); 64 67 } 65 68 } … … 74 77 tr("A name is missing, even though name:* exists."), 75 78 NAME_MISSING, p)); 76 return;77 }79 return; 80 } 78 81 79 82 if (names.contains(name)) return; … … 82 85 Check if this is the case. */ 83 86 84 String[] split _names = name.split(" - ");85 if (split _names.length == 1) {87 String[] splitNames = name.split(" - "); 88 if (splitNames.length == 1) { 86 89 /* The name is not composed of multiple parts. Complain. */ 87 90 missingTranslation(p); … … 90 93 91 94 /* Check that each part corresponds to a translated name:*. */ 92 for (String n : split _names) {95 for (String n : splitNames) { 93 96 if (!names.contains(n)) { 94 97 missingTranslation(p); -
trunk/src/org/openstreetmap/josm/data/validation/tests/OverlappingWays.java
r5783 r6240 31 31 32 32 /** Bag of all way segments */ 33 MultiMap<Pair<Node,Node>, WaySegment> nodePairs;33 private MultiMap<Pair<Node,Node>, WaySegment> nodePairs; 34 34 35 35 protected static final int OVERLAPPING_HIGHWAY = 101; … … 56 56 @Override 57 57 public void endTest() { 58 Map<List<Way>, Set<WaySegment>> ways_seen= new HashMap<List<Way>, Set<WaySegment>>(500);58 Map<List<Way>, Set<WaySegment>> seenWays = new HashMap<List<Way>, Set<WaySegment>>(500); 59 59 60 60 for (Set<WaySegment> duplicated : nodePairs.values()) { … … 63 63 if (ways > 1) { 64 64 List<OsmPrimitive> prims = new ArrayList<OsmPrimitive>(); 65 List<Way> current _ways = new ArrayList<Way>();65 List<Way> currentWays = new ArrayList<Way>(); 66 66 Collection<WaySegment> highlight; 67 67 int highway = 0; … … 89 89 90 90 prims.add(ws.way); 91 current _ways.add(ws.way);91 currentWays.add(ws.way); 92 92 } 93 93 /* These ways not seen before … … 95 95 * highways or railways mark a separate error 96 96 */ 97 if ((highlight = ways_seen.get(current_ways)) == null) {97 if ((highlight = seenWays.get(currentWays)) == null) { 98 98 String errortype; 99 99 int type; … … 128 128 type < OVERLAPPING_HIGHWAY_AREA ? Severity.WARNING : Severity.OTHER, 129 129 errortype, type, prims, duplicated)); 130 ways_seen.put(current_ways, duplicated);130 seenWays.put(currentWays, duplicated); 131 131 } else { /* way seen, mark highlight layer only */ 132 132 for (WaySegment ws : duplicated) { -
trunk/src/org/openstreetmap/josm/data/validation/tests/PowerLines.java
r5909 r6240 39 39 public static final Collection<String> POWER_ALLOWED_TAGS = Arrays.asList("switch", "transformer", "busbar", "generator"); 40 40 41 pr otectedfinal Map<Way, String> towerPoleTagMap = new HashMap<Way, String>();41 private final Map<Way, String> towerPoleTagMap = new HashMap<Way, String>(); 42 42 43 pr otectedfinal List<PowerLineError> potentialErrors = new ArrayList<PowerLineError>();43 private final List<PowerLineError> potentialErrors = new ArrayList<PowerLineError>(); 44 44 45 pr otectedfinal List<OsmPrimitive> powerStations = new ArrayList<OsmPrimitive>();45 private final List<OsmPrimitive> powerStations = new ArrayList<OsmPrimitive>(); 46 46 47 /** 48 * Constructs a new {@code PowerLines} test. 49 */ 47 50 public PowerLines() { 48 51 super(tr("Power lines"), tr("Checks for nodes in power lines that do not have a power=tower/pole tag.")); … … 182 185 183 186 protected class PowerLineError extends TestError { 184 p ublicfinal Way line;187 private final Way line; 185 188 public PowerLineError(Node n, Way line) { 186 189 super(PowerLines.this, Severity.WARNING, -
trunk/src/org/openstreetmap/josm/data/validation/tests/RelationChecker.java
r6113 r6240 59 59 } 60 60 61 static Collection<TaggingPreset> relationpresets = new LinkedList<TaggingPreset>();61 private static Collection<TaggingPreset> relationpresets = new LinkedList<TaggingPreset>(); 62 62 63 63 /** … … 79 79 } 80 80 81 p ublicstatic class RoleInfo {82 int total = 0;83 Collection<Node> nodes = new LinkedList<Node>();84 Collection<Way> ways = new LinkedList<Way>();85 Collection<Way> closedways = new LinkedList<Way>();86 Collection<Way> openways = new LinkedList<Way>();87 Collection<Relation> relations = new LinkedList<Relation>();81 private static class RoleInfo { 82 private int total = 0; 83 private Collection<Node> nodes = new LinkedList<Node>(); 84 private Collection<Way> ways = new LinkedList<Way>(); 85 private Collection<Way> closedways = new LinkedList<Way>(); 86 private Collection<Way> openways = new LinkedList<Way>(); 87 private Collection<Relation> relations = new LinkedList<Relation>(); 88 88 } 89 89 … … 145 145 } else { 146 146 LinkedList<String> done = new LinkedList<String>(); 147 String errorMessage = tr("Role verification problem"); 147 148 for (Role r : allroles) { 148 149 done.add(r.key); … … 157 158 if (count == 0) { 158 159 String s = marktr("Role {0} missing"); 159 errors.add(new TestError(this, Severity.WARNING, tr("Role verification problem"),160 errors.add(new TestError(this, Severity.WARNING, errorMessage, 160 161 tr(s, keyname), MessageFormat.format(s, keyname), ROLE_MISSING, n)); 161 162 } 162 163 else if (vc > count) { 163 164 String s = marktr("Number of {0} roles too low ({1})"); 164 errors.add(new TestError(this, Severity.WARNING, tr("Role verification problem"),165 errors.add(new TestError(this, Severity.WARNING, errorMessage, 165 166 tr(s, keyname, count), MessageFormat.format(s, keyname, count), LOW_COUNT, n)); 166 167 } else { 167 168 String s = marktr("Number of {0} roles too high ({1})"); 168 errors.add(new TestError(this, Severity.WARNING, tr("Role verification problem"),169 errors.add(new TestError(this, Severity.WARNING, errorMessage, 169 170 tr(s, keyname, count), MessageFormat.format(s, keyname, count), HIGH_COUNT, n)); 170 171 } … … 196 197 LinkedList<OsmPrimitive> highlight = new LinkedList<OsmPrimitive>(wrongTypes); 197 198 highlight.addFirst(n); 198 errors.add(new TestError(this, Severity.WARNING, tr("Role verification problem"),199 errors.add(new TestError(this, Severity.WARNING, errorMessage, 199 200 tr(s, keyname), MessageFormat.format(s, keyname), WRONG_TYPE, 200 201 highlight, wrongTypes)); … … 206 207 if (key.length() > 0) { 207 208 String s = marktr("Role {0} unknown"); 208 errors.add(new TestError(this, Severity.WARNING, tr("Role verification problem"),209 errors.add(new TestError(this, Severity.WARNING, errorMessage, 209 210 tr(s, key), MessageFormat.format(s, key), ROLE_UNKNOWN, n)); 210 211 } else { 211 212 String s = marktr("Empty role found"); 212 errors.add(new TestError(this, Severity.WARNING, tr("Role verification problem"),213 errors.add(new TestError(this, Severity.WARNING, errorMessage, 213 214 tr(s), s, ROLE_EMPTY, n)); 214 215 } … … 219 220 } 220 221 221 /* (non-Javadoc)222 * @see org.openstreetmap.josm.data.validation.Test#fixError(org.openstreetmap.josm.data.validation.TestError)223 */224 222 @Override 225 223 public Command fixError(TestError testError) { … … 230 228 } 231 229 232 /* (non-Javadoc)233 * @see org.openstreetmap.josm.data.validation.Test#isFixable(org.openstreetmap.josm.data.validation.TestError)234 */235 230 @Override 236 231 public boolean isFixable(TestError testError) { -
trunk/src/org/openstreetmap/josm/data/validation/tests/SimilarNamedWays.java
r6106 r6240 31 31 32 32 /** All ways, grouped by cells */ 33 Map<Point2D,List<Way>> cellWays;33 private Map<Point2D,List<Way>> cellWays; 34 34 /** The already detected errors */ 35 MultiMap<Way, Way> errorWays;35 private MultiMap<Way, Way> errorWays; 36 36 37 37 /** -
trunk/src/org/openstreetmap/josm/data/validation/tests/UnclosedWays.java
r6089 r6240 15 15 import org.openstreetmap.josm.data.validation.Test; 16 16 import org.openstreetmap.josm.data.validation.TestError; 17 import org.openstreetmap.josm.gui.progress.ProgressMonitor;18 17 19 18 /** … … 29 28 public UnclosedWays() { 30 29 super(tr("Unclosed Ways"), tr("This tests if ways which should be circular are closed.")); 31 }32 33 @Override34 public void startTest(ProgressMonitor monitor) {35 super.startTest(monitor);36 }37 38 @Override39 public void endTest() {40 super.endTest();41 30 } 42 31 -
trunk/src/org/openstreetmap/josm/data/validation/tests/UnconnectedWays.java
r6162 r6240 42 42 protected static final String PREFIX = ValidatorPreference.PREFIX + "." + UnconnectedWays.class.getSimpleName(); 43 43 44 Set<MyWaySegment> ways; 45 QuadBuckets<Node> endnodes; // nodes at end of way 46 QuadBuckets<Node> endnodes_highway; // nodes at end of way 47 QuadBuckets<Node> middlenodes; // nodes in middle of way 48 Set<Node> othernodes; // nodes appearing at least twice 49 //NodeSearchCache nodecache; 50 QuadBuckets<Node> nodecache; 51 Area ds_area; 52 DataSet ds; 53 54 double mindist; 55 double minmiddledist; 44 private Set<MyWaySegment> ways; 45 private QuadBuckets<Node> endnodes; // nodes at end of way 46 private QuadBuckets<Node> endnodes_highway; // nodes at end of way 47 private QuadBuckets<Node> middlenodes; // nodes in middle of way 48 private Set<Node> othernodes; // nodes appearing at least twice 49 private Area dsArea; 50 private DataSet ds; 51 52 private double mindist; 53 private double minmiddledist; 56 54 57 55 /** … … 74 72 minmiddledist = Main.pref.getDouble(PREFIX + ".way_way_distance", 0.0); 75 73 this.ds = Main.main.getCurrentDataSet(); 76 this.ds _area = ds.getDataSourceArea();74 this.dsArea = ds.getDataSourceArea(); 77 75 } 78 76 … … 81 79 Map<Node, Way> map = new HashMap<Node, Way>(); 82 80 for (int iter = 0; iter < 1; iter++) { 83 Collection<MyWaySegment> tmp_ways = ways; 84 for (MyWaySegment s : tmp_ways) { 81 for (MyWaySegment s : ways) { 85 82 Collection<Node> nearbyNodes = s.nearbyNodes(mindist); 86 83 for (Node en : nearbyNodes) { … … 145 142 } 146 143 } 147 //System.out.println("p3 elapsed: " + (System.currentTimeMillis()-last));148 //last = System.currentTimeMillis();149 144 for (Map.Entry<Node, Way> error : map.entrySet()) { 150 145 errors.add(new TestError(this, Severity.OTHER, … … 165 160 } 166 161 } 167 //System.out.println("p4 elapsed: " + (System.currentTimeMillis()-last));168 //last = System.currentTimeMillis();169 162 for (Map.Entry<Node, Way> error : map.entrySet()) { 170 163 errors.add(new TestError(this, Severity.OTHER, … … 178 171 endnodes = null; 179 172 super.endTest(); 180 //System.out.println("p99 elapsed: " + (System.currentTimeMillis()-last));181 //last = System.currentTimeMillis();182 173 } 183 174 … … 256 247 // result is no good 257 248 if (dist > nearbyNodeCacheDist) { 258 //if (nearbyNodeCacheDist != -1)259 // System.out.println("destroyed MyWaySegment nearby node cache:" + dist + " > " + nearbyNodeCacheDist);260 249 nearbyNodeCache = null; 261 250 } … … 264 253 // one now being asked for... 265 254 if (nearbyNodeCacheDist > dist) { 266 //System.out.println("had to trim MyWaySegment nearby node cache.");267 255 // Used the cached result and trim out 268 256 // the nodes that are not in the smaller … … 293 281 294 282 for (Node n : found_nodes) { 295 if (!nearby(n, dist) || !n.getCoor().isIn(ds _area)) {283 if (!nearby(n, dist) || !n.getCoor().isIn(dsArea)) { 296 284 continue; 297 285 } -
trunk/src/org/openstreetmap/josm/data/validation/tests/UntaggedNode.java
r6010 r6240 14 14 import org.openstreetmap.josm.data.validation.Test; 15 15 import org.openstreetmap.josm.data.validation.TestError; 16 import org.openstreetmap.josm.gui.progress.ProgressMonitor;17 16 18 17 /** … … 40 39 41 40 @Override 42 public void startTest(ProgressMonitor monitor) {43 super.startTest(monitor);44 }45 46 @Override47 41 public void visit(Collection<OsmPrimitive> selection) { 48 42 for (OsmPrimitive p : selection) { … … 55 49 @Override 56 50 public void visit(Node n) { 57 if(n.isUsable() && !n.isTagged() && n.getReferrers().isEmpty()) { 51 if (n.isUsable() && !n.isTagged() && n.getReferrers().isEmpty()) { 52 String errorMessage = tr("Unconnected nodes without physical tags"); 58 53 if (!n.hasKeys()) { 59 54 String msg = marktr("No tags"); 60 errors.add(new TestError(this, Severity.WARNING, tr("Unconnected nodes without physical tags"), tr(msg), msg, UNTAGGED_NODE_BLANK, n));55 errors.add(new TestError(this, Severity.WARNING, errorMessage, tr(msg), msg, UNTAGGED_NODE_BLANK, n)); 61 56 return; 62 57 } … … 66 61 /* translation note: don't translate quoted words */ 67 62 String msg = marktr("Has tag containing ''fixme'' or ''FIXME''"); 68 errors.add(new TestError(this, Severity.WARNING, tr("Unconnected nodes without physical tags"), 69 tr(msg), msg, UNTAGGED_NODE_FIXME, n)); 63 errors.add(new TestError(this, Severity.WARNING, errorMessage, tr(msg), msg, UNTAGGED_NODE_FIXME, n)); 70 64 return; 71 65 } … … 91 85 } 92 86 if (msg != null) { 93 errors.add(new TestError(this, Severity.WARNING, tr("Unconnected nodes without physical tags"), 94 tr(msg), msg, code, n)); 87 errors.add(new TestError(this, Severity.WARNING, errorMessage, tr(msg), msg, code, n)); 95 88 return; 96 89 } 97 90 } 98 91 // Does not happen, but just to be sure. Maybe definition of uninteresting tags changes in future. 99 errors.add(new TestError(this, Severity.WARNING, tr("Unconnected nodes without physical tags"), 100 tr("Other"), "Other", UNTAGGED_NODE_OTHER, n)); 92 errors.add(new TestError(this, Severity.WARNING, errorMessage, tr("Other"), "Other", UNTAGGED_NODE_OTHER, n)); 101 93 } 102 94 } -
trunk/src/org/openstreetmap/josm/data/validation/tests/UntaggedWay.java
r6142 r6240 79 79 if (!tags.isEmpty()) { 80 80 String highway = tags.get("highway"); 81 if (highway != null && NAMED_WAYS.contains(highway)) { 82 if (!tags.containsKey("name") && !tags.containsKey("ref")) { 83 boolean isRoundabout = false; 84 boolean hasName = false; 85 for (String key : w.keySet()) { 86 hasName = key.startsWith("name:") || key.endsWith("_name") || key.endsWith("_ref"); 87 if (hasName) { 88 break; 89 } 90 if (key.equals("junction")) { 91 isRoundabout = w.get("junction").equals("roundabout"); 92 break; 93 } 81 if (highway != null && NAMED_WAYS.contains(highway) && !tags.containsKey("name") && !tags.containsKey("ref")) { 82 boolean isRoundabout = false; 83 boolean hasName = false; 84 for (String key : w.keySet()) { 85 hasName = key.startsWith("name:") || key.endsWith("_name") || key.endsWith("_ref"); 86 if (hasName) { 87 break; 94 88 } 89 if (key.equals("junction")) { 90 isRoundabout = w.get("junction").equals("roundabout"); 91 break; 92 } 93 } 95 94 96 if (!hasName && !isRoundabout) { 97 errors.add(new TestError(this, Severity.WARNING, tr("Unnamed ways"), UNNAMED_WAY, w)); 98 } else if (isRoundabout) { 99 errors.add(new TestError(this, Severity.WARNING, tr("Unnamed junction"), UNNAMED_JUNCTION, w)); 100 } 95 if (!hasName && !isRoundabout) { 96 errors.add(new TestError(this, Severity.WARNING, tr("Unnamed ways"), UNNAMED_WAY, w)); 97 } else if (isRoundabout) { 98 errors.add(new TestError(this, Severity.WARNING, tr("Unnamed junction"), UNNAMED_JUNCTION, w)); 101 99 } 102 100 } … … 127 125 if (r.isMultipolygon() || WHITELIST.contains(m.getRole())) { 128 126 OsmPrimitive member = m.getMember(); 129 if (member != null && memberinstanceof Way && member.isUsable() && !member.isTagged()) {127 if (member instanceof Way && member.isUsable() && !member.isTagged()) { 130 128 waysUsedInRelations.add((Way)member); 131 129 } -
trunk/src/org/openstreetmap/josm/data/validation/tests/WronglyOrderedWays.java
r4869 r6240 20 20 21 21 protected static final int WRONGLY_ORDERED_COAST = 1001; 22 //protected static int WRONGLY_ORDERED_WATER = 1002;23 22 protected static final int WRONGLY_ORDERED_LAND = 1003; 24 23 … … 42 41 else if ("coastline".equals(natural) && Geometry.isClockwise(w)) { 43 42 reportError(w, tr("Reversed coastline: land not on left side"), WRONGLY_ORDERED_COAST); 44 /*} else if ("water".equals(natural) && !Geometry.isClockwise(w)) {45 reportError(w, tr("Reversed water: land not on left side"), WRONGLY_ORDERED_WATER);*/46 43 } else if ("land".equals(natural) && Geometry.isClockwise(w)) { 47 44 reportError(w, tr("Reversed land: land not on left side"), WRONGLY_ORDERED_LAND);
Note:
See TracChangeset
for help on using the changeset viewer.