Exemplo n.º 1
0
        /// <summary>
        /// Creates stub edges for all the intersections in this
        /// Edge (if any) and inserts them into the graph.
        /// </summary>
        /// <param name="edge"></param>
        /// <param name="l"></param>
        public virtual void ComputeEdgeEnds(Edge edge, IList l)
        {
            EdgeIntersectionList eiList = edge.EdgeIntersectionList;

            // ensure that the list has entries for the first and last point of the edge
            eiList.AddEndpoints();

            IEnumerator      it     = eiList.GetEnumerator();
            EdgeIntersection eiCurr = null;

            // no intersections, so there is nothing to do
            if (!it.MoveNext())
            {
                return;
            }
            EdgeIntersection eiNext = (EdgeIntersection)it.Current;

            do
            {
                EdgeIntersection eiPrev = eiCurr;
                eiCurr = eiNext;
                eiNext = null;

                if (it.MoveNext())
                {
                    eiNext = (EdgeIntersection)it.Current;
                }

                if (eiCurr != null)
                {
                    CreateEdgeEndForPrev(edge, l, eiCurr, eiPrev);
                    CreateEdgeEndForNext(edge, l, eiCurr, eiNext);
                }
            }while (eiCurr != null);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="pts"></param>
        /// <param name="label"></param>
        public Edge(IList<Coordinate> pts, Label label)
        {
            _eiList = new EdgeIntersectionList(this);

            _pts = pts;
            base.Label = label;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Check that a ring does not self-intersect, except at its endpoints.
        /// Algorithm is to count the number of times each node along edge occurs.
        /// If any occur more than once, that must be a self-intersection.
        /// </summary>
        private void CheckNoSelfIntersectingRing(EdgeIntersectionList eiList)
        {
            ISet nodeSet = new HashedSet();
            bool isFirst = true;

            for (IEnumerator i = eiList.Iterator(); i.MoveNext();)
            {
                EdgeIntersection ei = (EdgeIntersection)i.Current;
                if (isFirst)
                {
                    isFirst = false;
                    continue;
                }
                if (nodeSet.Contains(ei.coord))
                {
                    validErr = new ValidationError(
                        ValidationErrorType.RingSelfIntersection, ei.coord);

                    return;
                }
                else
                {
                    nodeSet.Add(ei.coord);
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Check that a ring does not self-intersect, except at its endpoints.
        /// Algorithm is to count the number of times each node along edge occurs.
        /// If any occur more than once, that must be a self-intersection.
        /// </summary>
        /// <param name="eiList"></param>
        private void CheckSelfIntersectingRing(EdgeIntersectionList eiList)
        {
            //Set nodeSet = new TreeSet(); awc  don't need sorted list, just a hashtable
            Hashtable nodeSet = new Hashtable();
            bool      isFirst = true;

            //for (Iterator i = eiList.iterator(); i.hasNext(); )
            foreach (EdgeIntersection ei in eiList)
            {
                //EdgeIntersection ei = (EdgeIntersection) i.next();
                if (isFirst)
                {
                    isFirst = false;
                    continue;
                }
                if (nodeSet.Contains(ei.Coordinate))
                {
                    _validErr = new TopologyValidationError(
                        TopologyValidationError.RingSelfIntersection,
                        ei.Coordinate);
                    return;
                }
                else
                {
                    //TODO: awc - should probably use hashcode
                    nodeSet.Add(ei.Coordinate, ei.Coordinate);
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Find a point from the list of testCoords
        /// that is NOT a node in the edge for the list of searchCoords.
        /// </summary>
        /// <param name="testCoords"></param>
        /// <param name="searchRing"></param>
        /// <param name="graph"></param>
        /// <returns>The point found, or <c>null</c> if none found.</returns>
        public static ICoordinate FindPointNotNode(ICoordinate[] testCoords, ILinearRing searchRing, GeometryGraph graph)
        {
            // find edge corresponding to searchRing.
            Edge searchEdge = graph.FindEdge(searchRing);
            // find a point in the testCoords which is not a node of the searchRing
            EdgeIntersectionList eiList = searchEdge.EdgeIntersectionList;

            // somewhat inefficient - is there a better way? (Use a node map, for instance?)
            foreach (ICoordinate pt in testCoords)
            {
                if (!eiList.IsIntersection(pt))
                {
                    return(pt);
                }
            }
            return(null);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Find a point from the list of testCoords
        /// that is NOT a node in the edge for the list of searchCoords
        /// </summary>
        /// <returns> the point found, or null if none found
        /// </returns>
        internal static Coordinate FindPointNotNode(ICoordinateList testCoords,
                                                    LinearRing searchRing, GeometryGraph graph)
        {
            // find edge corresponding to searchRing.
            Edge searchEdge = graph.FindEdge(searchRing);
            // find a point in the testCoords which is not a node of the searchRing
            EdgeIntersectionList eiList = searchEdge.EdgeIntersectionList;

            // somewhat inefficient - is there a better way? (Use a node map, for instance?)
            for (int i = 0; i < testCoords.Count; i++)
            {
                Coordinate pt = testCoords[i];
                if (!eiList.IsIntersection(pt))
                {
                    return(pt);
                }
            }
            return(null);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Check that a ring does not self-intersect, except at its endpoints.
        /// Algorithm is to count the number of times each node along edge occurs.
        /// If any occur more than once, that must be a self-intersection.
        /// </summary>
        private void CheckNoSelfIntersectingRing(EdgeIntersectionList eiList)
        {
            var  nodeSet = new HashSet <Coordinate>();
            bool isFirst = true;

            foreach (EdgeIntersection ei in eiList)
            {
                if (isFirst)
                {
                    isFirst = false;
                    continue;
                }
                if (nodeSet.Contains(ei.Coordinate))
                {
                    _validErr = new TopologyValidationError(TopologyValidationErrorType.RingSelfIntersection, ei.Coordinate);
                    return;
                }
                nodeSet.Add(ei.Coordinate);
            }
        }
Exemplo n.º 8
0
        }         // public ArrayList ComputeEdgeEnds( ArrayList edges )

        /// <summary>
        /// Creates stub edges for all the intersections in this Edge (if any) and inserts them into the graph.
        /// </summary>
        /// <param name="edge"></param>
        /// <param name="list"></param>
        public void ComputeEdgeEnds(Edge edge, ArrayList list)
        {
            EdgeIntersectionList eiList = edge.EdgeIntersectionList;

            //Trace.WriteLine( eiList.ToString() );

            // ensure that the list has entries for the first and last point of the edge
            if (!edge.IsClosed)
            {
                eiList.AddEndpoints();
            }

            EdgeIntersection eiPrev = null;
            EdgeIntersection eiCurr = null;

            // no intersections, so there is nothing to do
            if (eiList.IsEmpty())
            {
                return;                                         // return if the list is empty
            }
            int index = 0;                                      // index of eiList array.
            EdgeIntersection eiNext = eiList[index];            // gets the first intersection

            do
            {
                index++;
                eiPrev = eiCurr;                                // previouse one or null for first loop
                eiCurr = eiNext;                                // current one or the first one
                eiNext = null;
                if (index < eiList.Count)
                {
                    eiNext = eiList[index];                                             // if there are more
                }
                if (eiCurr != null)
                {
                    CreateEdgeEndForPrev(edge, list, eiCurr, eiPrev);
                    CreateEdgeEndForNext(edge, list, eiCurr, eiNext);
                }
            } while (eiCurr != null);
        }         // public void ComputeEdgeEnds( Edge edge, ArrayList l )
Exemplo n.º 9
0
 /// <summary>
 /// Check that a ring does not self-intersect, except at its endpoints.
 /// Algorithm is to count the number of times each node along edge occurs.
 /// If any occur more than once, that must be a self-intersection.
 /// </summary>
 private void CheckNoSelfIntersectingRing(EdgeIntersectionList eiList)
 {
     ISet nodeSet = new ListSet();    
     bool isFirst = true;
     foreach(EdgeIntersection ei in eiList)
     {                
         if (isFirst)
         {
             isFirst = false;
             continue;
         }
         if (nodeSet.Contains(ei.Coordinate))
         {
             _validErr = new TopologyValidationError(TopologyValidationErrors.RingSelfIntersection, ei.Coordinate);
             return;
         }
         nodeSet.Add(ei.Coordinate);
     }
 }