Changeset 274 in tmcsimulator for trunk/src/atmsdriver/model/Highways.java
- Timestamp:
- 02/25/2019 04:36:04 PM (7 years ago)
- File:
-
- 1 edited
-
trunk/src/atmsdriver/model/Highways.java (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/atmsdriver/model/Highways.java
r266 r274 63 63 // load FEP Lines 64 64 lines = loadLines(highwaysMapFileName); 65 // configure and load highways66 this.highways = configureHighways();65 // build highways data structure 66 this.highways = buildHighways(); 67 67 68 68 // write to FEP host and port number … … 71 71 } 72 72 73 private ArrayList<Highway> configureHighways()74 { 75 System.out.println(" Loading highways...");73 private ArrayList<Highway> buildHighways() 74 { 75 System.out.println("Building highways..."); 76 76 // The list of highways to return 77 77 ArrayList<Highway> highways = new ArrayList<Highway>(); … … 89 89 { 90 90 Integer hwyNum = station.routeNumber; 91 92 91 // if the map does not contain an entry for the highway, create 93 92 // a new entry (key/value pair) for the highway and instantiate … … 116 115 ArrayList<Station> hwyStations = highwayMap.get(hwyKey); 117 116 Collections.sort(hwyStations); 118 System.out.println("Loaded highway " + hwyKey + "..."); 117 System.out.println("Loaded highway " + hwyKey + " with " + 118 hwyStations.size() + " stations."); 119 119 highways.add(new Highway(hwyKey, 120 120 hwyStations)); … … 159 159 startPost = postmile; 160 160 endPost = postmile + range; 161 161 //TODO: Catch NPE exception for situation when the events file 162 // specifies a highway that doesn't exist in the network. 163 // Also the case where a desired postmile to color isn't in 164 // the network. 162 165 // iterate through the stations, if within the specified highway 163 166 // stretch, update the station by direction and apply dot color … … 222 225 223 226 /** 224 * Load sa single FEP Line from the highways map file.227 * Load all the stations for a single FEP Line from the highways map file. 225 228 * 226 229 * @param sc scanner at the current FEPLine line … … 348 351 // Print the number of bytes the highways data message contains 349 352 System.out.println("Highways sending " + this.toCondensedFormat(false).toCharArray().length + 1 + "bytes to FEPSIM."); 350 353 String outMsg = this.toCondensedFormat(false); 351 354 // Write the highways data over the socket 352 out.println( this.toCondensedFormat(false));355 out.println(outMsg); 353 356 354 357 // close the socket … … 371 374 * and does include the string location names. If MetaDataOnly is false, 372 375 * dynamic loop values are included, and unnecessary information like string 373 * location values are included.376 * location values are not included. 374 377 * 375 378 * The FEPSimulator takes in the toCondensedFormat() output, with a MetaDataOnly … … 526 529 public String toJson() 527 530 { 531 // TODO: move loading this file to init method so it doesn't get 532 // called every time. 528 533 PostmileCoords pmList = new PostmileCoords(); 529 534 FileInputStream fis = null; … … 545 550 for (Highway hwy: highways) 546 551 { 547 // For json output we don't care about listing all the stations548 // in order by direction because we are just outputting points not lines.552 // Consider each route direction 553 for (DIRECTION dir: DIRECTION.values()) 549 554 { 550 555 // Examine every station on this highway and direction
Note: See TracChangeset
for help on using the changeset viewer.
