Index: trunk/src/tmcsim/utilities/BuildHighwayFile.java
===================================================================
--- trunk/src/tmcsim/utilities/BuildHighwayFile.java	(revision 276)
+++ trunk/src/tmcsim/utilities/BuildHighwayFile.java	(revision 283)
@@ -3,5 +3,4 @@
 import java.io.File;
 import java.io.FileNotFoundException;
-import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.ArrayList;
@@ -22,8 +21,8 @@
  *      Data Clearinghouse.  It gives identifying info about each VDS.
  *      2. Loop detector (lane) file that we found on the ATMS server.
- *      It lists all the lanes associated with each VDS.       
+ *      It lists all the lanes associated with each VDS. 
  *      3. LDS file that has the fep line number for each LDS.
- * Output: 1. The highway map file that lists VDS info and the lanes it governs.
- *      2. A slightly reformatted loop file.  (Not sure what this is for.)
+ * Output: 1. The highway map file that lists VDS info and the lanes it governs,
+ *      in a format similar to what FEP simulator uses.
  * @author jdalbey, jtorres
  */
@@ -34,9 +33,8 @@
     final public static String loopFileName = "cleaned_chu_atms_loop_data.txt";
     final public static String ldsFileName = "cleaned_chu_atms_lds_data.txt";
-    final public static String reformattedLoopFile = "loop.txt";
-    final public static String highwayFile = "highway_stations.txt";
+    final public static String highwayFile = "highways_fullmap.txt";
     /** A dictionary of ldsIDs to VDSids */
     Map<String,StationAddr> ldsDict;
-    /** A dictionary of FEP line numbers to a list of VDSids */
+    /** A dictionary of all VDSids linked to a given FEP line number */
     Map<String,List<String>> feplines;
     /** A dictionary to lookup VDS data given vdsID */
@@ -45,8 +43,11 @@
     Set<String> vdsUsed = new HashSet<String>();
     int ignored = 0; // count of ignored VDS ids
-    /** Reported missing */
+    /** IDs Reported missing during lookup */
     Set<String> missingVDS = new HashSet<String>();
     Set<String> missingLDS = new HashSet<String>();
     
+    /** Once all the input data has been read and the lookup dictionaries
+     * created we can build the highway file.
+     */
     public void createHighwayFile()
     {
@@ -55,5 +56,6 @@
             PrintWriter hwyWriter = new PrintWriter(new File(filepath+highwayFile));
             hwyWriter.print(feplines.size()+"\n");
-            for (String fep_line: feplines.keySet()) // for each fep line
+            // for each fep line
+            for (String fep_line: feplines.keySet()) 
             {
                 hwyWriter.print(fep_line+" 0 ");
@@ -98,6 +100,5 @@
     
     /** Read the loop file to create a dictionary to lookup all the lanes
-     * for a given VDS.  As a byproduct we will write the reformatted Loop file.
-     * (Not sure if this is needed. Ask jtorres.)
+     * for a given VDS.
      */
     public void createLanelookup()
@@ -108,5 +109,4 @@
         {
             Scanner loopScanner = new Scanner(new File(filepath+loopFileName));
-            PrintWriter loopWriter = new PrintWriter(new File(filepath+reformattedLoopFile));
             
             loopScanner.nextLine();  // Skip the column headers
@@ -126,19 +126,7 @@
                 String shortLoc = lineScanner.next();
                 Integer laneNum = lineScanner.nextInt();
-                String loop_name = line.substring(73).trim(); // grab rest of line
+                String loop_name = lineScanner.nextLine().trim();
+//              String loop_name = line.substring(73).trim(); // grab rest of line
                 loop_name = loop_name.replace(" ", "_");
-                
-                loopWriter.print(fwy + "\t");
-                loopWriter.print(dir+ "\t");
-                loopWriter.print(postmile + "\t");
-                loopWriter.print(ldsID + "\t");
-                loopWriter.print(vdsID + "\t");
-                loopWriter.print(loopID + "\t");
-                loopWriter.print(shortLoc + "\t");
-                loopWriter.print(laneNum + "\t");
-                loopWriter.print(loop_name + "\t");
-                loopWriter.print("?" + "\t");
-                loopWriter.print("0" + "\t");
-                loopWriter.print('\n');
                 
                 lineScanner.close();
@@ -154,4 +142,6 @@
                 else
                 {
+                    // If we're missing a VDS id record it
+                    // but we're only interested in two lane types.
                     boolean desiredType = shortLoc.equals("ML") || shortLoc.equals("OS");
                     if (desiredType && !missingVDS.contains(vdsID))
@@ -215,5 +205,4 @@
             
             loopScanner.close();
-            loopWriter.close();
             
         } catch (FileNotFoundException ex)
@@ -236,5 +225,5 @@
                 Scanner lineScanner = new Scanner(line).useDelimiter("\t");
                 VehicleDetectionStation vds = new VehicleDetectionStation(lineScanner);
-                // We only want stations that are mainline
+                // We only want stations that are mainline, ignore offramps, etc.
                 if (vds.type.equals("ML"))
                 {
