Ejemplo n.º 1
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="edge"></param>
 /// <param name="isForward"></param>
 /// <param name="isFirstEdge"></param>
 protected virtual void AddPoints(Edge edge, bool isForward, bool isFirstEdge)
 {
     IList<Coordinate> edgePts = edge.Coordinates;
     if (isForward)
     {
         int startIndex = 1;
         if (isFirstEdge) 
             startIndex = 0;
         for (int i = startIndex; i < edgePts.Count; i++)                
             _pts.Add(edgePts[i]);                
     }
     else
     { 
         // is backward
         int startIndex = edgePts.Count - 2;
         if (isFirstEdge) 
             startIndex = edgePts.Count - 1;
         for (int i = startIndex; i >= 0; i--)                
             _pts.Add(edgePts[i]);                
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="line"></param>
        private void AddLineString(IBasicGeometry line)
        {
            IList<Coordinate> coord = CoordinateArrays.RemoveRepeatedPoints(line.Coordinates);

            if (coord.Count < 2) 
            {
                _hasTooFewPoints = true;
                _invalidPoint = coord[0];
                return;
            }

            // add the edge for the LineString
            // line edges do not have locations for their left and right sides
            Edge e = new Edge(coord, new Label(_argIndex, Locations.Interior));
            _lineEdgeMap.Add(line, e);
            InsertEdge(e);

            /*
            * Add the boundary points of the LineString, if any.
            * Even if the LineString is closed, add both points as if they were endpoints.
            * This allows for the case that the node already exists and is a boundary point.
            */
            Assert.IsTrue(coord.Count >= 2, "found LineString with single point");
            InsertBoundaryPoint(_argIndex, coord[0]);
            InsertBoundaryPoint(_argIndex, coord[coord.Count - 1]);

        }
Ejemplo n.º 3
0
 /// <summary> 
 /// Add an Edge computed externally.  The label on the Edge is assumed
 /// to be correct.
 /// </summary>
 /// <param name="e"></param>
 public virtual void AddEdge(Edge e)
 {
     InsertEdge(e);
     IList<Coordinate> coord = e.Coordinates;
     // insert the endpoint as a node, to mark that it is on the boundary
     InsertPoint(_argIndex, coord[0], Locations.Boundary);
     InsertPoint(_argIndex, coord[coord.Count - 1], Locations.Boundary);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Adds a new EdgeEnd to the planar graph
 /// </summary>
 /// <param name="e"></param>
 protected virtual void InsertEdge(Edge e)
 {
     _edges.Add(e);
 }
Ejemplo n.º 5
0
 /// <summary> 
 /// The left and right topological location arguments assume that the ring is oriented CW.
 /// If the ring is in the opposite orientation,
 /// the left and right locations must be interchanged.
 /// </summary>
 /// <param name="lr"></param>
 /// <param name="cwLeft"></param>
 /// <param name="cwRight"></param>
 private void AddPolygonRing(IBasicGeometry lr, Locations cwLeft, Locations cwRight)
 {
     IList<Coordinate> coord = CoordinateArrays.RemoveRepeatedPoints(lr.Coordinates);
     if (coord.Count < 4) 
     {
         _hasTooFewPoints = true;
         _invalidPoint = coord[0];
         return;
     }
     Locations left = cwLeft;
     Locations right = cwRight;
     if (CGAlgorithms.IsCounterClockwise(coord)) 
     {
         left = cwRight;
         right = cwLeft;
     }
     Edge e = new Edge(coord, new Label(_argIndex, Locations.Boundary, left, right));
     _lineEdgeMap.Add(lr, e);
     InsertEdge(e);
     // insert the endpoint as a node, to mark that it is on the boundary
     InsertPoint(_argIndex, coord[0], Locations.Boundary);
 }
Ejemplo n.º 6
0
 /// <summary> 
 /// Returns the EdgeEnd which has edge e as its base edge
 /// (MD 18 Feb 2002 - this should return a pair of edges).
 /// </summary>
 /// <param name="e"></param>
 /// <returns> The edge, if found <c>null</c> if the edge was not found.</returns>
 public virtual EdgeEnd FindEdgeEnd(Edge e)
 {
     for (IEnumerator i = EdgeEnds.GetEnumerator(); i.MoveNext(); )
     {
         EdgeEnd ee = (EdgeEnd)i.Current;
         if (ee.Edge == e)
             return ee;
     }
     return null;
 }
Ejemplo n.º 7
0
 /// <summary> 
 /// Insert an edge unless it is already in the list.
 /// </summary>
 /// <param name="e"></param>
 public virtual void Add(Edge e)
 {
     _edges.Add(e);
     _index.Insert(e.Envelope, e);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Remove the selected Edge element from the list if present.
 /// </summary>
 /// <param name="e">Edge element to remove from list</param>
 public virtual void Remove(Edge e)
 {
     _edges.Remove(e);
 }
Ejemplo n.º 9
0
 /// <summary>
 /// If the edge e is already in the list, return its index.
 /// </summary>
 /// <param name="e"></param>
 /// <returns>  
 /// Index, if e is already in the list,
 /// -1 otherwise.
 /// </returns>
 public virtual int FindEdgeIndex(Edge e)
 {
     for (int i = 0; i < _edges.Count; i++)
         if (_edges[i].Equals(e))
             return i;            
     return -1;
 }
Ejemplo n.º 10
0
 // <FIX> fast lookup for edges
 /// <summary>
 /// If there is an edge equal to e already in the list, return it.
 /// Otherwise return null.
 /// </summary>
 /// <param name="e"></param>
 /// <returns>  
 /// equal edge, if there is one already in the list,
 /// null otherwise.
 /// </returns>
 public virtual Edge FindEqualEdge(Edge e)
 {
     ICollection testEdges = _index.Query(e.Envelope);
     for (IEnumerator i = testEdges.GetEnumerator(); i.MoveNext(); ) 
     {
         Edge testEdge = (Edge)i.Current;
         if (testEdge.Equals(e)) 
             return testEdge;
     }
     return null;
 }