Changeset 6240 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2013-09-20T22:44:07+02:00 (11 years ago)
Author:
Don-vip
Message:

Sonar - fix some issues in data.validation.tests

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  
    5454            this(code, collection, message, null, null);
    5555        }
    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);
    5858        }
    5959    }
     
    146146            }
    147147            // Report duplicate house numbers
    148             String description_en = marktr("House number ''{0}'' duplicated");
     148            String englishDescription = marktr("House number ''{0}'' duplicated");
    149149            for (String key : map.keySet()) {
    150150                List<OsmPrimitive> list = map.get(key);
    151151                if (list.size() > 1) {
    152152                    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));
    154154                }
    155155            }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/BuildingInBuilding.java

    r6069 r6240  
    2525import org.openstreetmap.josm.tools.Predicate;
    2626
     27/**
     28 * Checks for building areas inside of buildings
     29 * @since 4409
     30 */
    2731public class BuildingInBuilding extends Test {
    2832
    2933    protected static final int BUILDING_INSIDE_BUILDING = 2001;
    30     protected List<OsmPrimitive> primitivesToCheck = new LinkedList<OsmPrimitive>();
    31     protected QuadBuckets<Way> index = new QuadBuckets<Way>();
     34    private final List<OsmPrimitive> primitivesToCheck = new LinkedList<OsmPrimitive>();
     35    private final QuadBuckets<Way> index = new QuadBuckets<Way>();
    3236
     37    /**
     38     * Constructs a new {@code BuildingInBuilding} test.
     39     */
    3340    public BuildingInBuilding() {
    3441        super(tr("Building inside building"), tr("Checks for building areas inside of buildings."));
     
    6774
    6875    protected class MultiPolygonMembers {
    69         public final Set<Way> outers = new HashSet<Way>();
    70         public final Set<Way> inners = new HashSet<Way>();
     76        private final Set<Way> outers = new HashSet<Way>();
     77        private final Set<Way> inners = new HashSet<Way>();
    7178        public MultiPolygonMembers(Relation multiPolygon) {
    7279            for (RelationMember m : multiPolygon.getMembers()) {
     
    144151                        // Else, test if w is inside one of the multipolygons
    145152                        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;
    150155                            }
    151156                        }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/CrossingWays.java

    r6089 r6240  
    1212import java.util.List;
    1313import java.util.Map;
     14import java.util.Set;
    1415
    1516import org.openstreetmap.josm.data.osm.Node;
     
    3233
    3334    /** All way segments, grouped by cells */
    34     Map<Point2D,List<ExtendedSegment>> cellSegments;
     35    private Map<Point2D,List<ExtendedSegment>> cellSegments;
    3536    /** The already detected errors */
    36     HashSet<WaySegment> errorSegments;
     37    private Set<WaySegment> errorSegments;
    3738    /** The already detected ways in error */
    38     Map<List<Way>, List<WaySegment>> ways_seen;
     39    private Map<List<Way>, List<WaySegment>> seenWays;
    3940
    4041    /**
     
    5152        cellSegments = new HashMap<Point2D,List<ExtendedSegment>>(1000);
    5253        errorSegments = new HashSet<WaySegment>();
    53         ways_seen = new HashMap<List<Way>, List<WaySegment>>(50);
     54        seenWays = new HashMap<List<Way>, List<WaySegment>>(50);
    5455    }
    5556
     
    5960        cellSegments = null;
    6061        errorSegments = null;
    61         ways_seen = null;
     62        seenWays = null;
    6263    }
    6364
     
    9091            WaySegment ws = new WaySegment(w, i);
    9192            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)) {
    9494                for (ExtendedSegment es2 : segments) {
    9595                    List<Way> prims;
     
    130130
    131131                    prims = Arrays.asList(es1.ws.way, es2.ws.way);
    132                     if ((highlight = ways_seen.get(prims)) == null) {
     132                    if ((highlight = seenWays.get(prims)) == null) {
    133133                        highlight = new ArrayList<WaySegment>();
    134134                        highlight.add(es1.ws);
     
    152152                                prims,
    153153                                highlight));
    154                         ways_seen.put(prims, highlight);
     154                        seenWays.put(prims, highlight);
    155155                    } else {
    156156                        highlight.add(es1.ws);
     
    187187    /**
    188188     * A way segment with some additional information
    189      * @author frsantos
    190189     */
    191190    public static class ExtendedSegment {
    192         public Node n1, n2;
    193 
    194         public WaySegment ws;
     191        private Node n1, n2;
     192
     193        private WaySegment ws;
    195194
    196195        /** The layer */
    197         public String layer;
     196        private String layer;
    198197
    199198        /** The railway type */
    200         public String railway;
     199        private String railway;
    201200
    202201        /** The waterway type */
    203         public String waterway;
     202        private String waterway;
    204203
    205204        /** The coastline type */
    206         public boolean coastline;
     205        private boolean coastline;
    207206
    208207        /**
  • trunk/src/org/openstreetmap/josm/data/validation/tests/DeprecatedTags.java

    r6238 r6240  
    155155    private static class DeprecationCheck {
    156156
    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>();
    161161
    162162        public DeprecationCheck(int code) {
     
    230230    private class DeprecationError extends TestError {
    231231
    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) {
    236236            super(DeprecatedTags.this, Severity.WARNING, check.getDescription(), check.code, p);
    237237            this.p = p;
  • trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateNode.java

    r6069 r6240  
    4343    private static class NodeHash implements Hash<Object, Object> {
    4444
    45         double precision = Main.pref.getDouble("validator.duplicatenodes.precision", 0.);
     45        private double precision = Main.pref.getDouble("validator.duplicatenodes.precision", 0.);
    4646
    4747        private LatLon roundCoord(LatLon coor) {
     
    104104     * <pos, NodesByEqualTagsMap>
    105105     */
    106     Storage<Object> potentialDuplicates;
     106    private Storage<Object> potentialDuplicates;
    107107
    108108    /**
  • trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateRelation.java

    r6104 r6240  
    5151
    5252        /** ID of the relation member in case it is a {@link Relation} */
    53         private long rel_id;
     53        private long relId;
    5454
    5555        @Override
    5656        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();
    5858        }
    5959
     
    6262            if (!(obj instanceof RelMember)) return false;
    6363            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);
    6565        }
    6666
     
    7171            role = src.getRole();
    7272            type = src.getType();
    73             rel_id = 0;
     73            relId = 0;
    7474            coor = new ArrayList<LatLon>();
    7575
     
    9292                Relation r = src.getRelation();
    9393                tags = r.getKeys();
    94                 rel_id = r.getId();
     94                relId = r.getId();
    9595                coor = new ArrayList<LatLon>();
    9696            }
     
    103103    private class RelationMembers {
    104104        /** List of member objects of the relation */
    105         public List<RelMember> members;
     105        private List<RelMember> members;
    106106
    107107        /** Store relation information
     
    133133    private class RelationPair {
    134134        /** Member objects of the relation */
    135         public RelationMembers members;
     135        private RelationMembers members;
    136136        /** Tags of the relation */
    137         public Map<String, String> keys;
     137        private Map<String, String> keys;
    138138
    139139        /** Store relation information
     
    166166
    167167    /** MultiMap of all relations */
    168     MultiMap<RelationPair, OsmPrimitive> relations;
     168    private MultiMap<RelationPair, OsmPrimitive> relations;
    169169
    170170    /** MultiMap of all relations, regardless of keys */
    171     MultiMap<List<RelationMember>, OsmPrimitive> relations_nokeys;
     171    private MultiMap<List<RelationMember>, OsmPrimitive> relations_nokeys;
    172172
    173173    /** 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());
    175175
    176176    /**
     
    229229        if (testError.getCode() == SAME_RELATION) return null;
    230230        Collection<? extends OsmPrimitive> sel = testError.getPrimitives();
    231         HashSet<Relation> rel_fix = new HashSet<Relation>();
     231        HashSet<Relation> relFix = new HashSet<Relation>();
    232232
    233233        for (OsmPrimitive osm : sel)
    234234            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)
    239239            return null;
    240240
    241241        long idToKeep = 0;
    242         Relation relationToKeep = rel_fix.iterator().next();
     242        Relation relationToKeep = relFix.iterator().next();
    243243        // Only one relation will be kept - the one with lowest positive ID, if such exist
    244244        // 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;
    251249            }
    252250        }
     
    254252        // Find the relation that is member of one or more relations. (If any)
    255253        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) {
    258256            List<Relation> rel = OsmPrimitive.getFilteredList(w.getReferrers(), Relation.class);
    259257            if (!rel.isEmpty()) {
     
    261259                    throw new AssertionError("Cannot fix duplicate relations: More than one relation is member of another relation.");
    262260                relationWithRelations = w;
    263                 rel_ref = rel;
     261                relRef = rel;
    264262            }
    265263        }
     
    269267        // Fix relations.
    270268        if (relationWithRelations != null && relationToKeep != relationWithRelations) {
    271             for (Relation rel : rel_ref) {
     269            for (Relation rel : relRef) {
    272270                Relation newRel = new Relation(rel);
    273271                for (int i = 0; i < newRel.getMembers().size(); ++i) {
     
    282280
    283281        //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));
    286284        return new SequenceCommand(tr("Delete duplicate relations"), commands);
    287285    }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateWay.java

    r6104 r6240  
    3232 * Tests if there are duplicate ways
    3333 */
    34 public class DuplicateWay extends Test
    35 {
     34public class DuplicateWay extends Test {
    3635
    3736    /**
     
    4039      */
    4140    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;
    4747        }
    4848
     
    6666      */
    6767    private static class WayPairNoTags {
    68         public List<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;
    7171        }
    7272        @Override
     
    242242        // or one "at random" if no such exists. Rest of the ways will be deleted
    243243        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;
    249247            }
    250248        }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/Highways.java

    r5902 r6240  
    5353    @Override
    5454    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>());
    6865                        }
     66                        list.add(h);
    6967                    }
    7068                }
    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));
    8683                        }
     84                        break;
    8785                    }
    8886                }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/MultipolygonTest.java

    r6239 r6240  
    2929import org.openstreetmap.josm.gui.mappaint.MapPaintStyles;
    3030
     31/**
     32 * Checks if multipolygons are valid
     33 * @since 3669
     34 */
    3135public class MultipolygonTest extends Test {
    3236
     
    4751    private final List<List<Node>> nonClosedWays = new ArrayList<List<Node>>();
    4852
    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     */
    5156    public MultipolygonTest() {
    5257        super(tr("Multipolygon"),
     
    5560
    5661    @Override
    57     public void initialize() throws Exception {
     62    public void initialize() {
    5863        styles = MapPaintStyles.getStyles();
    5964    }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/NameMismatch.java

    r6085 r6240  
    3333    protected static final int NAME_TRANSLATION_MISSING = 1502;
    3434
     35    /**
     36     * Constructs a new {@code NameMismatch} test.
     37     */
    3538    public NameMismatch() {
    3639        super(tr("Missing name:* translation"),
     
    5962        for (Entry<String, String> entry : p.getKeys().entrySet()) {
    6063            if (entry.getKey().startsWith("name:")) {
    61                 String name_s = entry.getValue();
    62                 if (name_s != null) {
    63                     names.add(name_s);
     64                String n = entry.getValue();
     65                if (n != null) {
     66                    names.add(n);
    6467                }
    6568            }
     
    7477                    tr("A name is missing, even though name:* exists."),
    7578                    NAME_MISSING, p));
    76         return;
    77     }
     79            return;
     80        }
    7881
    7982        if (names.contains(name)) return;
     
    8285        Check if this is the case. */
    8386
    84         String[] split_names = name.split(" - ");
    85         if (split_names.length == 1) {
     87        String[] splitNames = name.split(" - ");
     88        if (splitNames.length == 1) {
    8689            /* The name is not composed of multiple parts. Complain. */
    8790            missingTranslation(p);
     
    9093
    9194        /* Check that each part corresponds to a translated name:*. */
    92         for (String n : split_names) {
     95        for (String n : splitNames) {
    9396            if (!names.contains(n)) {
    9497                missingTranslation(p);
  • trunk/src/org/openstreetmap/josm/data/validation/tests/OverlappingWays.java

    r5783 r6240  
    3131
    3232    /** Bag of all way segments */
    33     MultiMap<Pair<Node,Node>, WaySegment> nodePairs;
     33    private MultiMap<Pair<Node,Node>, WaySegment> nodePairs;
    3434
    3535    protected static final int OVERLAPPING_HIGHWAY = 101;
     
    5656    @Override
    5757    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);
    5959
    6060        for (Set<WaySegment> duplicated : nodePairs.values()) {
     
    6363            if (ways > 1) {
    6464                List<OsmPrimitive> prims = new ArrayList<OsmPrimitive>();
    65                 List<Way> current_ways = new ArrayList<Way>();
     65                List<Way> currentWays = new ArrayList<Way>();
    6666                Collection<WaySegment> highlight;
    6767                int highway = 0;
     
    8989
    9090                    prims.add(ws.way);
    91                     current_ways.add(ws.way);
     91                    currentWays.add(ws.way);
    9292                }
    9393                /* These ways not seen before
     
    9595                 * highways or railways mark a separate error
    9696                 */
    97                 if ((highlight = ways_seen.get(current_ways)) == null) {
     97                if ((highlight = seenWays.get(currentWays)) == null) {
    9898                    String errortype;
    9999                    int type;
     
    128128                            type < OVERLAPPING_HIGHWAY_AREA ? Severity.WARNING : Severity.OTHER,
    129129                                    errortype, type, prims, duplicated));
    130                     ways_seen.put(current_ways, duplicated);
     130                    seenWays.put(currentWays, duplicated);
    131131                } else { /* way seen, mark highlight layer only */
    132132                    for (WaySegment ws : duplicated) {
  • trunk/src/org/openstreetmap/josm/data/validation/tests/PowerLines.java

    r5909 r6240  
    3939    public static final Collection<String> POWER_ALLOWED_TAGS = Arrays.asList("switch", "transformer", "busbar", "generator");
    4040   
    41     protected final Map<Way, String> towerPoleTagMap = new HashMap<Way, String>();
     41    private final Map<Way, String> towerPoleTagMap = new HashMap<Way, String>();
    4242   
    43     protected final List<PowerLineError> potentialErrors = new ArrayList<PowerLineError>();
     43    private final List<PowerLineError> potentialErrors = new ArrayList<PowerLineError>();
    4444
    45     protected final List<OsmPrimitive> powerStations = new ArrayList<OsmPrimitive>();
     45    private final List<OsmPrimitive> powerStations = new ArrayList<OsmPrimitive>();
    4646
     47    /**
     48     * Constructs a new {@code PowerLines} test.
     49     */
    4750    public PowerLines() {
    4851        super(tr("Power lines"), tr("Checks for nodes in power lines that do not have a power=tower/pole tag."));
     
    182185   
    183186    protected class PowerLineError extends TestError {
    184         public final Way line;
     187        private final Way line;
    185188        public PowerLineError(Node n, Way line) {
    186189            super(PowerLines.this, Severity.WARNING,
  • trunk/src/org/openstreetmap/josm/data/validation/tests/RelationChecker.java

    r6113 r6240  
    5959    }
    6060
    61     static Collection<TaggingPreset> relationpresets = new LinkedList<TaggingPreset>();
     61    private static Collection<TaggingPreset> relationpresets = new LinkedList<TaggingPreset>();
    6262
    6363    /**
     
    7979    }
    8080
    81     public static 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>();
    8888    }
    8989
     
    145145            } else {
    146146                LinkedList<String> done = new LinkedList<String>();
     147                String errorMessage = tr("Role verification problem");
    147148                for (Role r : allroles) {
    148149                    done.add(r.key);
     
    157158                        if (count == 0) {
    158159                            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,
    160161                                    tr(s, keyname), MessageFormat.format(s, keyname), ROLE_MISSING, n));
    161162                        }
    162163                        else if (vc > count) {
    163164                            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,
    165166                                    tr(s, keyname, count), MessageFormat.format(s, keyname, count), LOW_COUNT, n));
    166167                        } else {
    167168                            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,
    169170                                    tr(s, keyname, count), MessageFormat.format(s, keyname, count), HIGH_COUNT, n));
    170171                        }
     
    196197                            LinkedList<OsmPrimitive> highlight = new LinkedList<OsmPrimitive>(wrongTypes);
    197198                            highlight.addFirst(n);
    198                             errors.add(new TestError(this, Severity.WARNING, tr("Role verification problem"),
     199                            errors.add(new TestError(this, Severity.WARNING, errorMessage,
    199200                                    tr(s, keyname), MessageFormat.format(s, keyname), WRONG_TYPE,
    200201                                    highlight, wrongTypes));
     
    206207                        if (key.length() > 0) {
    207208                            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,
    209210                                    tr(s, key), MessageFormat.format(s, key), ROLE_UNKNOWN, n));
    210211                        } else {
    211212                            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,
    213214                                    tr(s), s, ROLE_EMPTY, n));
    214215                        }
     
    219220    }
    220221
    221     /* (non-Javadoc)
    222      * @see org.openstreetmap.josm.data.validation.Test#fixError(org.openstreetmap.josm.data.validation.TestError)
    223      */
    224222    @Override
    225223    public Command fixError(TestError testError) {
     
    230228    }
    231229
    232     /* (non-Javadoc)
    233      * @see org.openstreetmap.josm.data.validation.Test#isFixable(org.openstreetmap.josm.data.validation.TestError)
    234      */
    235230    @Override
    236231    public boolean isFixable(TestError testError) {
  • trunk/src/org/openstreetmap/josm/data/validation/tests/SimilarNamedWays.java

    r6106 r6240  
    3131
    3232    /** All ways, grouped by cells */
    33     Map<Point2D,List<Way>> cellWays;
     33    private Map<Point2D,List<Way>> cellWays;
    3434    /** The already detected errors */
    35     MultiMap<Way, Way> errorWays;
     35    private MultiMap<Way, Way> errorWays;
    3636
    3737    /**
  • trunk/src/org/openstreetmap/josm/data/validation/tests/UnclosedWays.java

    r6089 r6240  
    1515import org.openstreetmap.josm.data.validation.Test;
    1616import org.openstreetmap.josm.data.validation.TestError;
    17 import org.openstreetmap.josm.gui.progress.ProgressMonitor;
    1817
    1918/**
     
    2928    public UnclosedWays() {
    3029        super(tr("Unclosed Ways"), tr("This tests if ways which should be circular are closed."));
    31     }
    32 
    33     @Override
    34     public void startTest(ProgressMonitor monitor) {
    35         super.startTest(monitor);
    36     }
    37 
    38     @Override
    39     public void endTest() {
    40         super.endTest();
    4130    }
    4231
  • trunk/src/org/openstreetmap/josm/data/validation/tests/UnconnectedWays.java

    r6162 r6240  
    4242    protected static final String PREFIX = ValidatorPreference.PREFIX + "." + UnconnectedWays.class.getSimpleName();
    4343
    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;
    5654
    5755    /**
     
    7472        minmiddledist = Main.pref.getDouble(PREFIX + ".way_way_distance", 0.0);
    7573        this.ds = Main.main.getCurrentDataSet();
    76         this.ds_area = ds.getDataSourceArea();
     74        this.dsArea = ds.getDataSourceArea();
    7775    }
    7876
     
    8179        Map<Node, Way> map = new HashMap<Node, Way>();
    8280        for (int iter = 0; iter < 1; iter++) {
    83             Collection<MyWaySegment> tmp_ways = ways;
    84             for (MyWaySegment s : tmp_ways) {
     81            for (MyWaySegment s : ways) {
    8582                Collection<Node> nearbyNodes = s.nearbyNodes(mindist);
    8683                for (Node en : nearbyNodes) {
     
    145142                }
    146143            }
    147             //System.out.println("p3 elapsed: " + (System.currentTimeMillis()-last));
    148             //last = System.currentTimeMillis();
    149144            for (Map.Entry<Node, Way> error : map.entrySet()) {
    150145                errors.add(new TestError(this, Severity.OTHER,
     
    165160                }
    166161            }
    167             //System.out.println("p4 elapsed: " + (System.currentTimeMillis()-last));
    168             //last = System.currentTimeMillis();
    169162            for (Map.Entry<Node, Way> error : map.entrySet()) {
    170163                errors.add(new TestError(this, Severity.OTHER,
     
    178171        endnodes = null;
    179172        super.endTest();
    180         //System.out.println("p99 elapsed: " + (System.currentTimeMillis()-last));
    181         //last = System.currentTimeMillis();
    182173    }
    183174
     
    256247            // result is no good
    257248            if (dist > nearbyNodeCacheDist) {
    258                 //if (nearbyNodeCacheDist != -1)
    259                 //    System.out.println("destroyed MyWaySegment nearby node cache:" + dist + " > " +  nearbyNodeCacheDist);
    260249                nearbyNodeCache = null;
    261250            }
     
    264253                // one now being asked for...
    265254                if (nearbyNodeCacheDist > dist) {
    266                     //System.out.println("had to trim MyWaySegment nearby node cache.");
    267255                    // Used the cached result and trim out
    268256                    // the nodes that are not in the smaller
     
    293281
    294282            for (Node n : found_nodes) {
    295                 if (!nearby(n, dist) || !n.getCoor().isIn(ds_area)) {
     283                if (!nearby(n, dist) || !n.getCoor().isIn(dsArea)) {
    296284                    continue;
    297285                }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/UntaggedNode.java

    r6010 r6240  
    1414import org.openstreetmap.josm.data.validation.Test;
    1515import org.openstreetmap.josm.data.validation.TestError;
    16 import org.openstreetmap.josm.gui.progress.ProgressMonitor;
    1716
    1817/**
     
    4039
    4140    @Override
    42     public void startTest(ProgressMonitor monitor) {
    43         super.startTest(monitor);
    44     }
    45 
    46     @Override
    4741    public void visit(Collection<OsmPrimitive> selection) {
    4842        for (OsmPrimitive p : selection) {
     
    5549    @Override
    5650    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");
    5853            if (!n.hasKeys()) {
    5954                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));
    6156                return;
    6257            }
     
    6661                    /* translation note: don't translate quoted words */
    6762                    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));
    7064                    return;
    7165                }
     
    9185                }
    9286                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));
    9588                    return;
    9689                }
    9790            }
    9891            // 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));
    10193        }
    10294    }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/UntaggedWay.java

    r6142 r6240  
    7979        if (!tags.isEmpty()) {
    8080            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;
    9488                    }
     89                    if (key.equals("junction")) {
     90                        isRoundabout = w.get("junction").equals("roundabout");
     91                        break;
     92                    }
     93                }
    9594
    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));
    10199                }
    102100            }
     
    127125                    if (r.isMultipolygon() || WHITELIST.contains(m.getRole())) {
    128126                        OsmPrimitive member = m.getMember();
    129                         if (member != null && member instanceof Way && member.isUsable() && !member.isTagged()) {
     127                        if (member instanceof Way && member.isUsable() && !member.isTagged()) {
    130128                            waysUsedInRelations.add((Way)member);
    131129                        }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/WronglyOrderedWays.java

    r4869 r6240  
    2020
    2121    protected static final int WRONGLY_ORDERED_COAST = 1001;
    22     //protected static int WRONGLY_ORDERED_WATER = 1002;
    2322    protected static final int WRONGLY_ORDERED_LAND  = 1003;
    2423
     
    4241        else if ("coastline".equals(natural) && Geometry.isClockwise(w)) {
    4342            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);*/
    4643        } else if ("land".equals(natural) && Geometry.isClockwise(w)) {
    4744            reportError(w, tr("Reversed land: land not on left side"), WRONGLY_ORDERED_LAND);
Note: See TracChangeset for help on using the changeset viewer.