All Downloads are FREE. Search and download functionalities are using the official Maven repository.

edu.kit.ifv.mobitopp.visum.reader.VisumPtVehicleJourneyReader Maven / Gradle / Ivy

Go to download

mobiTopp (http://mobitopp.ifv.kit.edu/) is an agent-based travel demand model developed at the Institute for transport studies at the Karlsruhe Institute of Technology (http://www.ifv.kit.edu/english/index.php). Publications about mobiTopp can be found on the project site (http://mobitopp.ifv.kit.edu/28.php).

The newest version!
package edu.kit.ifv.mobitopp.visum.reader;

import static java.util.stream.Collectors.toList;

import java.util.List;
import java.util.Map;
import java.util.stream.Stream;

import edu.kit.ifv.mobitopp.util.dataimport.Row;
import edu.kit.ifv.mobitopp.visum.NetfileLanguage;
import edu.kit.ifv.mobitopp.visum.VisumPtLineRoute;
import edu.kit.ifv.mobitopp.visum.VisumPtTimeProfile;
import edu.kit.ifv.mobitopp.visum.VisumPtVehicleJourney;
import edu.kit.ifv.mobitopp.visum.VisumPtVehicleJourneySection;

public class VisumPtVehicleJourneyReader extends VisumBaseReader {

  private final Map ptLineRoutes;
  private final Map ptTimeProfiles;
  private final Map> sectionMapping;

  public VisumPtVehicleJourneyReader(
      NetfileLanguage language, Map ptLineRoutes,
      Map ptTimeProfiles,
      Map> sections) {
    super(language);
    this.ptLineRoutes = ptLineRoutes;
    this.ptTimeProfiles = ptTimeProfiles;
    this.sectionMapping = sections;
  }

  public List readJourneys(Stream content) {
    return content.map(this::createJourney).collect(toList());
  }

  private VisumPtVehicleJourney createJourney(Row row) {
    String lineId = lineRouteIdOf(row);
    String profileName = profileNameOf(row);
    String profileId = lineId + ";" + profileName;

    VisumPtLineRoute route = ptLineRoutes.get(lineId);
    VisumPtTimeProfile profile = ptTimeProfiles.get(profileId);

    int number = numberOf(row);
    String name = nameOf(row);
    int departure = departureOf(row);
    int fromIndex = fromTimeProfileElementIndexOf(row);
    int toIndex = toTimeProfileElementIndexOf(row);
    List sections = this.sectionMapping.get(number);
    return new VisumPtVehicleJourney(number, name, departure, route, profile, fromIndex, toIndex,
        sections);
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy