intersection method

Envelope intersection(
  1. Envelope env
)

Computes the intersection of two {@link Envelope}s.

@param env the envelope to intersect with @return a new Envelope representing the intersection of the envelopes (this will be the null envelope if either argument is null, or they do not intersect

Implementation

Envelope intersection(Envelope env) {
  if (isNull() || env.isNull() || !intersectsEnvelope(env))
    return Envelope.empty();

  double intMinX = _minx > env._minx ? _minx : env._minx;
  double intMinY = _miny > env._miny ? _miny : env._miny;
  double intMaxX = _maxx < env._maxx ? _maxx : env._maxx;
  double intMaxY = _maxy < env._maxy ? _maxy : env._maxy;
  return Envelope(intMinX, intMaxX, intMinY, intMaxY);
}