示例#1
0
        /// <summary>
        /// Computes the set-theoretic union of two <c>Geometry</c>s, using enhanced precision.
        /// </summary>
        /// <param name="geom0">The first Geometry.</param>
        /// <param name="geom1">The second Geometry.</param>
        /// <returns>The Geometry representing the set-theoretic union of the input Geometries.</returns>
        public static IGeometry Union(IGeometry geom0, IGeometry geom1)
        {
            ApplicationException originalEx = null;

            try
            {
                IGeometry result = geom0.Union(geom1);
                return(result);
            }
            catch (ApplicationException ex)
            {
                originalEx = ex;
            }

            /*
             * If we are here, the original op encountered a precision problem
             * (or some other problem).  Retry the operation with
             * enhanced precision to see if it succeeds
             */
            try
            {
                CommonBitsOp cbo      = new CommonBitsOp(true);
                IGeometry    resultEP = cbo.Union(geom0, geom1);
                // check that result is a valid point after the reshift to orginal precision
                if (!resultEP.IsValid)
                {
                    throw originalEx;
                }
                return(resultEP);
            }
            catch (ApplicationException)
            {
                throw originalEx;
            }
        }
 /// <summary>
 /// Computes the set-theoretic union of two <c>Geometry</c>s, using enhanced precision.
 /// </summary>
 /// <param name="geom0">The first Geometry.</param>
 /// <param name="geom1">The second Geometry.</param>
 /// <returns>The Geometry representing the set-theoretic union of the input Geometries.</returns>
 public static IGeometry Union(IGeometry geom0, IGeometry geom1)
 {
     ApplicationException originalEx = null;
     try
     {
         IGeometry result = geom0.Union(geom1);
         return result;
     }
     catch (ApplicationException ex)
     {
         originalEx = ex;
     }
     /*
      * If we are here, the original op encountered a precision problem
      * (or some other problem).  Retry the operation with
      * enhanced precision to see if it succeeds
      */
     try
     {
         CommonBitsOp cbo = new CommonBitsOp(true);
         IGeometry resultEP = cbo.Union(geom0, geom1);
         // check that result is a valid point after the reshift to orginal precision
         if (!resultEP.IsValid)
             throw originalEx;
         return resultEP;
     }
     catch (ApplicationException)
     {
         throw originalEx;
     }
 }