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


Ignore:
Timestamp:
2009-11-12T23:17:52+01:00 (15 years ago)
Author:
hansendc
Message:

This should fix #3909

We created empty branches when we attempted to split a QB node
with ways in it and none of the ways could fit into a child.
The children were allocated before we knew that we had something
to put in them, and we ended up with an empty array of children.
That triggered this check.

So, defer child array allocation until we really need it.

File:
1 edited

Legend:

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

    r2441 r2442  
    281281                        + this.bbox.width()+", "+this.bbox.height()+")");
    282282            }
    283             if (children != null) {
    284                 abort("overwrote children");
    285             }
    286             children = newChildren();
    287283            // deferring allocation of children until use
    288284            // seems a bit faster
     
    298294                    continue;
    299295                }
     296                if (children == null)
     297                    children = newChildren();
    300298                if (children[new_index] == null) {
    301299                    children[new_index] = new QBLevel(this, new_index);
     
    357355        boolean matches(T o, BBox search_bbox)
    358356        {
     357            // This can be optimized when o is a node
     358            //return search_bbox.bounds(coor));
    359359            return o.getBBox().intersects(search_bbox);
    360360        }
     
    490490                }
    491491                if (child == null) {
    492                     abort("branch node had no children");
     492                    abort("branch node ("+this+" "+next.isLeaf()+") had no children (content: "+next.content+") this: " + this);
    493493                }
    494494                next = child;
     
    568568                    debug = true;
    569569                    get_index(n, level);
    570                     abort("object " + n + " does not belong in node at level: " + level + " bbox: " + this.bbox());
     570                    get_index(n, level-1);
     571                    int nr = 0;
     572                    for (QBLevel sibling : parent.children) {
     573                        out("sibling["+ (nr++) +"]: " + sibling.bbox() + " this: " + (this==sibling));
     574                    }
     575                    abort("\nobject " + n + " does not belong in node at level: " + level + " bbox: " + this.bbox());
    571576                }
    572577            }
Note: See TracChangeset for help on using the changeset viewer.