MATSIM
Classes | Public Member Functions | Private Attributes | List of all members
org.matsim.visum.VisumMatrixReader Class Reference

Classes

class  DenseMatrixReader
 
class  SparseMatrixReader
 

Public Member Functions

 VisumMatrixReader (final Matrix matrix)
 
Matrix readFile (final String filename)
 

Private Attributes

Matrix matrix = null
 

Detailed Description

Author
mrieser

Definition at line 34 of file VisumMatrixReader.java.

Constructor & Destructor Documentation

◆ VisumMatrixReader()

org.matsim.visum.VisumMatrixReader.VisumMatrixReader ( final Matrix  matrix)

Definition at line 40 of file VisumMatrixReader.java.

References org.matsim.visum.VisumMatrixReader.matrix.

40  {
41  this.matrix = matrix;
42  }

Member Function Documentation

◆ readFile()

Matrix org.matsim.visum.VisumMatrixReader.readFile ( final String  filename)

Definition at line 44 of file VisumMatrixReader.java.

References org.matsim.core.utils.io.IOUtils.getBufferedReader(), org.matsim.visum.VisumMatrixReader.DenseMatrixReader.read(), and org.matsim.matrices.Matrix.setDesc().

44  {
45  BufferedReader infile = null;
46  try {
47  infile = IOUtils.getBufferedReader(filename);
48 
49  this.matrix.setDesc(filename);
50 
51  infile.mark(1024);
52  String header = infile.readLine();
53  infile.reset();
54 
55  if (header != null) {
56  if (header.equals("$VN;Y5")) {
57  new DenseMatrixReader(this.matrix).read(infile);
58  } else if (header.startsWith("$O")) {
59  new SparseMatrixReader(this.matrix).read(infile);
60  } else {
61  throw new RuntimeException("Visum file format '" + header +"' is not supported.");
62  }
63  } else {
64  throw new RuntimeException("header is missing");
65  }
66 
67  } catch (IOException e) {
68  e.printStackTrace();
69  return null;
70  } finally {
71  if (infile != null) {
72  try { infile.close(); }
73  catch (IOException e) { log.warn("Could not close input-stream.", e); }
74  }
75  }
76 
77  return matrix;
78  }
final void setDesc(final String desc)
Definition: Matrix.java:108
Here is the call graph for this function:

Member Data Documentation

◆ matrix

Matrix org.matsim.visum.VisumMatrixReader.matrix = null
private

The documentation for this class was generated from the following file: