コード例 #1
0
        /// <summary>
        /// Gets the first point on the given edge starting a the given vertex.
        /// </summary>
        public static Coordinate GetFirstPoint(this RoutingNetwork graph, RoutingEdge edge, uint vertex)
        {
            var points = new List <Coordinate>();

            if (edge.From == vertex)
            { // start at from.
                if (edge.Shape == null)
                {
                    return(graph.GetVertex(edge.To));
                }
                var shape = edge.Shape.GetEnumerator();
                shape.MoveNext();
                return(shape.Current);
            }
            else if (edge.To == vertex)
            { // start at to.
                if (edge.Shape == null)
                {
                    return(graph.GetVertex(edge.From));
                }
                var shape = edge.Shape.Reverse().GetEnumerator();
                shape.MoveNext();
                return(shape.Current);
            }
            throw new ArgumentOutOfRangeException(string.Format("Vertex {0} is not part of edge {1}.",
                                                                vertex, edge.Id));
        }
コード例 #2
0
 /// <summary>
 /// Returns a directed version of the edge-id. Smaller than 0 if inverted, as-is if not inverted.
 /// </summary>
 /// <remarks>
 /// The relationship between a regular edge id and a directed edge id:
 /// - 0 -> 1 forward, -1 backward.
 /// - all other id's are offset by 1 and postive when forward, negative when backward.
 /// </remarks>
 public static long IdDirected(this RoutingEdge edge)
 {
     if (edge.DataInverted)
     {
         return(-(edge.Id + 1));
     }
     return(edge.Id + 1);
 }
コード例 #3
0
 /// <summary>
 /// Gets the vertex on this edge that is not the given vertex.
 /// </summary>
 public static uint GetOther(this RoutingEdge edge, uint vertex)
 {
     if (edge.From == vertex)
     {
         return(edge.To);
     }
     else if (edge.To == vertex)
     {
         return(edge.From);
     }
     throw new ArgumentOutOfRangeException(string.Format("Vertex {0} is not part of edge {1}.",
                                                         vertex, edge.Id));
 }
コード例 #4
0
        /// <summary>
        /// Gets the shape points including the two vertices.
        /// </summary>
        public static List <Coordinate> GetShape(this RoutingNetwork graph, RoutingEdge edge)
        {
            var points = new List <Coordinate>();

            points.Add(graph.GetVertex(edge.From));
            var shape = edge.Shape;

            if (shape != null)
            {
                if (edge.DataInverted)
                {
                    shape = shape.Reverse();
                }
                var shapeEnumerator = shape.GetEnumerator();
                shapeEnumerator.Reset();
                while (shapeEnumerator.MoveNext())
                {
                    points.Add(shapeEnumerator.Current);
                }
            }
            points.Add(graph.GetVertex(edge.To));
            return(points);
        }