/// <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)); }
/// <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); }