Ejemplo n.º 1
0
        /// <summary>
        /// Confirms that a potential link is valid. For a link to be valid, the
        /// midpoint of the link must fall inside the specified polygon, and the
        /// line connecting the 2 points cannot intersect anything.
        /// </summary>
        /// <param name="other">The end of the proposed point to link to.</param>
        /// <param name="pol">The polygon the link must fall completely inside.</param>
        /// <returns>True if link is valid.</returns>
        internal bool IsLinkValid(PolygonLink other, Polygon pol)
        {
            // 22-MAR-00 There may be no point at a corner.
            if (m_Point == null || other.Point == null)
            {
                return(false);
            }

            // Get the midpoint of the link.
            IPosition mid = Geom.MidPoint(m_Point, other.Point);

            // Confirm the midpoint falls inside the right polygon.
            if (!pol.IsRingEnclosing(mid))
            {
                return(false);
            }

            // Locate any intersections formed by the proposed link (considering
            // only the currently active theme).
            LineGeometry       seg   = new SegmentGeometry(m_Point, other.m_Point);
            IntersectionFinder xsect = new IntersectionFinder(seg, true);

            // The proposed link is not valid if it intersects anything
            // along the length of the segment, or has any grazes.
            if (xsect.IsGrazing || xsect.IsSplitNeeded)
            {
                return(false);
            }

            return(true);
        }