Changeset 2501 in josm for trunk/src


Ignore:
Timestamp:
2009-11-22T17:14:56+01:00 (15 years ago)
Author:
jttt
Message:

Added another tests to dataset consistency tester

File:
1 edited

Legend:

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

    r2500 r2501  
    8282    }
    8383
     84    private void checkReferredPrimitive(OsmPrimitive primitive, OsmPrimitive parent) {
     85        if (dataSet.getPrimitiveById(primitive) == null) {
     86            writer.println(String.format("%s is referenced by %s but not found in dataset", primitive, parent));
     87        }
     88        if (dataSet.getPrimitiveById(primitive) != primitive) {
     89            writer.println(String.format("%s is different instance that reffered by %s", primitive, parent));
     90        }
     91        if (primitive.isDeleted()) {
     92            writer.println(String.format("%s reffers to deleted primitive %s", parent, primitive));
     93        }
     94    }
     95
     96    private void refferedPrimitiveNotInDataset() {
     97        for (Way way:dataSet.getWays()) {
     98            for (Node node:way.getNodes()) {
     99                checkReferredPrimitive(node, way);
     100            }
     101        }
     102
     103        for (Relation relation:dataSet.getRelations()) {
     104            for (RelationMember member:relation.getMembers()) {
     105                checkReferredPrimitive(member.getMember(), relation);
     106            }
     107        }
     108    }
     109
    84110    public void runTest() {
    85         checkReferrers();
    86         checkCompleteWaysWithIncompleteNodes();
    87         checkCompleteNodesWithoutCoordinates();
    88         searchNodes();
    89         searchWays();
     111        try {
     112            checkReferrers();
     113            checkCompleteWaysWithIncompleteNodes();
     114            checkCompleteNodesWithoutCoordinates();
     115            searchNodes();
     116            searchWays();
     117            refferedPrimitiveNotInDataset();
     118        } catch (Exception e) {
     119            writer.println("Exception during dataset integrity test:");
     120            e.printStackTrace(writer);
     121        }
    90122    }
    91123
Note: See TracChangeset for help on using the changeset viewer.