public void writeNetwork(String outputRoot, String networkFileName) { try { OutputDirectoryLogging.initLoggingWithOutputDirectory(outputRoot); } catch (IOException e) { e.printStackTrace(); } NetworkWriter networkWriter = new NetworkWriter(network); networkWriter.write(networkFileName); LOG.info("Network file written to " + networkFileName); }
private void dumpNetwork() { // dump network new NetworkWriter(network).write(controlerIO.getOutputFilename(Controler.OUTPUT_PREFIX + Controler.FILENAME_NETWORK)); }
public static final void writeNetwork(Network network, String filename) { System.out.println(" writing network xml file... "); NetworkWriter network_writer = new NetworkWriter(network); network_writer.write(filename); System.out.println(" done."); }
new NetworkWriter(network).write(outputDir+"/output_network.xml.gz"); System.out.println("done.");
public static void main(String[] args) { final String inNetworkFile = args[ 0 ]; final String outNetworkFile = args[ 1 ]; Set<Integer> nodeTypesToMerge = new TreeSet<>(); nodeTypesToMerge.add(4); nodeTypesToMerge.add(5); Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); final Network network = scenario.getNetwork(); new MatsimNetworkReader(scenario.getNetwork()).readFile( inNetworkFile ); NetworkSimplifier nsimply = new NetworkSimplifier(); nsimply.setNodesToMerge(nodeTypesToMerge); // nsimply.setMergeLinkStats(true); nsimply.run(network, Double.NEGATIVE_INFINITY); new NetworkWriter(network).write( outNetworkFile ); }
public static void run(String[] args) { String input = args[0]; String output = args[1]; Network network = NetworkUtils.createNetwork(); new MatsimNetworkReader(network).readFile(input); IntersectionSimplifier ns = new IntersectionSimplifier(30.0, 2); Network newNetwork = ns.simplify(network); NetworkCalcTopoType nct = new NetworkCalcTopoType(); nct.run(newNetwork); LOG.info("Simplifying the network..."); new NetworkSimplifier().run(newNetwork); LOG.info("Cleaning the network..."); new NetworkCleaner().run(newNetwork); IntersectionSimplifier.reportNetworkStatistics(newNetwork); new NetworkWriter(newNetwork).write(output); }
/** Runs the network cleaning algorithms over the network read in from <code>inputNetworkFile</code> * and writes the resulting ("cleaned") network to the specified file. * * @param inputNetworkFile filename of the network to be handled * @param outputNetworkFile filename where to write the cleaned network to */ public void run(final String inputNetworkFile, final String outputNetworkFile) { final Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); final Network network = scenario.getNetwork(); new MatsimNetworkReader(scenario.getNetwork()).readFile(inputNetworkFile); new org.matsim.core.network.algorithms.NetworkCleaner().run(network); new NetworkWriter(network).write(outputNetworkFile); }
@Test public void testComplexIntersection() { Network network = null; try { network = buildComplexIntersection(); new NetworkWriter(network).write(utils.getOutputDirectory() + "network.xml.gz"); } catch (Exception e) { Assert.fail("Should build and write without exception."); } Assert.assertEquals("Wrong number of nodes", 28, network.getNodes().size()); Assert.assertEquals("Wrong number of links", 50, network.getLinks().size()); }
@Test public void testInput() { final String networkFile = utils.getOutputDirectory()+"/network.xml"; final Network initialNetwork = createInitialNetwork(); new NetworkWriter( initialNetwork ).write( networkFile ); final Network readNetwork = NetworkUtils.createNetwork(); new MatsimNetworkReader( INITIAL_CRS, TARGET_CRS, readNetwork ).readFile( networkFile ); Assert.assertEquals( "unexpected network size", 2, readNetwork.getNodes().size() ); for ( Node n : readNetwork.getNodes().values() ) { Node initialNode = initialNetwork.getNodes().get(n.getId()); Assert.assertEquals( "Unexpected coordinate", transformation.transform(initialNode.getCoord()), n.getCoord() ); } }
@Test public void testOutput() { final String networkFile = utils.getOutputDirectory()+"/network.xml"; final Network initialNetwork = createInitialNetwork(); new NetworkWriter( transformation, initialNetwork ).write( networkFile ); final Network readNetwork = NetworkUtils.createNetwork(); new MatsimNetworkReader( readNetwork ).readFile( networkFile ); Assert.assertEquals( "unexpected network size", 2, readNetwork.getNodes().size() ); for ( Node n : readNetwork.getNodes().values() ) { Node initialNode = initialNetwork.getNodes().get(n.getId()); Assert.assertEquals( "Unexpected coordinate", transformation.transform(initialNode.getCoord()), n.getCoord() ); } }
@Test public void testSimplifyOne() { Network network = buildComplexIntersection(); IntersectionSimplifier is = new IntersectionSimplifier(10.0, 2); Network simpleNetwork = is.simplify(network); is.writeClustersToFile(utils.getOutputDirectory() + "clusters.csv"); List<Cluster> clusters = is.getClusters(); Assert.assertEquals("Wrong number of clusters", 6l, clusters.size()); /* Check some clusters. */ Cluster c1 = findCluster(clusters, CoordUtils.createCoord(85.0, 85.0)); Assert.assertNotNull("Could not find a cluster with centroid (85.0,85.0)", c1); Assert.assertEquals("Wrong number of points", 4, c1.getPoints().size()); Cluster c2 = findCluster(clusters, CoordUtils.createCoord(225.0, 85.0)); Assert.assertNotNull("Could not find cluster with centroid (225.0,85.0)", c2); Assert.assertEquals("Wrong number of points", 4, c2.getPoints().size()); /* Write the cleaned network to file. */ new NetworkWriter(simpleNetwork).write(utils.getOutputDirectory() + "cleanNetwork.xml"); }
@Test public void testSimplifyTwo() { Network network = buildComplexIntersection(); IntersectionSimplifier is = new IntersectionSimplifier(30.0, 4); Network simpleNetwork = is.simplify(network); is.writeClustersToFile(utils.getOutputDirectory() + "clusters.csv"); List<Cluster> clusters = is.getClusters(); Assert.assertEquals("Wrong number of clusters", 2l, clusters.size()); /* Check some clusters. */ Cluster c1 = findCluster(clusters, CoordUtils.createCoord(85.0, 85.0)); Assert.assertNotNull("Could not find cluster with centroid (85.0,85.0)", c1); Assert.assertEquals("Wrong number of points", 4, c1.getPoints().size()); Cluster c2 = findCluster(clusters, CoordUtils.createCoord(225.0, 85.0)); Assert.assertNotNull("Could not find cluster with centroid (225.0,85.0)", c2); Assert.assertEquals("Wrong number of points", 12, c2.getPoints().size()); /* Write the cleaned network to file. */ new NetworkWriter(simpleNetwork).write(utils.getOutputDirectory() + "cleanNetwork.xml"); }
ns.run(simpleNetwork); new NetworkCleaner().run(simpleNetwork); new NetworkWriter(simpleNetwork).write(utils.getOutputDirectory() + "network.xml");
new NetworkWriter(originalScenario.getNetwork()).write(utils.getOutputDirectory()+NET_FILE);
ProjectionUtils.putCRS(initialNetwork, INITIAL_CRS); new NetworkWriter( initialNetwork ).write( networkFile );
new NetworkWriter( initialNetwork ).write( networkFile );