Changeset 283 in tmcsimulator


Ignore:
Timestamp:
02/27/2019 11:14:48 AM (7 years ago)
Author:
jdalbey
Message:

BuildHighwaysFile?.java improved reading of loop file to be free format instead of insisting last field start in a specific column.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/tmcsim/utilities/BuildHighwayFile.java

    r276 r283  
    33import java.io.File; 
    44import java.io.FileNotFoundException; 
    5 import java.io.IOException; 
    65import java.io.PrintWriter; 
    76import java.util.ArrayList; 
     
    2221 *      Data Clearinghouse.  It gives identifying info about each VDS. 
    2322 *      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.  
    2524 *      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. 
    2827 * @author jdalbey, jtorres 
    2928 */ 
     
    3433    final public static String loopFileName = "cleaned_chu_atms_loop_data.txt"; 
    3534    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"; 
    3836    /** A dictionary of ldsIDs to VDSids */ 
    3937    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 */ 
    4139    Map<String,List<String>> feplines; 
    4240    /** A dictionary to lookup VDS data given vdsID */ 
     
    4543    Set<String> vdsUsed = new HashSet<String>(); 
    4644    int ignored = 0; // count of ignored VDS ids 
    47     /** Reported missing */ 
     45    /** IDs Reported missing during lookup */ 
    4846    Set<String> missingVDS = new HashSet<String>(); 
    4947    Set<String> missingLDS = new HashSet<String>(); 
    5048     
     49    /** Once all the input data has been read and the lookup dictionaries 
     50     * created we can build the highway file. 
     51     */ 
    5152    public void createHighwayFile() 
    5253    { 
     
    5556            PrintWriter hwyWriter = new PrintWriter(new File(filepath+highwayFile)); 
    5657            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())  
    5860            { 
    5961                hwyWriter.print(fep_line+" 0 "); 
     
    98100     
    99101    /** 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. 
    102103     */ 
    103104    public void createLanelookup() 
     
    108109        { 
    109110            Scanner loopScanner = new Scanner(new File(filepath+loopFileName)); 
    110             PrintWriter loopWriter = new PrintWriter(new File(filepath+reformattedLoopFile)); 
    111111             
    112112            loopScanner.nextLine();  // Skip the column headers 
     
    126126                String shortLoc = lineScanner.next(); 
    127127                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 
    129130                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'); 
    143131                 
    144132                lineScanner.close(); 
     
    154142                else 
    155143                { 
     144                    // If we're missing a VDS id record it 
     145                    // but we're only interested in two lane types. 
    156146                    boolean desiredType = shortLoc.equals("ML") || shortLoc.equals("OS"); 
    157147                    if (desiredType && !missingVDS.contains(vdsID)) 
     
    215205             
    216206            loopScanner.close(); 
    217             loopWriter.close(); 
    218207             
    219208        } catch (FileNotFoundException ex) 
     
    236225                Scanner lineScanner = new Scanner(line).useDelimiter("\t"); 
    237226                VehicleDetectionStation vds = new VehicleDetectionStation(lineScanner); 
    238                 // We only want stations that are mainline 
     227                // We only want stations that are mainline, ignore offramps, etc. 
    239228                if (vds.type.equals("ML")) 
    240229                { 
Note: See TracChangeset for help on using the changeset viewer.