public static Envelope GetEnvelope(Geometry a, Geometry b, Envelope targetEnv) { var cec = new RobustClipEnvelopeComputer(targetEnv); cec.Add(a); cec.Add(b); return(cec.Envelope); }
/// <summary> /// Computes a clipping envelope for overlay input geometries. /// The clipping envelope encloses all geometry line segments which /// might participate in the overlay, with a buffer to /// account for numerical precision /// (in particular, rounding due to a precision model. /// The clipping envelope is used in both the <see cref="RingClipper"/> /// and in the <see cref="LineLimiter"/>. /// <para/> /// Some overlay operations (i.e. <see cref="SpatialFunction.Union"/> and <see cref="SpatialFunction.SymDifference"/>) /// cannot use clipping as an optimization, /// since the result envelope is the full extent of the two input geometries. /// In this case the returned /// envelope is <c>null</c> to indicate this. /// </summary> /// <param name="opCode">The overlay op code</param> /// <param name="inputGeom">The input geometries</param> /// <param name="pm">The precision model being used</param> /// <returns>An envelope for clipping and line limiting, or null if no clipping is performed</returns> internal static Envelope ClippingEnvelope(SpatialFunction opCode, InputGeometry inputGeom, PrecisionModel pm) { var resultEnv = ResultEnvelope(opCode, inputGeom, pm); if (resultEnv == null) { return(null); } var clipEnv = RobustClipEnvelopeComputer.GetEnvelope( inputGeom.GetGeometry(0), inputGeom.GetGeometry(1), resultEnv); var safeEnv = SafeEnv(clipEnv, pm); return(safeEnv); }