public static void convertMatsim2KS(String signalSystemsFilename,String signalGroupsFilename,String signalControlFilename,String networkFilename,String lanesFilename,String populationFilename,double startTime,double endTime,double signalsBoundingBoxOffset,double cuttingBoundingBoxOffset,double freeSpeedFilter,boolean useFreeSpeedTravelTime,double maximalLinkLength,double matsimPopSampleSize,double ksModelCommoditySampleSize,double minCommodityFlow,boolean simplifyNetwork,int cellsX,int cellsY,String scenarioDescription,String dateFormat,String outputDirectory) throws Exception {
  String spCost="tt";
  if (!useFreeSpeedTravelTime)   spCost="dist";
  outputDirectory+=dateFormat + "_minflow_" + minCommodityFlow+ "_time"+ startTime+ "-"+ endTime+ "_speedFilter"+ freeSpeedFilter+ "_SP_"+ spCost+ "_cBB"+ cuttingBoundingBoxOffset+ "_sBB"+ signalsBoundingBoxOffset+ "/";
  String ksModelOutputFilename="ks2010_model_" + Double.toString(minCommodityFlow) + "_"+ Double.toString(startTime)+ "_"+ Double.toString(cuttingBoundingBoxOffset)+ ".xml";
  OutputDirectoryLogging.initLoggingWithOutputDirectory(outputDirectory);
  String shapeFileDirectory=createShapeFileDirectory(outputDirectory);
  Scenario fullScenario=DgScenarioUtils.loadScenario(networkFilename,populationFilename,lanesFilename,signalSystemsFilename,signalGroupsFilename,signalControlFilename);
  NetLanesSignalsShrinker scenarioShrinker=new NetLanesSignalsShrinker(fullScenario,CRS);
  scenarioShrinker.shrinkScenario(outputDirectory,shapeFileDirectory,cuttingBoundingBoxOffset,freeSpeedFilter,useFreeSpeedTravelTime,maximalLinkLength,simplifyNetwork);
  ZoneBuilder zoneBuilder=new ZoneBuilder(CRS);
  DgZones zones=zoneBuilder.createAndWriteZones(scenarioShrinker.getShrinkedNetwork(),scenarioShrinker.getCuttingBoundingBox(),cellsX,cellsY,shapeFileDirectory);
  PopulationToOd pop2od=new PopulationToOd();
  pop2od.setMatsimPopSampleSize(matsimPopSampleSize);
  pop2od.setOriginalToSimplifiedLinkMapping(scenarioShrinker.getOriginalToSimplifiedLinkIdMatching());
  pop2od.convertPopulation2OdPairs(zones,fullScenario.getNetwork(),fullScenario.getPopulation(),CRS,scenarioShrinker.getShrinkedNetwork(),scenarioShrinker.getCuttingBoundingBox(),startTime,endTime,shapeFileDirectory);
  M2KS2010Converter converter=new M2KS2010Converter(scenarioShrinker.getShrinkedNetwork(),scenarioShrinker.getShrinkedLanes(),scenarioShrinker.getShrinkedSignals(),signalsBoundingBoxOffset,CRS);
  String description=createDescription(cellsX,cellsY,startTime,endTime,cuttingBoundingBoxOffset,matsimPopSampleSize,ksModelCommoditySampleSize,minCommodityFlow);
  converter.setKsModelCommoditySampleSize(ksModelCommoditySampleSize);
  converter.setMinCommodityFlow(minCommodityFlow);
  converter.convertAndWrite(outputDirectory,shapeFileDirectory,ksModelOutputFilename,scenarioDescription,description,zones,startTime,endTime);
  printStatistics(cellsX,cellsY,cuttingBoundingBoxOffset,startTime,endTime);
  log.info("output ist written to " + outputDirectory);
  OutputDirectoryLogging.closeOutputDirLogging();
}

