public static void main(final String[] args) { Gbl.startMeasurement(); final String netFilename = "../schweiz-ivtch-SVN/baseCase/network/ivtch-osm.xml"; final String plansFilename = "../runs-svn/run684/it.1000/1000.plans.xml.gz"; String outputFilename = "../matsimTests/run684/DailyEnRouteTime/"; String tollFilename = "../matsimTests/toll/KantonZurichToll.xml"; ScenarioImpl scenario = (ScenarioImpl) ScenarioUtils.createScenario(ConfigUtils.createConfig()); new MatsimNetworkReader(scenario).readFile(netFilename); Population population = scenario.getPopulation(); // ConfigUtils.addOrGetModule(scenario.getConfig(), RoadPricingConfigGroup.GROUP_NAME, // RoadPricingConfigGroup.class).setUseRoadpricing(true); RoadPricingReaderXMLv1 tollReader = new RoadPricingReaderXMLv1( (RoadPricingSchemeImpl) scenario.getScenarioElement(RoadPricingScheme.ELEMENT_NAME)); tollReader.parse(tollFilename); DailyEnRouteTime ert = new DailyEnRouteTime( (RoadPricingScheme) scenario.getScenarioElement(RoadPricingScheme.ELEMENT_NAME)); System.out.println("-->reading plansfile: " + plansFilename); new MatsimPopulationReader(scenario).readFile(plansFilename); ert.run(population); ert.write(outputFilename); System.out.println("--> Done!"); Gbl.printElapsedTime(); System.exit(0); }
private List<Id<Link>> readLinkIdsFromRoadPricingScheme(String roadpricingFilename) { log.info("Reading tolled links from " + roadpricingFilename); RoadPricingReaderXMLv1 rpr = new RoadPricingReaderXMLv1(scheme); rpr.parse(roadpricingFilename); List<Id<Link>> list = new ArrayList<>(); for (Id<Link> i : this.scheme.getTolledLinkIds()) { list.add(i); } log.info("Read " + list.size() + " tolled link Ids"); return list; }
private static Network filterNetwork(Network network) { CoordinateTransformation transform = TransformationFactory.getCoordinateTransformation( TransformationFactory.CH1903_LV03_GT, TransformationFactory.DHDN_GK4); // CoordinateTransformation transform = // TransformationFactory.getCoordinateTransformation(TransformationFactory.CH1903_LV03_GT, // "WGS84_UTM32T"); Network net = NetworkUtils.createNetwork(); RoadPricingSchemeImpl rps = new RoadPricingSchemeImpl(); RoadPricingReaderXMLv1 rpr = new RoadPricingReaderXMLv1(rps); rpr.parse(linksToFilter); Set<Id<Link>> linkList = rps.getTolledLinkIds(); for (Link link : network.getLinks().values()) { Id linkId = link.getId(); if (linkList.contains(linkId)) { Id fromId = link.getFromNode().getId(); Id toId = link.getToNode().getId(); Coord fromNodeCoord = link.getFromNode().getCoord(); Coord toNodeCoord = link.getToNode().getCoord(); Coord fromNodeTransformed = transform.transform(fromNodeCoord); Coord toNodeTransformed = transform.transform(toNodeCoord); // Node newFromNode = net.getFactory().createNode(fromId, fromNodeCoord); // Node newToNode = net.getFactory().createNode(toId, toNodeCoord); Node newFromNode = net.getFactory().createNode(fromId, fromNodeTransformed); Node newToNode = net.getFactory().createNode(toId, toNodeTransformed); if (!net.getNodes().containsKey(fromId)) { net.addNode(newFromNode); } if (!net.getNodes().containsKey(toId)) { net.addNode(newToNode); } Link ll = net.getFactory().createLink(link.getId(), newFromNode, newToNode); net.addLink(ll); } } return net; }