Codota Logo
NetworkWriter
Code IndexAdd Codota to your IDE (free)

How to use
NetworkWriter
in
org.matsim.core.network.io

Best Java code snippets using org.matsim.core.network.io.NetworkWriter (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Dictionary d =
  • Codota Iconnew Hashtable()
  • Codota IconBundle bundle;bundle.getHeaders()
  • Codota Iconnew Properties()
  • Smart code suggestions by Codota
}
origin: matsim-org/matsim

private void dumpNetwork() {
  // dump network
  new NetworkWriter(network).write(controlerIO.getOutputFilename(Controler.OUTPUT_PREFIX + Controler.FILENAME_NETWORK));
}
origin: matsim-org/matsim

/**
 * Writes the network in the format of network_v1.dtd
 * 
 * @param filename
 */
public void writeV1(final String filename) {
  new org.matsim.core.network.io.NetworkWriter(network).writeFileV1(filename);
}
origin: matsim-org/matsim

public void writeV2(final String filename) {
  final org.matsim.core.network.io.NetworkWriter writer =
      new org.matsim.core.network.io.NetworkWriter(network);
  writer.putAttributeConverters( converters );
  writer.writeFileV2(filename);
}
origin: matsim-org/matsim

@Override
protected void writeNetwork(final Network network, final String filename) {
  new NetworkWriter(network).writeFileV2(filename);
}

origin: matsim-org/matsim

openFile(filename);
writeXmlHead();
writeDoctype("network", dtd);
origin: matsim-org/matsim

@Override
public void write(final String filename) {
  log.info("Writing network to file: " + filename  + "...");
  // always write out in newest version, currently v2
  writeFileV2(filename);
  log.info("done.");
}
origin: matsim-org/matsim

public void writeFileV1(final String filename) {
  String dtd = "http://www.matsim.org/files/dtd/network_v1.dtd";
  NetworkWriterHandler handler = new NetworkWriterHandlerImplV1(transformation);
  writeFile( dtd , handler , filename );
}
origin: matsim-org/matsim

public void writeFileV2(final String filename) {
  String dtd = "http://www.matsim.org/files/dtd/network_v2.dtd";
  NetworkWriterHandlerImplV2 handler = new NetworkWriterHandlerImplV2(transformation);
  handler.putAttributeConverters( converters );
  writeFile( dtd , handler , filename );
}
origin: matsim-org/matsim

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);
}

origin: matsim-org/matsim

@Override
protected void writeNetwork(final Network network, final String filename) {
  new NetworkWriter(network).writeFileV1(filename);
}

origin: matsim-org/matsim

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.");
}
origin: matsim-org/matsim

  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 );

  }
  
origin: matsim-org/matsim

new NetworkWriter(network).write(outputDir+"/output_network.xml.gz");
System.out.println("done.");
origin: matsim-org/matsim

/** 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);
}

origin: matsim-org/matsim

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);
}
origin: matsim-org/matsim

@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());
}
origin: matsim-org/matsim

@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() );
  }
}
origin: matsim-org/matsim

@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() );
  }
}
origin: matsim-org/matsim

@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");
}
origin: matsim-org/matsim

@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");
}
org.matsim.core.network.ioNetworkWriter

Most used methods

  • <init>
  • write
  • writeFileV1
  • writeFileV2
  • openFile
  • putAttributeConverters
  • writeDoctype
  • writeFile
  • writeXmlHead

Popular in Java

  • Making http requests using okhttp
  • setContentView (Activity)
  • getContentResolver (Context)
  • getSystemService (Context)
  • GridBagLayout (java.awt)
    The GridBagLayout class is a flexible layout manager that aligns components vertically and horizonta
  • BufferedReader (java.io)
    Reads text from a character-input stream, buffering characters so as to provide for the efficient re
  • SimpleDateFormat (java.text)
    Formats and parses dates in a locale-sensitive manner. Formatting turns a Date into a String, and pa
  • ArrayList (java.util)
    Resizable-array implementation of the List interface. Implements all optional list operations, and p
  • JList (javax.swing)
  • Logger (org.apache.log4j)
    This is the central class in the log4j package. Most logging operations, except configuration, are d
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now