@@ -12,33 +12,42 @@ private NmbsToMlgDessinsAdapter() {
1212
1313 }
1414
15- static NmbsTrainType convert (String parentType , String subType , String orientation , int firstClassSeats ) {
15+ static NmbsTrainType convert (String parentType , String subType , String orientation , int firstClassSeats , int position ) {
16+ subType = subType .toUpperCase ();
1617 if (parentType .startsWith ("HLE" )) {
1718 return convertHle (parentType , subType , orientation );
18- } else if (parentType .startsWith ("AM" ) || parentType .startsWith ("MR" ) || parentType .startsWith ("AR" )) {
19+ } else if (parentType .startsWith ("AM" ) || parentType .startsWith ("MR" ) || parentType .startsWith ("AR" ) || parentType . startsWith ( "M08" ) ) {
1920 return convertAm (parentType , subType , orientation , firstClassSeats );
2021 } else if (parentType .startsWith ("I" ) || parentType .startsWith ("M" )) {
21- return convertCarriage (parentType , subType , orientation , firstClassSeats );
22+ return convertCarriage (parentType , subType , orientation , firstClassSeats , position );
2223 } else {
2324 return new NmbsTrainType (parentType , subType , orientation );
2425 }
2526 }
2627
27- private static NmbsTrainType convertCarriage (String parentType , String subType , String orientation , int firstClassSeats ) {
28+ private static NmbsTrainType convertCarriage (String parentType , String subType , String orientation , int firstClassSeats , int position ) {
2829 String newParentType = parentType ;
2930 String newSubType = subType ;
31+ String newOrientation = orientation ;
3032 switch (parentType ) {
3133 case "M4" :
3234 switch (subType ) {
3335 case "A" :
3436 case "AU" :
37+ case "AYU" :
3538 newSubType = "B_A" ;
3639 break ;
3740 case "AD" :
3841 case "AUD" :
3942 newSubType = "B_AD" ;
4043 break ;
44+ case "ADU" :
4145 case "ADX" :
46+ if (position <= 2 ) {
47+ newOrientation = "R" ;
48+ } else {
49+ newOrientation = "L" ;
50+ }
4251 newSubType = "B_ADX" ;
4352 break ;
4453 case "B" :
@@ -109,31 +118,34 @@ private static NmbsTrainType convertCarriage(String parentType, String subType,
109118 }
110119 break ;
111120 }
112- return new NmbsTrainType (newParentType , newSubType , orientation );
121+ return new NmbsTrainType (newParentType , newSubType , newOrientation );
113122 }
114123
115124 private static NmbsTrainType convertAm (String parentType , String subType , String orientation , int firstClassSeats ) {
116125 String newParentType = parentType ;
117126 String newSubType = subType ;
118-
119127 switch (parentType ) {
120128 case "AM08" :
121129 case "AM08M" :
130+ newParentType = "AM08" ;
122131 switch (subType ) {
123132 case "A" :
133+ newSubType = "A" ;
134+ break ;
124135 case "C" :
125136 newSubType = "0_C" ;
126137 break ;
127138 case "B" :
128139 newSubType = "0_B" ;
129140 break ;
130141 }
131- newParentType = "AM08" ;
132142 break ;
133143 case "AM08P" :
134144 newParentType = "AM08" ;
135145 switch (subType ) {
136146 case "A" :
147+ newSubType = "A" ;
148+ break ;
137149 case "C" :
138150 newSubType = "5_C" ;
139151 break ;
0 commit comments