Changeset 283 in tmcsimulator for trunk/src/tmcsim
- Timestamp:
- 02/27/2019 11:14:48 AM (7 years ago)
- File:
-
- 1 edited
-
trunk/src/tmcsim/utilities/BuildHighwayFile.java (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/tmcsim/utilities/BuildHighwayFile.java
r276 r283 3 3 import java.io.File; 4 4 import java.io.FileNotFoundException; 5 import java.io.IOException;6 5 import java.io.PrintWriter; 7 6 import java.util.ArrayList; … … 22 21 * Data Clearinghouse. It gives identifying info about each VDS. 23 22 * 2. Loop detector (lane) file that we found on the ATMS server. 24 * It lists all the lanes associated with each VDS. 23 * It lists all the lanes associated with each VDS. 25 24 * 3. LDS file that has the fep line number for each LDS. 26 * Output: 1. The highway map file that lists VDS info and the lanes it governs .27 * 2. A slightly reformatted loop file. (Not sure what this is for.)25 * Output: 1. The highway map file that lists VDS info and the lanes it governs, 26 * in a format similar to what FEP simulator uses. 28 27 * @author jdalbey, jtorres 29 28 */ … … 34 33 final public static String loopFileName = "cleaned_chu_atms_loop_data.txt"; 35 34 final public static String ldsFileName = "cleaned_chu_atms_lds_data.txt"; 36 final public static String reformattedLoopFile = "loop.txt"; 37 final public static String highwayFile = "highway_stations.txt"; 35 final public static String highwayFile = "highways_fullmap.txt"; 38 36 /** A dictionary of ldsIDs to VDSids */ 39 37 Map<String,StationAddr> ldsDict; 40 /** A dictionary of FEP line numbers to a list of VDSids*/38 /** A dictionary of all VDSids linked to a given FEP line number */ 41 39 Map<String,List<String>> feplines; 42 40 /** A dictionary to lookup VDS data given vdsID */ … … 45 43 Set<String> vdsUsed = new HashSet<String>(); 46 44 int ignored = 0; // count of ignored VDS ids 47 /** Reported missing*/45 /** IDs Reported missing during lookup */ 48 46 Set<String> missingVDS = new HashSet<String>(); 49 47 Set<String> missingLDS = new HashSet<String>(); 50 48 49 /** Once all the input data has been read and the lookup dictionaries 50 * created we can build the highway file. 51 */ 51 52 public void createHighwayFile() 52 53 { … … 55 56 PrintWriter hwyWriter = new PrintWriter(new File(filepath+highwayFile)); 56 57 hwyWriter.print(feplines.size()+"\n"); 57 for (String fep_line: feplines.keySet()) // for each fep line 58 // for each fep line 59 for (String fep_line: feplines.keySet()) 58 60 { 59 61 hwyWriter.print(fep_line+" 0 "); … … 98 100 99 101 /** Read the loop file to create a dictionary to lookup all the lanes 100 * for a given VDS. As a byproduct we will write the reformatted Loop file. 101 * (Not sure if this is needed. Ask jtorres.) 102 * for a given VDS. 102 103 */ 103 104 public void createLanelookup() … … 108 109 { 109 110 Scanner loopScanner = new Scanner(new File(filepath+loopFileName)); 110 PrintWriter loopWriter = new PrintWriter(new File(filepath+reformattedLoopFile));111 111 112 112 loopScanner.nextLine(); // Skip the column headers … … 126 126 String shortLoc = lineScanner.next(); 127 127 Integer laneNum = lineScanner.nextInt(); 128 String loop_name = line.substring(73).trim(); // grab rest of line 128 String loop_name = lineScanner.nextLine().trim(); 129 // String loop_name = line.substring(73).trim(); // grab rest of line 129 130 loop_name = loop_name.replace(" ", "_"); 130 131 loopWriter.print(fwy + "\t");132 loopWriter.print(dir+ "\t");133 loopWriter.print(postmile + "\t");134 loopWriter.print(ldsID + "\t");135 loopWriter.print(vdsID + "\t");136 loopWriter.print(loopID + "\t");137 loopWriter.print(shortLoc + "\t");138 loopWriter.print(laneNum + "\t");139 loopWriter.print(loop_name + "\t");140 loopWriter.print("?" + "\t");141 loopWriter.print("0" + "\t");142 loopWriter.print('\n');143 131 144 132 lineScanner.close(); … … 154 142 else 155 143 { 144 // If we're missing a VDS id record it 145 // but we're only interested in two lane types. 156 146 boolean desiredType = shortLoc.equals("ML") || shortLoc.equals("OS"); 157 147 if (desiredType && !missingVDS.contains(vdsID)) … … 215 205 216 206 loopScanner.close(); 217 loopWriter.close();218 207 219 208 } catch (FileNotFoundException ex) … … 236 225 Scanner lineScanner = new Scanner(line).useDelimiter("\t"); 237 226 VehicleDetectionStation vds = new VehicleDetectionStation(lineScanner); 238 // We only want stations that are mainline 227 // We only want stations that are mainline, ignore offramps, etc. 239 228 if (vds.type.equals("ML")) 240 229 {
Note: See TracChangeset
for help on using the changeset viewer.
