예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="geom"></param>
        /// <returns></returns>
        public bool Intersects(IGeometry geom)
        {
            if (!rectEnv.Intersects(geom.EnvelopeInternal))
            {
                return(false);
            }
            // test envelope relationships
            EnvelopeIntersectsVisitor visitor = new EnvelopeIntersectsVisitor(rectEnv);

            visitor.ApplyTo(geom);
            if (visitor.Intersects())
            {
                return(true);
            }

            // test if any rectangle corner is contained in the target
            ContainsPointVisitor ecpVisitor = new ContainsPointVisitor(rectangle);

            ecpVisitor.ApplyTo(geom);
            if (ecpVisitor.ContainsPoint())
            {
                return(true);
            }

            // test if any lines intersect
            LineIntersectsVisitor liVisitor = new LineIntersectsVisitor(rectangle);

            liVisitor.ApplyTo(geom);
            if (liVisitor.Intersects())
            {
                return(true);
            }

            return(false);
        }
예제 #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="geom"></param>
        /// <returns></returns>
        public bool Intersects(IGeometry geom)
        {
            if (!rectEnv.Intersects(geom.EnvelopeInternal))
                return false;
            // test envelope relationships
            EnvelopeIntersectsVisitor visitor = new EnvelopeIntersectsVisitor(rectEnv);
            visitor.ApplyTo(geom);
            if (visitor.Intersects())
                return true;

            // test if any rectangle corner is contained in the target
            ContainsPointVisitor ecpVisitor = new ContainsPointVisitor(rectangle);
            ecpVisitor.ApplyTo(geom);
            if (ecpVisitor.ContainsPoint())
                return true;

            // test if any lines intersect
            LineIntersectsVisitor liVisitor = new LineIntersectsVisitor(rectangle);
            liVisitor.ApplyTo(geom);
            if (liVisitor.Intersects())
                return true;

            return false;
        }