예제 #1
0
        /// <summary>
        /// Simplify these intersection results by converting any grazing intersections
        /// into simple intersections. Given that there are any grazes, the results will be
        /// re-sorted so that the end of each graze comes at it's proper sequence along the
        /// line that they relate to (this covers the fact that grazes may overlap). Any
        /// consecutive duplicates will be removed too (covering the fact that the intersected
        /// line may have passed through a node). Intersections at the end of the line will be
        /// eliminated.
        /// </summary>
        /// <returns>The number of intersection after simplification.</returns>
        internal uint Simplify()
        {
            // Return if there are no intersections.
            if (m_Data == null || m_Data.Count == 0)
            {
                return(0);
            }

            // If we have any grazes, copy each intersection to a new results array (and
            // for each graze, stick in the end of the graze as well).
            uint ngraze = this.NumGraze;

            if (ngraze > 0)
            {
                List <IntersectionData> newres = new List <IntersectionData>((int)(m_Data.Count + ngraze));
                foreach (IntersectionData d in m_Data)
                {
                    if (d.IsGraze)
                    {
                        newres.Add(new IntersectionData(d.P1));
                        newres.Add(new IntersectionData(d.P2));
                    }
                    else
                    {
                        newres.Add(d);
                    }
                }

                m_Data = newres;
            }

            // Ensure the intersections are sorted properly.
            this.Sort(true);

            // Ensure context is set properly.
            SetContext(m_IntersectedObject.LineGeometry);

            // Null out any consecutive duplicates, as well as intersections
            // at the end of the line.

            int nLeft = m_Data.Count;                   // How many have we got left?

            // Reset any consecutive duplicates.

            IntersectionData prev = m_Data[0];
            IntersectionData cur  = null;

            for (int i = 1; i < m_Data.Count; i++, prev = cur)
            {
                cur = m_Data[i];

                // Reset the previous intersection if it has the same sort value
                // as the current one.
                if (Math.Abs(cur.GetDeltaSort(prev)) < Constants.XYRES)
                {
                    prev.Reset();
                    nLeft--;
                }
            }

            // Reset anything at either end of the line.
            foreach (IntersectionData d in m_Data)
            {
                if (d.IsEnd)
                {
                    d.Reset();
                    nLeft--;
                }
            }

            // Squeeze out the redundant intersections.
            return(Squeeze(nLeft));
        }
예제 #2
0
        /// <summary>
        /// Appends a simple intersection.
        /// </summary>
        /// <param name="xi">Easting of the intersection.</param>
        /// <param name="yi">Northing of the intersection.</param>
        /// <param name="sortval">Sort value (default=0.0).</param>
        internal void Append(double xi, double yi, double sortval)
        {
            IntersectionData xsect = new IntersectionData(xi, yi, sortval);

            Append(xsect);
        }
예제 #3
0
        /// <summary>
        /// Appends a grazing intersection.
        /// </summary>
        /// <param name="x1">Easting of the 1st intersection.</param>
        /// <param name="y1">Northing of the 1st intersection.</param>
        /// <param name="x2">Easting of the 2nd intersection.</param>
        /// <param name="y2">Northing of the 2nd intersection.</param>
        internal void Append(double x1, double y1, double x2, double y2)
        {
            IntersectionData xsect = new IntersectionData(x1, y1, x2, y2);

            Append(xsect);
        }
예제 #4
0
        /*
         * // Multisegment
         * uint Intersect(IPointGeometry[] locs)
         * {
         *  return m_Object.Intersect(this, locs);
         * }
         */

        /// <summary>
        /// Append intersection info to this object.
        /// </summary>
        /// <param name="xsect">The intersection info to append.</param>
        void Append(IntersectionData xsect)
        {
            m_Data.Add(xsect);
        }