Skip to content
This repository has been archived by the owner on Jan 10, 2019. It is now read-only.

Rectangle that intersects with four children doesn't mean it covers all its children #12

Open
ywh233 opened this issue Aug 20, 2015 · 0 comments

Comments

@ywh233
Copy link

ywh233 commented Aug 20, 2015

This snippet of code is problematic:

if (children.size() == 1 || children.size() == 2) {
            for (S2CellId child : children) {
                if (child.isLeaf()) {
                    cellIds.add(child);
                } else {
                    queue.add(child);
                }
            }
        } else if (children.size() == 3) {
            cellIds.addAll(children);
        } else if (children.size() == 4) {
            cellIds.add(parent);
        } else {
            assert false; // This should not happen.
        }

Image the situation that the rectangle is located near the center of the parent but isn't large enough to cover it, then it can still intersect with all its children.

The right way to do is to first check whether the rectangle contains the parent, and add all its intersected children to the queue.

Example bounds: (46.95913069858797, -123.74038696289062, 48.055558949569566, -121.27670288085938). Queries also returns points in Spokane.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant