예제 #1
0
        }         // public EdgeIntersection this[int index]

        /// <summary>
        /// Adds an intersection into the list, if it isn't already there.
        /// The input segmentIndex and distance are expected to be normalized.
        /// </summary>
        /// <param name="coord"></param>
        /// <param name="segmentIndex"></param>
        /// <param name="distance"></param>
        /// <returns>return the EdgeIntersection found or added</returns>
        public EdgeIntersection Add(Coordinate coord, int segmentIndex, double distance)
        {
            // this varies from the java code due to the differences in arraylist.  java can add based on the
            // iterator.
            int              indexAt;
            bool             isInList = FindInsertionPoint(segmentIndex, distance, out indexAt);
            EdgeIntersection ei;

            if (!isInList)
            {
                ei = new EdgeIntersection(coord, segmentIndex, distance);
                if (indexAt < 0)                        // not found and greater than all others in list.
                {
                    _list.Add(ei);
                }
                else
                {
                    _list.Insert(indexAt, ei);                          // not found but insert at this index to keep order.
                }
            }
            else
            {
                ei = (EdgeIntersection)_list[indexAt];                  // found in list at this index.
            }
            return(ei);
        }
예제 #2
0
        }         // public void AddSplitEdges(ArrayList edgeList)

        /// <summary>
        /// Create a new "split edge" with the section of points between
        /// (and including) the two intersections.
        /// The label for the new edge is the same as the label for the parent edge.
        /// </summary>
        private Edge CreateSplitEdge(EdgeIntersection ei0, EdgeIntersection ei1)
        {
            //Trace.WriteLine("\ncreateSplitEdge"); Trace.WriteLine(ei0.ToString()); Trace.WriteLine(ei1.ToString());
            int npts = ei1.SegmentIndex - ei0.SegmentIndex + 2;

            Coordinate lastSegStartPt = _edge.Coordinates[ei1.SegmentIndex];
            // if the last intersection point is not equal to the its segment start pt,
            // add it to the points list as well.
            // (This check is needed because the distance metric is not totally reliable!)
            bool useIntPt1 = ei1.Distance > 0.0 || !ei1.Coordinate.Equals(lastSegStartPt);

            Coordinates coordinatePts = new Coordinates();              // new coordinates collection

            coordinatePts.Add(new Coordinate(ei0.Coordinate));
            for (int i = ei0.SegmentIndex + 1; i <= ei1.SegmentIndex; i++)
            {
                coordinatePts.Add(_edge.Coordinates[i]);
            }

            if (useIntPt1)
            {
                coordinatePts.Add(ei1.Coordinate);
            }

            return(new Edge(coordinatePts, new Label(_edge.Label)));
        }         // Edge CreateSplitEdge(EdgeIntersection ei0, EdgeIntersection ei1)
예제 #3
0
        }         // Edge CreateSplitEdge(EdgeIntersection ei0, EdgeIntersection ei1)

        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("Intersections:");
            foreach (object objEdgeIntersection in _list)
            {
                EdgeIntersection ei = (EdgeIntersection)objEdgeIntersection;
                sb.Append(ei.ToString());
            }
            return(sb.ToString());
        }         //public override string ToString()
예제 #4
0
        }         // private void InsertBoundaryPoint( int argIndex, Coordinate coord )

        private void AddSelfIntersectionNodes(int argIndex)
        {
            foreach (object objEdge in _edges)
            {
                Edge e    = (Edge)objEdge;
                int  eLoc = e.Label.GetLocation(argIndex);
                //for (Iterator eiIt = e.eiList.iterator(); eiIt.hasNext(); )
                foreach (object objEdgeIntersection in e.EdgeIntersectionList)
                {
                    EdgeIntersection ei = (EdgeIntersection)objEdgeIntersection;
                    AddSelfIntersectionNode(argIndex, ei.Coordinate, eLoc);
                }
            }
        }         // private void AddSelfIntersectionNodes(int argIndex)
예제 #5
0
        }         // public void AddEndpoints()

        /// <summary>
        /// Creates new edges for all the edges that the intersections in this
        /// list split the parent edge into.
        /// </summary>
        /// <remarks>
        /// Adds the edges to the input list (this is so a single list can be used to accumulate all split edges for a Geometry).
        /// </remarks>
        /// <param name="edgeList"></param>
        public void AddSplitEdges(ArrayList edgeList)
        {
            // ensure that the list has entries for the first and last point of the edge
            AddEndpoints();

            // there should always be at least two entries in the list
            EdgeIntersection eiPrev = (EdgeIntersection)_list[0];

            for (int i = 1; i < _list.Count; i++)                       // start at 1st element cuz eiPrev is equal to 0th element.
            {
                EdgeIntersection ei      = (EdgeIntersection)_list[i];
                Edge             newEdge = CreateSplitEdge(eiPrev, ei);
                edgeList.Add(newEdge);
                eiPrev = ei;
            }     // for ( int i = 1; i < _list.Count; i++ )
        }         // public void AddSplitEdges(ArrayList edgeList)
예제 #6
0
파일: Edge.cs 프로젝트: tinuvieltr/geotools
        }         // public void AddIntersections(LineIntersector li, int segmentIndex, int geomIndex)

        /// <summary>
        /// Add an EdgeIntersection for intersection intIndex.
        /// </summary>
        /// <remarks>
        /// An intersection that falls exactly on a vertex of the edge is normalized
        /// to use the higher of the two possible segmentIndexes
        /// </remarks>
        /// <param name="li"></param>
        /// <param name="segmentIndex"></param>
        /// <param name="geomIndex"></param>
        /// <param name="intIndex"></param>
        public void AddIntersection(LineIntersector li, int segmentIndex, int geomIndex, int intIndex)
        {
            Coordinate intPt = new Coordinate(li.GetIntersection(intIndex));
            int        normalizedSegmentIndex = segmentIndex;
            double     dist = li.GetEdgeDistance(geomIndex, intIndex);
            //Trace.WriteLine("edge intpt: " + intPt + " dist: " + dist);
            // normalize the intersection point location
            int nextSegIndex = normalizedSegmentIndex + 1;

            if (nextSegIndex < _pts.Count)
            {
                Coordinate nextPt = _pts[nextSegIndex];
                //Trace.WriteLine("next pt: " + nextPt);
                if (intPt.Equals(nextPt))
                {
                    //Trace.WriteLine("normalized distance");
                    normalizedSegmentIndex = nextSegIndex;
                    dist = 0.0;
                }
            }
            //Add the intersection point to edge intersection list.
            EdgeIntersection ei = _eiList.Add(intPt, normalizedSegmentIndex, dist);
            //Trace.WriteLine( ei.ToString() );
        }         // public void AddIntersection(LineIntersector li, int segmentIndex, int geomIndex, int intIndex)