Example #1
0
        /// <summary>
        /// A basic strategy for finding split points when nothing extra is known about the geometry of
        /// the situation.
        /// </summary>
        /// <param name="seg">the encroached segment</param>
        /// <param name="encroachPt">the encroaching point</param>
        /// <returns>the point at which to split the encroached segment</returns>
        public Coordinate FindSplitPoint(Segment seg, Coordinate encroachPt)
        {
            var    lineSeg  = seg.LineSegment;
            double segLen   = lineSeg.Length;
            double midPtLen = segLen / 2;
            var    splitSeg = new SplitSegment(lineSeg);

            var projPt = ProjectedSplitPoint(seg, encroachPt);

            /*
             * Compute the largest diameter (length) that will produce a split segment which is not
             * still encroached upon by the encroaching point (The length is reduced slightly by a
             * safety factor)
             */
            double nonEncroachDiam = projPt.Distance(encroachPt) * 2 * 0.8; // .99;
            double maxSplitLen     = nonEncroachDiam;

            if (maxSplitLen > midPtLen)
            {
                maxSplitLen = midPtLen;
            }
            splitSeg.MinimumLength = maxSplitLen;

            splitSeg.SplitAt(projPt);

            return(splitSeg.SplitPoint);
        }
        /// <summary>
        /// A basic strategy for finding split points when nothing extra is known about the geometry of
        /// the situation.
        /// </summary>
        /// <param name="seg">the encroached segment</param>
        /// <param name="encroachPt">the encroaching point</param>
        /// <returns>the point at which to split the encroached segment</returns>
        public Coordinate FindSplitPoint(Segment seg, Coordinate encroachPt)
        {
            var lineSeg = seg.LineSegment;
            var segLen = lineSeg.Length;
            var midPtLen = segLen / 2;
            var splitSeg = new SplitSegment(lineSeg);

            var projPt = ProjectedSplitPoint(seg, encroachPt);
            /*
             * Compute the largest diameter (length) that will produce a split segment which is not
             * still encroached upon by the encroaching point (The length is reduced slightly by a
             * safety factor)
             */
            var nonEncroachDiam = projPt.Distance(encroachPt) * 2 * 0.8; // .99;
            var maxSplitLen = nonEncroachDiam;
            if (maxSplitLen > midPtLen) {
                maxSplitLen = midPtLen;
            }
            splitSeg.MinimumLength = maxSplitLen;

            splitSeg.SplitAt(projPt);

            return splitSeg.SplitPoint;
        }