Changeset 266 in tmcsimulator
- Timestamp:
- 02/16/2019 03:22:09 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
-
src/atmsdriver/model/Highways.java (modified) (1 diff)
-
src/atmsdriver/model/PostmileCoords.java (modified) (4 diffs)
-
src/tmcsim/application.properties (modified) (1 diff)
-
test/atmsdriver/model/PostmileCoordsTest.java (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/atmsdriver/model/Highways.java
r260 r266 556 556 + stat.postmile; 557 557 PostmileCoords.Postmile currentPM = pmList.find(pmID); 558 if (currentPM == null) 559 { 560 Logger.getLogger(Highways.class.getName()).log(Level.INFO, 561 "Postmile Coords lookup couldn't find Station: "+pmID, 562 " "); 563 } 558 564 if (currentPM != null) 559 565 { 560 //lineout.append("" + dir.getLetter() + stat.postmile);561 //lineout.append(stat.getColorByDirection(dir));562 String outString = currentPM.toJson();563 // replace the color code with the color name564 String colorName="";565 switch (stat.getColorByDirection(stat.direction))566 {567 case '@': colorName = "red";break;568 case '+': colorName = "yellow"; break;569 case '-': colorName = "lime";break;570 case ' ': colorName = "lime";break;571 }572 outString = outString.replace("desiredcolor",colorName);573 lineout.append(outString);574 lineout.append(" ");566 //lineout.append("" + dir.getLetter() + stat.postmile); 567 //lineout.append(stat.getColorByDirection(dir)); 568 String outString = currentPM.toJson(); 569 // replace the color code with the color name 570 String colorName=""; 571 switch (stat.getColorByDirection(stat.direction)) 572 { 573 case '@': colorName = "red";break; 574 case '+': colorName = "yellow"; break; 575 case '-': colorName = "lime";break; 576 case ' ': colorName = "lime";break; 577 } 578 outString = outString.replace("desiredcolor",colorName); 579 lineout.append(outString); 580 lineout.append(" "); 575 581 } 576 582 } -
trunk/src/atmsdriver/model/PostmileCoords.java
r260 r266 48 48 public void load(Scanner scan) 49 49 { 50 try 51 { 50 52 String out = scan.next(); 51 53 // split into an array … … 62 64 } 63 65 String revisedpm = nameparts[0] + " " + nameparts[1] + " " + statepm; 64 Postmile pm = new Postmile(revisedpm,fields[1],fields[2] );66 Postmile pm = new Postmile(revisedpm,fields[1],fields[2],fields[3]); 65 67 postmileList.add(pm); 68 } 69 } 70 catch (Exception ex) 71 { 72 ex.printStackTrace(); 66 73 } 67 74 } … … 77 84 final static class Postmile 78 85 { 79 String name; // the postmile name (Route,Direction,State postmile )86 String name; // the postmile name (Route,Direction,State postmile, e.g., 5 N 6.2) 80 87 String latitude; // the latitude coordinate for this postmile 81 88 String longitude; // the longitude coordinate for this postmile 82 public Postmile(String name, String lat, String longitude) 89 String street; // cross street name 90 public Postmile(String name, String lat, String longitude, String street) 83 91 { 84 92 this.name = name.trim(); 85 93 this.latitude = lat.trim(); 86 94 this.longitude = longitude.trim(); 95 this.street = street.trim(); 87 96 } 88 97 public boolean nameEquals(String target) … … 98 107 boolean r2 = this.latitude.equals(that.latitude); 99 108 boolean r3 = this.longitude.equals(that.longitude); 100 return r1 && r2 && r3; 109 boolean r4 = this.street.equals(that.street); 110 return r1 && r2 && r3 && r4; 101 111 } 102 112 @Override public String toString() 103 113 { 104 return name + ": " + latitude +","+ longitude ;114 return name + ": " + latitude +","+ longitude +","+ street; 105 115 } 106 116 public String toJson() 107 117 { 108 String kFeature = "\n{\n \"type\": \"Feature\",\n \"id\": \""; 109 String kPoint = "\", \n \"geometry\":\n {\n \"type\": \"Point\",\n \"coordinates\": ["; 110 String kProp = "]\n" + 111 " },\n" + 112 " \"properties\": \n" + 113 " {\"color\": \"desiredcolor\""; 114 String kTail = "}\n" + 115 " },"; 116 return kFeature + name + kPoint + longitude + "," + latitude + kProp + kTail; 118 String pattern = "\n{\n \"type\": \"Feature\",\n" 119 + " \"geometry\":\n {\n \"type\": \"Point\",\n" + 120 " \"coordinates\": [%s,%s]\n" + 121 " },\n" + 122 " \"properties\": \n" + 123 " {\"id\": \"%s\", " + 124 "\"street\": \"%s\", " + 125 "\"color\": \"desiredcolor\"" + 126 "}\n},"; 127 128 return String.format(pattern, longitude, latitude, name, street); 117 129 } 118 130 } -
trunk/src/tmcsim/application.properties
r260 r266 1 # Tue, 12 Feb 2019 10:44:52-08001 #Sat, 16 Feb 2019 16:50:48 -0800 2 2 3 Application.revision=2 593 Application.revision=265 4 4 5 5 Application.buildnumber=95 -
trunk/test/atmsdriver/model/PostmileCoordsTest.java
r248 r266 37 37 38 38 System.out.println("load"); 39 String line1 = "5 N 4.02, 33.33, -117.117 \n5 S 3.56, 33.33, -117.117";39 String line1 = "5 N 4.02, 33.33, -117.117,Dyer Rd\n5 S 3.56, 33.33, -117.117,Dyer Rd"; 40 40 Scanner scan = new Scanner(line1).useDelimiter("\\A"); 41 41 pmc = new PostmileCoords(); 42 42 pmc.load(scan); 43 43 PostmileCoords.Postmile pm = new PostmileCoords.Postmile("5 N 4.02", "33.33", 44 "-117.117" );44 "-117.117","Dyer Rd"); 45 45 assertEquals(pm,pmc.get(0)); 46 46 assert(pmc.size() == 2); … … 48 48 public void testLoadwithPrefix() throws FileNotFoundException 49 49 { 50 51 50 System.out.println("load"); 52 String line1 = "5 N R4.02, 33.33, -117.117 \n5 S 3.56, 33.33, -117.117";51 String line1 = "5 N R4.02, 33.33, -117.117,Dyer Rd\n5 S 3.56, 33.33, -117.117,Dyer Rd"; 53 52 Scanner scan = new Scanner(line1).useDelimiter("\\A"); 54 53 pmc = new PostmileCoords(); 55 54 pmc.load(scan); 56 55 PostmileCoords.Postmile pm = new PostmileCoords.Postmile("5 N 4.02", "33.33", 57 "-117.117" );56 "-117.117","Dyer Rd"); 58 57 assertEquals(pm,pmc.get(0)); 59 58 assert(pmc.size() == 2); … … 76 75 PostmileCoords.Postmile result = pmc.find("5 N 4.02"); 77 76 assertNotNull(result); 78 PostmileCoords.Postmile pm = new PostmileCoords.Postmile("5 N 4.02", "33.33", "-117.117" );77 PostmileCoords.Postmile pm = new PostmileCoords.Postmile("5 N 4.02", "33.33", "-117.117","Dyer Rd"); 79 78 assertEquals(pm,result); 80 79 PostmileCoords.Postmile result2 = pmc.find("X"); 81 80 assertNull(result2); 81 System.out.println(pm.toJson()); 82 82 } 83 83 }
Note: See TracChangeset
for help on using the changeset viewer.
