public IGeometry GetResultGeometry(SpatialFunction opCode)
        {
            IGeometry result         = null;
            var       isSuccess      = false;
            Exception savedException = null;

            try
            {
                // try basic operation with input geometries
                result = OverlayOp.Overlay(_geom[0], _geom[1], opCode);
                var isValid = true;
                // not needed if noding validation is used
                //      boolean isValid = OverlayResultValidator.isValid(geom[0], geom[1], OverlayOp.INTERSECTION, result);
                // if (isValid)
                isSuccess = true;
            }
            catch (Exception ex)
            {
                savedException = ex;
                //// Ignore this exception, since the operation will be rerun
                //Debug.WriteLine(ex);
                //Console.WriteLine(ex.Message));
                //Console.WriteLine("Geom 0: " + geom[0]);
                //Console.WriteLine("Geom 1: " + geom[1]);
            }
            if (!isSuccess)
            {
                // this may still throw an exception
                // if so, throw the original exception since it has the input coordinates
                try
                {
                    result = SnapOverlayOp.Overlay(_geom[0], _geom[1], opCode);
                }
                catch (Exception)
                {
                    throw savedException;
                }
            }
            return(result);
        }
        public Geometry GetResultGeometry(SpatialFunction opCode)
        {
            Geometry result    = null;
            bool     isSuccess = false;
            ExceptionDispatchInfo savedException = null;

            try
            {
                // try basic operation with input geometries
                result = OverlayOp.Overlay(_geom[0], _geom[1], opCode);
                bool isValid = true;
                // not needed if noding validation is used
                //      boolean isValid = OverlayResultValidator.isValid(geom[0], geom[1], OverlayOp.INTERSECTION, result);
                // if (isValid)
                isSuccess = true;
            }
            catch (Exception ex)
            {
                savedException = ExceptionDispatchInfo.Capture(ex);
                // Ignore this exception, since the operation will be rerun
            }
            if (!isSuccess)
            {
                // this may still throw an exception
                // if so, throw the original exception since it has the input coordinates
                try
                {
                    result = SnapOverlayOp.Overlay(_geom[0], _geom[1], opCode);
                }
                catch (Exception)
                {
                    savedException.Throw();
                }
            }
            return(result);
        }
Beispiel #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="g0"></param>
        /// <param name="g1"></param>
        /// <param name="opCode"></param>
        /// <returns></returns>
        public static Geometry Overlay(Geometry g0, Geometry g1, SpatialFunction opCode)
        {
            var op = new SnapOverlayOp(g0, g1);

            return(op.GetResultGeometry(opCode));
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="g0"></param>
 /// <param name="g1"></param>
 /// <param name="opCode"></param>
 /// <returns></returns>
 public static IGeometry Overlay(IGeometry g0, IGeometry g1, SpatialFunction opCode)
 {
     SnapOverlayOp op = new SnapOverlayOp(g0, g1);
     return op.GetResultGeometry(opCode);
 }