Changeset 266 in tmcsimulator for trunk/src/atmsdriver/model
- Timestamp:
- 02/16/2019 03:22:09 PM (7 years ago)
- Location:
- trunk/src/atmsdriver/model
- Files:
-
- 2 edited
-
Highways.java (modified) (1 diff)
-
PostmileCoords.java (modified) (4 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 }
Note: See TracChangeset
for help on using the changeset viewer.
