Пример #1
0
        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
            }
            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);
        }
Пример #2
0
        /// <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));
        }