20 package tutorial.converter.networkFromEmme;
22 import org.apache.log4j.Logger;
36 import java.io.BufferedReader;
37 import java.io.FileNotFoundException;
38 import java.io.IOException;
62 private static final int PSRC = 0 ;
63 private static final int EUGENE = 1 ;
70 ((
Network) network).setEffectiveLaneWidth(3.75) ;
76 BufferedReader reader =
IOUtils.
getBufferedReader(
"/Users/nagel/eclipse/shared-svn/studies/countries/us/psrc/network/emme-export/net1.out" ) ;
78 boolean weAreReadingNodes = true ;
82 while ( (line = reader.readLine()) != null ) {
83 String[] parts = line.split(
"[ \t\n]+");
85 if ( parts[0].equals(
"c") ) {
87 }
else if ( parts[0].equals(
"t") ) {
88 if ( parts[1].equals(
"links") ) {
89 weAreReadingNodes = false ;
91 }
else if ( parts[0].equals(
"a") ) {
92 if ( weAreReadingNodes ) {
93 String idStr = parts[1] ;
94 String xxStr = parts[2] ;
95 String yyStr = parts[3] ;
97 new Coord(Double.parseDouble(xxStr), Double.parseDouble(yyStr)));
102 if ( fromNode==null || toNode==null ) {
106 if ( parts[4].equals(
"r") || parts[4].equals(
"b") ) {
107 log.info(
"rail only or bus only link; skipping it ...") ;
110 double length = 1600 * Double.parseDouble( parts[3] ) ;
113 double permlanes = Double.parseDouble( parts[6] ) ;
114 if ( permlanes <= 0 ) { permlanes = 0.5 ; }
116 double capacity, freespeed ;
117 if ( NW_NAME==PSRC ) {
118 capacity = permlanes * Double.parseDouble( parts[8] ) ;
119 if ( capacity <= 500 ) { capacity = 500. ; }
121 freespeed = Double.parseDouble( parts[9] ) ;
122 if ( freespeed < 10. ) { freespeed = 10. ; }
123 freespeed *= 1600./3600. ;
124 }
else if ( NW_NAME==EUGENE ) {
125 log.warn(
"For EUGENE, I have not clarified if capacity really needs to be multiplied by number of lanes.");
126 capacity = permlanes * Double.parseDouble( parts[10] ) ;
127 if ( capacity <= 500 ) { capacity = 500. ; }
129 freespeed = Double.parseDouble( parts[9] ) ;
130 if ( freespeed < 10. ) { freespeed = 10. ; }
131 freespeed *= 1600./3600. ;
133 log.error(
"NW_NAME not known; aborting" ) ;
137 Id<Link>
id = Id.create(linkCnt,
Link.class);
152 }
catch (FileNotFoundException e) {
154 }
catch (IOException e) {
164 public static void main(String[] args) {
173 log.info(
"reading network ...");
175 log.info(
"... finished reading network.\n");
177 log.info(
"cleaning network ...");
179 nwCleaner.
run( network ) ;
180 log.info(
"... finished cleaning network.\n") ;
182 log.info(
"writing network ...") ;
184 log.info(
"... finished writing network.\n") ;
static void readNetwork(Scenario sc)
void setNumberOfLanes(double lanes)
Map< Id< Node >,?extends Node > getNodes()
void setFreespeed(double freespeed)
void run(final Network network)
NetworkFactory getFactory()
static BufferedReader getBufferedReader(final String filename)
static void main(String[] args)
Link createLink(final Id< Link > id, final Node fromNode, final Node toNode)
void setLength(double length)
static Config createConfig(final String filename)
void setCapacityPeriod(double capPeriod)
Node createNode(final Id< Node > id, final Coord coord)
void write(final String filename)
static Scenario createScenario(final Config config)
void setCapacity(double capacity)