Index: trunk/src/tmcsim/application.properties
===================================================================
--- trunk/src/tmcsim/application.properties	(revision 349)
+++ trunk/src/tmcsim/application.properties	(revision 353)
@@ -1,5 +1,5 @@
-#Wed, 27 Mar 2019 16:27:44 -0700
+#Tue, 02 Apr 2019 19:31:19 -0700
 
-Application.revision=348
+Application.revision=351
 
-Application.buildnumber=114
+Application.buildnumber=115
Index: trunk/src/atmsdriver/model/Highways.java
===================================================================
--- trunk/src/atmsdriver/model/Highways.java	(revision 345)
+++ trunk/src/atmsdriver/model/Highways.java	(revision 353)
@@ -151,9 +151,16 @@
      * Applies specified color to the specified highway stretch. Route number
      * and direction specify the highway. Postmile and range specify the stretch
-     * of specified highway. Dot color is the color to be applied to the
-     * stretch.
-     *
+     * of specified highway. 
+     * The purpose of this method is to modify the highway state to represent 
+     * traffic conditions created by the Traffic Manager.  These conditions 
+     * originate in the traffic events file which specifies traffic congestion arising
+     * during the simulation.  NOTE: Since these events describe congestion,
+     * the direction that the color should be applied is the REVERSE of the
+     * regular flow of traffic.  
+     * So a request to apply red to 55 S from 8.5 for 2 miles means 
+     * the stretch 8.5 -> 10.5 because sobo traffic normally flows toward
+     * decreasing postmiles and we want to do the reverse.
      * @param routeNumber highway route number
-     * @param direction highway direction
+     * @param direction highway direction (for normal traffic flow)
      * @param postmile origin postmile value
      * @param range range from origin postmile
@@ -179,8 +186,9 @@
         Double startPost;
         Double endPost;
+        double epsilon = 0.001;
 
         // postmiles increase from s to n and w to e
-        // handle increasing postmile directinons (north or east)
-        if (direction.equals(Station.DIRECTION.NORTH) || direction.equals(Station.DIRECTION.EAST))
+        // S or W directions backup in a positive postmile direction
+        if (direction.equals(Station.DIRECTION.SOUTH) || direction.equals(Station.DIRECTION.WEST))
         {
             // add range value to startPost to get
@@ -191,5 +199,5 @@
             //   specifies a highway that doesn't exist in the network.
             //   Also the case where a desired postmile to color isn't in
-            //   the network.
+            //   the network.  Ticket 118
             // iterate through the stations, if within the specified highway
             // stretch, update the station by direction and apply dot color
@@ -202,5 +210,5 @@
             }
         } 
-        // handle decreasing postmile directions (south or west) 
+        // N or E directions backup in a negative postmile direction
         else
         {
@@ -581,4 +589,5 @@
         pmList.load(s);
         
+        Collections.sort(highways);  // Sort the highways for easier inspection
         String header = "{\n" +
         "  \"type\": \"FeatureCollection\",\n" +
@@ -590,4 +599,5 @@
             // Examine every station on this highway
             StringBuilder lineout = new StringBuilder();
+            Collections.sort(hwy.stations, new StationComparator());
             for (Station stat: hwy.stations)
             {
Index: trunk/src/atmsdriver/model/StationComparator.java
===================================================================
--- trunk/src/atmsdriver/model/StationComparator.java	(revision 353)
+++ trunk/src/atmsdriver/model/StationComparator.java	(revision 353)
@@ -0,0 +1,53 @@
+package atmsdriver.model;
+
+import java.util.Comparator;
+
+/**
+ * Compare two stations by route and postmile. 
+ * Used by Highways.toJson() so json is listed by route then postmile
+ * @author jdalbey
+ * @version 4/2/2019
+ */
+public final class StationComparator implements Comparator
+{
+
+    /**
+     * Compare two stations by route and postmile. 
+     */
+    @Override
+    public int compare(Object a, Object b)
+    {
+        // check for identity
+        if (a == b)
+        {
+            return 0;
+        }
+        // check that Object is of type Station, if not throw exception
+        if (!(a instanceof Station && b instanceof Station))
+        {
+            throw new ClassCastException("A Station object expected.");
+        }
+        Station statA = (Station) a;
+        Station statB = (Station) b;
+        // compare by direction field first
+        int i = statA.direction.compareTo(statB.direction);
+        if (i != 0) return i;
+        
+        // get difference of postmile values
+        double val = statA.postmile - statB.postmile;
+        
+        // set appropriate comparable return value
+        int retval = 0;
+        if (val > 0)
+        {
+            retval = 1;
+        }
+        else if (val < 0)
+        {
+            retval = -1;
+        }
+
+        return retval;
+    }
+
+}
Index: trunk/src/atmsdriver/model/Highway.java
===================================================================
--- trunk/src/atmsdriver/model/Highway.java	(revision 343)
+++ trunk/src/atmsdriver/model/Highway.java	(revision 353)
@@ -16,5 +16,5 @@
  * @author jdalbey
  */
-final public class Highway
+final public class Highway implements Comparable<Highway>
 {
     /** The identifying number for this highway, e.g., 101 */
@@ -49,3 +49,11 @@
         return Integer.toString(this.routeNumber);
     }
+
+    @Override
+    public int compareTo(Highway other)
+    {
+        int otherRoute = ((Highway) other).routeNumber; 
+        //ascending order
+        return this.routeNumber - otherRoute;        
+    }
 }
