Index: /trunk/src/tmcsim/application.properties
===================================================================
--- /trunk/src/tmcsim/application.properties	(revision 246)
+++ /trunk/src/tmcsim/application.properties	(revision 248)
@@ -1,5 +1,5 @@
-#Thu, 07 Feb 2019 15:47:33 -0800
+#Sat, 09 Feb 2019 09:41:52 -0800
 
-Application.revision=242
+Application.revision=247
 
 Application.buildnumber=91
Index: /trunk/src/tmcsim/cadsimulator/managers/TrafficModelManager.java
===================================================================
--- /trunk/src/tmcsim/cadsimulator/managers/TrafficModelManager.java	(revision 228)
+++ /trunk/src/tmcsim/cadsimulator/managers/TrafficModelManager.java	(revision 248)
@@ -1,4 +1,5 @@
 package tmcsim.cadsimulator.managers;
 
+import atmsdriver.GoogleMapAnimator;
 import atmsdriver.model.Highways;
 import atmsdriver.model.LoopDetector;
@@ -8,4 +9,5 @@
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
+import java.io.PrintWriter;
 import java.rmi.RemoteException;
 import java.text.ParseException;
@@ -208,4 +210,7 @@
             wtConsole.start();
         }
+        // Always write to json for google map display
+        Thread wtJson = new WriteToJsonThread();
+        wtJson.start();
     }
     /** Accessor to event queue
@@ -403,11 +408,63 @@
             while (true)
             {
-                 // Write the highway network status to the FEP Simulator
+                 // Write the highway network status to the Console
                  System.out.println(highways.toString());
-
-                // Wait for FEP Sim to process the data we just sent
+                // Output the highway model 
+                String geojson = highways.toJson();
+                //System.out.println(geojson); // diagnostic
+                PrintWriter out;
+                try
+                {
+                    out = new PrintWriter("highways.json");
+                    out.print(geojson);
+                    out.close();
+                }
+                catch (FileNotFoundException ex)
+                {
+                    Logger.getLogger(GoogleMapAnimator.class.getName()).log(Level.SEVERE, null, ex);
+                }
+                // Wait for Google Map to process the data we just sent
                 try
                 {
                     Thread.sleep(5000);
+                }
+                catch (InterruptedException ie)
+                {
+                    ie.printStackTrace();
+                }
+            }
+
+        }
+    }
+    /** Writes the highway model to a GeoJson file for reading
+     *  by Google Maps.
+     */
+    class WriteToJsonThread extends Thread
+    {
+
+        public void run()
+        {
+            System.out.println("WriteToJson Thread starting.");
+            // Run indefinitely
+            while (true)
+            {
+                 // Write the highway network status to Json
+                String geojson = highways.toJson();
+                PrintWriter out;
+                try
+                {
+                    // currently writes to local file
+                    out = new PrintWriter("highways.json");
+                    out.print(geojson);
+                    out.close();
+                }
+                catch (FileNotFoundException ex)
+                {
+                    Logger.getLogger(GoogleMapAnimator.class.getName()).log(Level.SEVERE, null, ex);
+                }
+                // Wait for Google Map to process the data we just sent
+                try
+                {
+                    Thread.sleep(30000);
                 }
                 catch (InterruptedException ie)
Index: /trunk/src/atmsdriver/ATMSDriver.java
===================================================================
--- /trunk/src/atmsdriver/ATMSDriver.java	(revision 190)
+++ /trunk/src/atmsdriver/ATMSDriver.java	(revision 248)
@@ -8,5 +8,5 @@
 import tmcsim.common.SimulationException;
 
-/**
+/** "Super Old"
  * ATMS Driver reads the current simulation traffic conditions from the
  * EXCHANGE.XML file and constructs the Highway Network status info in the
Index: /trunk/src/atmsdriver/model/Highways.java
===================================================================
--- /trunk/src/atmsdriver/model/Highways.java	(revision 243)
+++ /trunk/src/atmsdriver/model/Highways.java	(revision 248)
@@ -545,19 +545,14 @@
         for (Highway hwy: highways)
         {
-            // Consider each route direction
-            //for (DIRECTION dir: DIRECTION.values())
-            // TODO: Needs fixing so proper direction is displayed
-            Station.DIRECTION dir = Station.DIRECTION.SOUTH;
-            if (hwy.routeNumber == 55)
-                dir = Station.DIRECTION.SOUTH;
-            if (hwy.routeNumber == 405)
-                dir = Station.DIRECTION.NORTH;
-            {
-                String rowLabel = ""+String.format("%3s ",hwy.routeNumber)+dir.getLetter()+' ';
+            // For json output we don't care about listing all the stations
+            // in order by direction because we are just outputting points not lines.
+            {
+                // Examine every station on this highway and direction
                 StringBuilder lineout = new StringBuilder();
-                // Examine every station on this highway and direction
                 for (Station stat: hwy.stations)
                 {
-                    String pmID = "" + hwy.routeNumber + " " + stat.postmile;
+                    String pmID = "" + hwy.routeNumber + " " 
+                            + stat.direction.getLetter() + " " 
+                            + stat.postmile;
                     PostmileCoords.Postmile currentPM = pmList.find(pmID);
                     if (currentPM != null)
@@ -566,6 +561,7 @@
                     //lineout.append(stat.getColorByDirection(dir));
                     String outString = currentPM.toJson();
+                    // replace the color code with the color name
                     String colorName="";
-                    switch (stat.getColorByDirection(dir))
+                    switch (stat.getColorByDirection(stat.direction))
                     {
                         case '@': colorName = "red";break;
@@ -579,12 +575,6 @@
                     }
                 }
-                                // See if there were stations for this direction
-                String checkMe = lineout.toString().trim();
-                // if any stations were colored, output the line
-                if (checkMe.length() > 1)
-                {
-                    //result.append(rowLabel);
-                    result.append(lineout + "\n");
-                }
+                //result.append(rowLabel);
+                result.append(lineout + "\n");
 
             }
Index: /trunk/src/atmsdriver/model/PostmileCoords.java
===================================================================
--- /trunk/src/atmsdriver/model/PostmileCoords.java	(revision 244)
+++ /trunk/src/atmsdriver/model/PostmileCoords.java	(revision 248)
@@ -54,5 +54,13 @@
         {
             String[] fields = item.split(",");
-            Postmile pm = new Postmile(fields[0],fields[1],fields[2]);
+            String[] nameparts = fields[0].split(" ");
+            String statepm = nameparts[2];
+            // some postmiles come with a prefix, which we ignore
+            if (Character.isLetter(statepm.charAt(0)))
+            {
+                statepm = statepm.substring(1);
+            }  
+            String revisedpm = nameparts[0] + " " + nameparts[1] + " " + statepm;
+            Postmile pm = new Postmile(revisedpm,fields[1],fields[2]);
             postmileList.add(pm);
         }
@@ -69,5 +77,5 @@
     final static class Postmile  
     {
-        String name;  // the postmile name or id
+        String name;  // the postmile name (Route,Direction,State postmile)
         String latitude; // the latitude coordinate for this postmile
         String longitude; // the longitude coordinate for this postmile
Index: /trunk/src/atmsdriver/GoogleMapAnimator.java
===================================================================
--- /trunk/src/atmsdriver/GoogleMapAnimator.java	(revision 245)
+++ /trunk/src/atmsdriver/GoogleMapAnimator.java	(revision 248)
@@ -33,5 +33,5 @@
      * Error logger.
      */
-    private final static Logger logger = Logger.getLogger("trafficmodeleventdriver");
+    private final static Logger logger = Logger.getLogger("mapanimator");
 
     /**
@@ -195,5 +195,5 @@
     public static void main(String[] args) throws RemoteException, SimulationException
     {
-        JFrame frame = new JFrame("Traffic Events Animator");
+        JFrame frame = new JFrame("Google Map Animator");
         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         frame.setSize(1050,450);
Index: /trunk/test/atmsdriver/model/PostmileCoordsTest.java
===================================================================
--- /trunk/test/atmsdriver/model/PostmileCoordsTest.java	(revision 244)
+++ /trunk/test/atmsdriver/model/PostmileCoordsTest.java	(revision 248)
@@ -37,10 +37,24 @@
 
         System.out.println("load");
-        String line1 = "ORA 4 5.55, 33.33, -117.117\nORA 4 6.66, 33.33, -117.117";
+        String line1 = "5 N 4.02, 33.33, -117.117\n5 S 3.56, 33.33, -117.117";
         Scanner scan = new Scanner(line1).useDelimiter("\\A"); 
         pmc = new PostmileCoords();
         pmc.load(scan);
-        PostmileCoords.Postmile pm = new PostmileCoords.Postmile("ORA 4 5.55", "33.33", "-117.117");
-        assertEquals(pmc.get(0),pm);
+        PostmileCoords.Postmile pm = new PostmileCoords.Postmile("5 N 4.02", "33.33", 
+                "-117.117");
+        assertEquals(pm,pmc.get(0));
+        assert(pmc.size() == 2);
+    }
+    public void testLoadwithPrefix() throws FileNotFoundException
+    {
+
+        System.out.println("load");
+        String line1 = "5 N R4.02, 33.33, -117.117\n5 S 3.56, 33.33, -117.117";
+        Scanner scan = new Scanner(line1).useDelimiter("\\A"); 
+        pmc = new PostmileCoords();
+        pmc.load(scan);
+        PostmileCoords.Postmile pm = new PostmileCoords.Postmile("5 N 4.02", "33.33", 
+                "-117.117");
+        assertEquals(pm,pmc.get(0));
         assert(pmc.size() == 2);
     }
@@ -60,7 +74,7 @@
         System.out.println("find");
         testLoad();
-        PostmileCoords.Postmile result = pmc.find("ORA 4 6.66");
+        PostmileCoords.Postmile result = pmc.find("5 N 4.02");
         assertNotNull(result);
-        PostmileCoords.Postmile pm = new PostmileCoords.Postmile("ORA 4 6.66", "33.33", "-117.117");
+        PostmileCoords.Postmile pm = new PostmileCoords.Postmile("5 N 4.02", "33.33", "-117.117");
         assertEquals(pm,result);
         PostmileCoords.Postmile result2 = pmc.find("X");
Index: /trunk/test/atmsdriver/model/HighwaysTest.java
===================================================================
--- /trunk/test/atmsdriver/model/HighwaysTest.java	(revision 243)
+++ /trunk/test/atmsdriver/model/HighwaysTest.java	(revision 248)
@@ -29,37 +29,37 @@
             writer.println("32 0 2");
             writer.println("1210831 1 5 S 0.9 8 CALAFIA");
-            writer.println("1210832 ML_1");
-            writer.println("1210833 ML_2");
-            writer.println("1210834 ML_3");
-            writer.println("1210835 ML_4");
-            writer.println("1210836 PASSAGE");
-            writer.println("1210837 DEMAND");
-            writer.println("1210838 QUEUE");
-            writer.println("1210839 RAMP_OFF");
+            writer.println("1210832 ML ML_1");
+            writer.println("1210833 ML ML_2");
+            writer.println("1210834 ML ML_3");
+            writer.println("1210835 ML ML_4");
+            writer.println("1210836 PA PASSAGE");
+            writer.println("1210837 DM DEMAND");
+            writer.println("1210838 QU QUEUE");
+            writer.println("1210839 FR RAMP_OFF");
             writer.println("1210845 2 5 S 1.49 9 EL CAMINO REAL");
-            writer.println("1210846 ML_1");
-            writer.println("1210847 ML_2");
-            writer.println("1210848 ML_3");
-            writer.println("1210849 ML_4");
-            writer.println("1210850 RAMP_ON");
-            writer.println("1210851 PASSAGE");
-            writer.println("1210853 DEMAND");
-            writer.println("1210854 QUEUE");
-            writer.println("1210855 RAMP_OFF");
+            writer.println("1210846 ML ML_1");
+            writer.println("1210847 ML ML_2");
+            writer.println("1210848 ML ML_3");
+            writer.println("1210849 ML ML_4");
+            writer.println("1210850 OR RAMP_ON");
+            writer.println("1210851 PA PASSAGE");
+            writer.println("1210853 DM DEMAND");
+            writer.println("1210854 QU QUEUE");
+            writer.println("1210855 FR RAMP_OFF");
             writer.println("74 0 1");
             writer.println("1204203 2 5 N 1.26 13 MAGDALENA");
-            writer.println("1204205 RAMP_ON");
-            writer.println("1204206 QUEUE");
-            writer.println("1204207 DEMAND");
-            writer.println("1204208 PASSAGE");
-            writer.println("1204210 RAMP_OFF");
-            writer.println("1204212 ML_1");
-            writer.println("1204213 ML_2");
-            writer.println("1204214 ML_3");
-            writer.println("1204215 ML_4");
-            writer.println("1204217 OS_1");
-            writer.println("1204218 OS_2");
-            writer.println("1204219 OS_3");
-            writer.println("1204220 OS_4");
+            writer.println("1204205 OR RAMP_ON");
+            writer.println("1204206 QU QUEUE");
+            writer.println("1204207 DM DEMAND");
+            writer.println("1204208 PA PASSAGE");
+            writer.println("1204210 FR RAMP_OFF");
+            writer.println("1204212 ML ML_1");
+            writer.println("1204213 ML ML_2");
+            writer.println("1204214 ML ML_3");
+            writer.println("1204215 ML ML_4");
+            writer.println("1204217 OS OS_1");
+            writer.println("1204218 OS OS_2");
+            writer.println("1204219 OS OS_3");
+            writer.println("1204220 OS OS_4");
             writer.close();
         } catch (Exception e) {
@@ -97,12 +97,11 @@
         System.out.println("toJson");
         Highways highways = new Highways(
-                "config/vds_data/highways_fullmap.txt",
+                "test/atmsdriver/model/ldssample.txt",
                 "localhost", 8080);
-        highways.getHighwayByRouteNumber(5).stations.get(0).loops.get(0).vol = 1;
+        //highways.getHighwayByRouteNumber(5).stations.get(0).loops.get(0).vol = 1;
         String result = highways.toJson();
         System.out.println(result);
-        assertTrue(result.startsWith(expToJson1));
-    }
-    String expToJson1 = ""; 
+        assertTrue(result.indexOf("33.416348") > 0);
+    }
    
 
