Changeset 23917 in osm


Ignore:
Timestamp:
2010-10-30T16:45:34+02:00 (14 years ago)
Author:
nakor
Message:

Added more types and precision option for duplicated nodes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/DuplicateNode.java

    r22445 r23917  
    4545    private class NodeHash implements Hash<Object, Object> {
    4646
     47        double precision = Main.pref.getDouble("validator.duplicatenodes.precision", 0.);
     48
     49        private LatLon RoundCoord(Node o) {
     50            return new LatLon(
     51                    Math.round(o.getCoor().lat() / precision) * precision,
     52                    Math.round(o.getCoor().lon() / precision) * precision
     53            );
     54        }
     55
    4756        @SuppressWarnings("unchecked")
    4857        private LatLon getLatLon(Object o) {
    4958            if (o instanceof Node) {
    50                 return ((Node) o).getCoor().getRoundedToOsmPrecision();
     59                if (precision==0) {
     60                    return ((Node) o).getCoor().getRoundedToOsmPrecision();
     61                } else {
     62                    return RoundCoord((Node) o);
     63                }
    5164            } else if (o instanceof List<?>) {
    52                 return ((List<Node>) o).get(0).getCoor().getRoundedToOsmPrecision();
     65                if (precision==0) {
     66                    return ((List<Node>) o).get(0).getCoor().getRoundedToOsmPrecision();
     67                } else {
     68                    return RoundCoord(((List<Node>) o).get(0));
     69                }
    5370            } else {
    5471                throw new AssertionError();
     
    6885    protected static int DUPLICATE_NODE = 1;
    6986    protected static int DUPLICATE_NODE_MIXED = 2;
    70     protected static int DUPLICATE_NODE_HIGHWAY = 3;
    71     protected static int DUPLICATE_NODE_RAILWAY = 3;
    72     protected static int DUPLICATE_NODE_WATERWAY = 4;
    73     protected static int DUPLICATE_NODE_BOUNDARY = 5;
    74     protected static int DUPLICATE_NODE_POWER = 6;
     87    protected static int DUPLICATE_NODE_OTHER = 3;
     88    protected static int DUPLICATE_NODE_BUILDING = 10;
     89    protected static int DUPLICATE_NODE_BOUNDARY = 11;
     90    protected static int DUPLICATE_NODE_HIGHWAY = 12;
     91    protected static int DUPLICATE_NODE_LANDUSE = 13;
     92    protected static int DUPLICATE_NODE_NATURAL = 14;
     93    protected static int DUPLICATE_NODE_POWER = 15;
     94    protected static int DUPLICATE_NODE_RAILWAY = 16;
     95    protected static int DUPLICATE_NODE_WATERWAY = 17;
    7596
    7697    /** The map of potential duplicates.
     
    126147
    127148        Map<String,Boolean> typeMap=new HashMap<String,Boolean>();
    128         String[] types = {"none", "highway", "railway", "waterway", "boundary", "power"};
     149        String[] types = {"none", "highway", "railway", "waterway", "boundary", "power", "natural", "landuse", "building"};
    129150
    130151
     
    171192                    errors.add(new TestError(
    172193                            parentTest,
    173                             Severity.ERROR,
     194                            Severity.WARNING,
    174195                            tr("Duplicated nodes"),
    175196                            tr(msg),
     
    233254                            bag.get(tagSet)
    234255                    ));
     256                } else if (typeMap.get("natural")) {
     257                    String msg = marktr("Natural duplicated nodes");
     258                    errors.add(new TestError(
     259                            parentTest,
     260                            Severity.ERROR,
     261                            tr("Duplicated nodes"),
     262                            tr(msg),
     263                            msg,
     264                            DUPLICATE_NODE_NATURAL,
     265                            bag.get(tagSet)
     266                    ));
     267                } else if (typeMap.get("building")) {
     268                    String msg = marktr("Building duplicated nodes");
     269                    errors.add(new TestError(
     270                            parentTest,
     271                            Severity.ERROR,
     272                            tr("Duplicated nodes"),
     273                            tr(msg),
     274                            msg,
     275                            DUPLICATE_NODE_BUILDING,
     276                            bag.get(tagSet)
     277                    ));
     278                } else if (typeMap.get("landuse")) {
     279                    String msg = marktr("Landuse duplicated nodes");
     280                    errors.add(new TestError(
     281                            parentTest,
     282                            Severity.ERROR,
     283                            tr("Duplicated nodes"),
     284                            tr(msg),
     285                            msg,
     286                            DUPLICATE_NODE_LANDUSE,
     287                            bag.get(tagSet)
     288                    ));
    235289                } else {
    236                     errors.add(new TestError(
    237                             parentTest,
    238                             Severity.ERROR,
    239                             tr("Duplicated nodes"),
    240                             DUPLICATE_NODE,
     290                    String msg = marktr("Other duplicated nodes");
     291                    errors.add(new TestError(
     292                            parentTest,
     293                            Severity.WARNING,
     294                            tr("Duplicated nodes"),
     295                            tr(msg),
     296                            msg,
     297                            DUPLICATE_NODE_OTHER,
    241298                            bag.get(tagSet)
    242299                    ));
Note: See TracChangeset for help on using the changeset viewer.