getNode method

NodeNode getNode(
  1. Envelope searchEnv
)

Returns the subquad containing the envelope searchEnv. Creates the subquad if it does not already exist.

@return the subquad containing the search envelope

Implementation

NodeNode getNode(Envelope searchEnv) {
  int subnodeIndex = NodeBase.getSubnodeIndex(searchEnv, centrex, centrey);
  // if subquadIndex is -1 searchEnv is not contained in a subquad
  if (subnodeIndex != -1) {
    // create the quad if it does not exist
    NodeNode? node = getSubnode(subnodeIndex);
    // recursively search the found/created quad
    return node!.getNode(searchEnv);
  } else {
    return this;
  }
}