/** Generates a TripPlan from a set of paths */
  public TripPlan generatePlan(List<GraphPath> paths, RoutingRequest request) {

    GraphPath exemplar = paths.get(0);
    Vertex tripStartVertex = exemplar.getStartVertex();
    Vertex tripEndVertex = exemplar.getEndVertex();
    String startName = tripStartVertex.getName();
    String endName = tripEndVertex.getName();

    // Use vertex labels if they don't have names
    if (startName == null) {
      startName = tripStartVertex.getLabel();
    }
    if (endName == null) {
      endName = tripEndVertex.getLabel();
    }
    Place from = new Place(tripStartVertex.getX(), tripStartVertex.getY(), startName);
    Place to = new Place(tripEndVertex.getX(), tripEndVertex.getY(), endName);

    TripPlan plan = new TripPlan(from, to, request.getDateTime());

    for (GraphPath path : paths) {
      Itinerary itinerary = generateItinerary(path, request.getShowIntermediateStops());
      plan.addItinerary(itinerary);
    }
    return plan;
  }
 private Vertex getVertexByCrossStreets(String s1, String s2) {
   for (Vertex v : Context.getInstance().graph.getVertices()) {
     if (v.getName().contains(s1) && v.getName().contains(s2)) {
       return v;
     }
   }
   return null;
 }
  /**
   * Makes a new Place from a state. Contains information about time.
   *
   * @return
   */
  private Place makePlace(State state, boolean time) {
    Vertex v = state.getVertex();
    Coordinate endCoord = v.getCoordinate();
    String name = v.getName();
    Place place;
    if (time) {
      Calendar timeAtState = makeCalendar(state);
      place = new Place(endCoord.x, endCoord.y, name, timeAtState);
    } else {
      place = new Place(endCoord.x, endCoord.y, name);
    }

    if (v instanceof TransitVertex) {
      TransitVertex transitVertex = (TransitVertex) v;
      place.stopId = transitVertex.getStopId();
      place.stopCode = transitVertex.getStopCode();
      place.zoneId = state.getZone();
    }
    return place;
  }