Changeset 2958 in josm


Ignore:
Timestamp:
2010-02-09T21:31:20+01:00 (10 years ago)
Author:
jttt
Message:

Fix #4468 Status -> OutOfMemory after copying layer

File:
1 edited

Legend:

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

    r2925 r2958  
    1616public class DatasetConsistencyTest {
    1717
     18    private static final int MAX_ERRORS = 100;
    1819    private final DataSet dataSet;
    1920    private final PrintWriter writer;
     21    private int errorCount;
    2022
    2123    public DatasetConsistencyTest(DataSet dataSet, Writer writer) {
     
    2527
    2628    private void printError(String type, String message, Object... args) {
    27         writer.println("[" + type + "] " + String.format(message, args));
     29        errorCount++;
     30        if (errorCount <= MAX_ERRORS) {
     31            writer.println("[" + type + "] " + String.format(message, args));
     32        }
    2833    }
    2934
    30     private void checkReferrers() {
     35    public void checkReferrers() {
    3136        for (Way way:dataSet.getWays()) {
    3237            if (!way.isDeleted()) {
     
    5055    }
    5156
    52     private void checkCompleteWaysWithIncompleteNodes() {
     57    public void checkCompleteWaysWithIncompleteNodes() {
    5358        for (Way way:dataSet.getWays()) {
    5459            if (way.isUsable()) {
     
    6267    }
    6368
    64     private void checkCompleteNodesWithoutCoordinates() {
     69    public void checkCompleteNodesWithoutCoordinates() {
    6570        for (Node node:dataSet.getNodes()) {
    6671            if (!node.isIncomplete() && (node.getCoor() == null || node.getEastNorth() == null)) {
     
    7075    }
    7176
    72     private void searchNodes() {
     77    public void searchNodes() {
    7378        for (Node n:dataSet.getNodes()) {
    7479            if (!n.isIncomplete() && !n.isDeleted()) {
     
    8287    }
    8388
    84     private void searchWays() {
     89    public void searchWays() {
    8590        for (Way w:dataSet.getWays()) {
    86             if (!w.isIncomplete() && !w.isDeleted() && !dataSet.searchWays(w.getBBox()).contains(w)) {
     91            if (!w.isIncomplete() && !w.isDeleted() && w.getNodesCount() >= 2 && !dataSet.searchWays(w.getBBox()).contains(w)) {
    8792                printError("SEARCH WAYS", "%s not found using Dataset.searchWays()", w);
    8893            }
     
    102107    }
    103108
    104     private void referredPrimitiveNotInDataset() {
     109    public void referredPrimitiveNotInDataset() {
    105110        for (Way way:dataSet.getWays()) {
    106111            for (Node node:way.getNodes()) {
     
    117122
    118123
    119     private void checkZeroNodesWays() {
     124    public void checkZeroNodesWays() {
    120125        for (Way way:dataSet.getWays()) {
    121126            if (way.isUsable() && way.getNodesCount() == 0) {
     
    136141            referredPrimitiveNotInDataset();
    137142            checkZeroNodesWays();
     143            if (errorCount > MAX_ERRORS) {
     144                writer.println((errorCount - MAX_ERRORS) + " more...");
     145            }
    138146        } catch (Exception e) {
    139147            writer.println("Exception during dataset integrity test:");
Note: See TracChangeset for help on using the changeset viewer.