Changeset 2925 in josm for trunk


Ignore:
Timestamp:
2010-02-02T21:13:35+01:00 (10 years ago)
Author:
jttt
Message:

Better log from DatasetConsistencyTest

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/DatasetConsistencyTest.java

    r2879 r2925  
    2424    }
    2525
     26    private void printError(String type, String message, Object... args) {
     27        writer.println("[" + type + "] " + String.format(message, args));
     28    }
     29
    2630    private void checkReferrers() {
    2731        for (Way way:dataSet.getWays()) {
     
    2933                for (Node n:way.getNodes()) {
    3034                    if (!n.getReferrers().contains(way)) {
    31                         writer.println(String.format("%s is part of %s but is not in referrers", n, way));
     35                        printError("WAY NOT IN REFERRERS", "%s is part of %s but is not in referrers", n, way);
    3236                    }
    3337                }
     
    3943                for (RelationMember m:relation.getMembers()) {
    4044                    if (!m.getMember().getReferrers().contains(relation)) {
    41                         writer.println(String.format("%s is part of %s but is not in referrers", m.getMember(), relation));
     45                        printError("RELATION NOT IN REFERRERS", "%s is part of %s but is not in referrers", m.getMember(), relation);
    4246                    }
    4347                }
     
    5155                for (Node node:way.getNodes()) {
    5256                    if (node.isIncomplete()) {
    53                         writer.println(String.format("%s is usable but contains incomplete node '%s'", way, node));
     57                        printError("USABLE HAS INCOMPLETE", "%s is usable but contains incomplete node '%s'", way, node);
    5458                    }
    5559                }
     
    6165        for (Node node:dataSet.getNodes()) {
    6266            if (!node.isIncomplete() && (node.getCoor() == null || node.getEastNorth() == null)) {
    63                 writer.println(String.format("%s is not incomplete but has null coordinates", node));
     67                printError("COMPLETE WITHOUT COORDINATES", "%s is not incomplete but has null coordinates", node);
    6468            }
    6569        }
     
    7276                BBox box = new BBox(new LatLon(c.lat() - 0.0001, c.lon() - 0.0001), new LatLon(c.lat() + 0.0001, c.lon() + 0.0001));
    7377                if (!dataSet.searchNodes(box).contains(n)) {
    74                     writer.println(String.format("%s not found using Dataset.searchNodes()", n));
     78                    printError("SEARCH NODES", "%s not found using Dataset.searchNodes()", n);
    7579                }
    7680            }
     
    8185        for (Way w:dataSet.getWays()) {
    8286            if (!w.isIncomplete() && !w.isDeleted() && !dataSet.searchWays(w.getBBox()).contains(w)) {
    83                 writer.println(String.format("%s not found using Dataset.searchWays()", w));
     87                printError("SEARCH WAYS", "%s not found using Dataset.searchWays()", w);
    8488            }
    8589        }
     
    8892    private void checkReferredPrimitive(OsmPrimitive primitive, OsmPrimitive parent) {
    8993        if (dataSet.getPrimitiveById(primitive) == null) {
    90             writer.println(String.format("%s is referenced by %s but not found in dataset", primitive, parent));
     94            printError("REFERENCED BUT NOT IN DATA", "%s is referenced by %s but not found in dataset", primitive, parent);
    9195        }
    9296        if (dataSet.getPrimitiveById(primitive) != primitive) {
    93             writer.println(String.format("%s is different instance that referred by %s", primitive, parent));
     97            printError("DIFFERENT INSTANCE", "%s is different instance that referred by %s", primitive, parent);
    9498        }
    9599        if (primitive.isDeleted()) {
    96             writer.println(String.format("%s refers to deleted primitive %s", parent, primitive));
     100            printError("DELETED REFERENCED", "%s refers to deleted primitive %s", parent, primitive);
    97101        }
    98102    }
     
    112116    }
    113117
     118
    114119    private void checkZeroNodesWays() {
    115120        for (Way way:dataSet.getWays()) {
    116121            if (way.isUsable() && way.getNodesCount() == 0) {
    117                 writer.println(String.format("Way %s has zero nodes", way));
     122                printError("WARN - ZERO NODES", "Way %s has zero nodes", way);
    118123            } else if (way.isUsable() && way.getNodesCount() == 1) {
    119                 writer.println(String.format("Way %s has only one node", way));
     124                printError("WARN - NO NODES", "Way %s has only one node", way);
    120125            }
    121126        }
Note: See TracChangeset for help on using the changeset viewer.