Пример #1
0
 private void finalizeLeg(
     Leg leg,
     State state,
     List<State> states,
     int start,
     int end,
     CoordinateArrayListSequence coordinates) {
   if (start != -1) {
     leg.walkSteps = getWalkSteps(states.subList(start, end + 1));
   }
   leg.endTime = makeCalendar(state.getBackState());
   Geometry geometry = GeometryUtils.getGeometryFactory().createLineString(coordinates);
   leg.legGeometry = PolylineEncoder.createEncodings(geometry);
   leg.to = makePlace(state, true);
   coordinates.clear();
 }
  private void finalizeLeg(
      Leg leg,
      State state,
      List<State> states,
      int start,
      int end,
      CoordinateArrayListSequence coordinates,
      Itinerary itinerary) {

    // this leg has already been added to the itinerary, so we actually want the penultimate leg, if
    // any
    if (states != null) {
      int extra = 0;
      WalkStep continuation = null;
      if (itinerary.legs.size() >= 2) {
        Leg previousLeg = itinerary.legs.get(itinerary.legs.size() - 2);
        if (previousLeg.walkSteps != null) {
          continuation = previousLeg.walkSteps.get(previousLeg.walkSteps.size() - 1);
          extra = 1;
        }
      }
      if (end == states.size() - 1) {
        extra = 1;
      }

      leg.walkSteps = getWalkSteps(states.subList(start, end + extra), continuation);
    }
    leg.endTime = makeCalendar(state.getBackState());
    Geometry geometry = GeometryUtils.getGeometryFactory().createLineString(coordinates);
    leg.legGeometry = PolylineEncoder.createEncodings(geometry);
    Edge backEdge = state.getBackEdge();
    String name;
    if (backEdge instanceof StreetEdge) {
      name = backEdge.getName();
    } else {
      name = state.getVertex().getName();
    }
    leg.to = makePlace(state, name, true);
    coordinates.clear();
  }