visit method

void visit(
  1. Geometry element
)
override

Implementation

void visit(Geometry element) {
  Envelope elementEnv = element.getEnvelopeInternal();

  // disjoint => no intersection
  if (!rectEnv.intersectsEnvelope(elementEnv)) {
    return;
  }
  // rectangle contains target env => must intersect
  if (rectEnv.containsEnvelope(elementEnv)) {
    _intersects = true;
    return;
  }
  /**
   * Since the envelopes intersect and the test element is connected, if the
   * test envelope is completely bisected by an edge of the rectangle the
   * element and the rectangle must touch (This is basically an application of
   * the Jordan Curve Theorem). The alternative situation is that the test
   * envelope is "on a corner" of the rectangle envelope, i.e. is not
   * completely bisected. In this case it is not possible to make a conclusion
   * about the presence of an intersection.
   */
  if (elementEnv.getMinX() >= rectEnv.getMinX() &&
      elementEnv.getMaxX() <= rectEnv.getMaxX()) {
    _intersects = true;
    return;
  }
  if (elementEnv.getMinY() >= rectEnv.getMinY() &&
      elementEnv.getMaxY() <= rectEnv.getMaxY()) {
    _intersects = true;
    return;
  }
}