public static void convertMatsim2KS ( String signalSystemsFilename , String signalGroupsFilename , String signalControlFilename , String networkFilename , String lanesFilename , String populationFilename , double startTime , double endTime , double signalsBoundingBoxOffset , double cuttingBoundingBoxOffset , double freeSpeedFilter , boolean useFreeSpeedTravelTime , double maximalLinkLength , double matsimPopSampleSize , double ksModelCommoditySampleSize , double minCommodityFlow , boolean simplifyNetwork , int cellsX , int cellsY , String scenarioDescription , String dateFormat , String outputDirectory ) throws Exception { String spCost = "tt" ; if ( ! useFreeSpeedTravelTime ) spCost = "dist" ; outputDirectory += dateFormat + "_minflow_" + minCommodityFlow + "_time" + startTime + "-" + endTime + "_speedFilter" + freeSpeedFilter + "_SP_" + spCost + "_cBB" + cuttingBoundingBoxOffset + "_sBB" + signalsBoundingBoxOffset + "/" ; String ksModelOutputFilename = "ks2010_model_" + Double . toString ( minCommodityFlow ) + "_" + Double . toString ( startTime ) + "_" + Double . toString ( cuttingBoundingBoxOffset ) + ".xml" ; OutputDirectoryLogging . initLoggingWithOutputDirectory ( outputDirectory ) ; String shapeFileDirectory = createShapeFileDirectory ( outputDirectory ) ; Scenario fullScenario = DgScenarioUtils . loadScenario ( networkFilename , populationFilename , lanesFilename , signalSystemsFilename , signalGroupsFilename , signalControlFilename ) ; NetLanesSignalsShrinker scenarioShrinker = new NetLanesSignalsShrinker ( fullScenario , CRS ) ; scenarioShrinker . shrinkScenario ( outputDirectory , shapeFileDirectory , cuttingBoundingBoxOffset , freeSpeedFilter , useFreeSpeedTravelTime , maximalLinkLength , simplifyNetwork ) ; ZoneBuilder zoneBuilder = new ZoneBuilder ( CRS ) ; DgZones zones = zoneBuilder . createAndWriteZones ( scenarioShrinker . getShrinkedNetwork ( ) , scenarioShrinker . getCuttingBoundingBox ( ) , cellsX , cellsY , shapeFileDirectory ) ; PopulationToOd pop2od = new PopulationToOd ( ) ; pop2od . setMatsimPopSampleSize ( matsimPopSampleSize ) ; pop2od . setOriginalToSimplifiedLinkMapping ( scenarioShrinker . getOriginalToSimplifiedLinkIdMatching ( ) ) ; pop2od . convertPopulation2OdPairs ( zones , fullScenario . getNetwork ( ) , fullScenario . getPopulation ( ) , CRS , scenarioShrinker . getShrinkedNetwork ( ) , scenarioShrinker . getCuttingBoundingBox ( ) , startTime , endTime , shapeFileDirectory ) ; M2KS2010Converter converter = new M2KS2010Converter ( scenarioShrinker . getShrinkedNetwork ( ) , scenarioShrinker . getShrinkedLanes ( ) , scenarioShrinker . getShrinkedSignals ( ) , signalsBoundingBoxOffset , CRS ) ; String description = createDescription ( cellsX , cellsY , startTime , endTime , cuttingBoundingBoxOffset , matsimPopSampleSize , ksModelCommoditySampleSize , minCommodityFlow ) ; converter . setKsModelCommoditySampleSize ( ksModelCommoditySampleSize ) ; converter . setMinCommodityFlow ( minCommodityFlow ) ; converter . convertAndWrite ( outputDirectory , shapeFileDirectory , ksModelOutputFilename , scenarioDescription , description , zones , startTime , endTime ) ; printStatistics ( cellsX , cellsY , cuttingBoundingBoxOffset , startTime , endTime ) ; log . info ( "output ist written to " + outputDirectory ) ; OutputDirectoryLogging . closeOutputDirLogging ( ) ; }
runs the conversion process and writes the btu output file .
