Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 2 commits
  • 9 files changed
  • 0 comments
  • 1 contributor
84  delay_profile/Segments.py
@@ -9,12 +9,12 @@
9 9
 Bangalore_stations = [ 'SBC', 'BNC', 'YPR', 'BNCE' ]
10 10
 Hyderabad_stations = [ 'HYB', 'SC', 'KCG', 'BMT' ]
11 11
 
12  
-## This file lists all the imp segments, with in b/w stations 
  12
+## This file lists all the imp segments, with in b/w stations
13 13
 
14 14
 
15 15
 ###################  Northern Belt  #####################
16 16
 
17  
-# Amritsar(ASR) - Ambala(UMB) 
  17
+# Amritsar(ASR) - Ambala(UMB)
18 18
 asr_umb = ['ASR','JRC','JUC','LDH','UMB']
19 19
 
20 20
 #Ambala(UMB) - Panipat - Delhi
@@ -27,6 +27,9 @@
27 27
 # Delhi- Jaipur(JP)
28 28
 delhi_jp = ['DELHI','RE','AWR','JP']
29 29
 
  30
+# Belt info
  31
+north_belt = [ asr_umb, umb_delhi, umb_mb, delhi_jp ]
  32
+
30 33
 
31 34
 
32 35
 ################## Eastern & Gangetic Belt     #####################
@@ -43,7 +46,7 @@
43 46
 # Delhi- Moradabad(MB)
44 47
 delhi_mb= ['DELHI','MB']
45 48
 
46  
-# Moradabad(MB)- Lucknow(LKO) 
  49
+# Moradabad(MB)- Lucknow(LKO)
47 50
 mb_lko= ['MB','LKO']
48 51
 
49 52
 # Kanpur(CNB)- Allahabad(ALD)
@@ -65,13 +68,9 @@
65 68
 # Mugalsarai(MGS)- Ara - Danapur - Patna(PNBE)
66 69
 mgs_pnbe= ['MGS','ARA','PNBE']
67 70
 
68  
-# Sonpur(SEE)- Hajipur- Barauni- Katihar(KIR) 
  71
+# Sonpur(SEE)- Hajipur- Barauni- Katihar(KIR)
69 72
 see_kir= ['SEE','HJP','BJU','KIR']
70 73
 
71  
-#see_kir1= ['SEE','BJU'] 
72  
-#see_kir2 see-kir only 13, bju-kir: 42, hjp-kir: 17, see-hjp: 69, see-hjp-bju: 75,
73  
-#see_kir3 
74  
-
75 74
 # Mugalsarai(MGS)- Gaya(GAYA)
76 75
 mgs_gaya= ['MGS','DOS','GAYA']
77 76
 
@@ -93,6 +92,11 @@
93 92
 # New Jalpaiguri - New Cooch Behar - New Bongaigon - Guwahati
94 93
 njp_guwahati = ['NJP', 'NCB', 'NBQ', 'GHY']
95 94
 
  95
+# Belt info
  96
+igp_belt = [delhi_agc, delhi_cnb, delhi_mb, cnb_ald, cnb_lko, ald_mgs, \
  97
+    lko_bsb, mb_lko, bsb_see, mgs_pnbe, see_kir, mgs_gaya, \
  98
+    gaya_dhn, garwa_gomoh, pnbe_asn, dhanbad_kolkata, kolkata_mldt, njp_guwahati]
  99
+
96 100
 ################# Western Belt #######################
97 101
 
98 102
 #Jaipur(JP)- Ajmer(AII)- Marwar(MJ)
@@ -102,8 +106,8 @@
102 106
 mj_adi= ['MJ','ABR','ADI']
103 107
 
104 108
 # Ahmedabad(ADI)- Anand(ANND) -Vadodara(BRC)- Surat (ST)
105  
-#adi_surat = ['ADI','ANND','BRC', 'ST'] 
106  
-adi_surat = ['ADI','BRC', 'ST'] 
  109
+#adi_surat = ['ADI','ANND','BRC', 'ST']
  110
+adi_surat = ['ADI','BRC', 'ST']
107 111
 
108 112
 # Ahmedabad(ADI) - Vadodara(BRC)
109 113
 #adi_brc = ['ADI', 'BRC' ]
@@ -111,20 +115,22 @@
111 115
 # Vadodara (BRC) - Surat (ST)
112 116
 #brc_surat = ['BRC', 'ST']
113 117
 
114  
-# Bhusaval(BSL)- Manmad - Kalyan 
  118
+# Bhusaval(BSL)- Manmad - Kalyan
115 119
 bsl_kalyan = ['BSL','MMR','KYN' ]
116 120
 
117 121
 # Surat- Mumbai(CSTM/BCT)
118 122
 st_mumbai = ['ST','MUMBAI']
119 123
 
120  
-# Mumbai-Pune(PUNE) 
  124
+# Mumbai-Pune(PUNE)
121 125
 mumbai_pune = ['MUMBAI','PUNE']
122 126
 
123 127
 # KOTA(KOTA)- Ratlam(RTM)- Vadodara(BRC)
124  
-kota_brc= ['KOTA','RTM','BRC'] 
  128
+kota_brc= ['KOTA','RTM','BRC']
125 129
 
126 130
 # Agra(AF/AGC)- KOTA(KOTA)
127 131
 
  132
+# Belt info
  133
+west_belt = [jp_mj, mj_adi, adi_surat, bsl_kalyan, st_mumbai, mumbai_pune, kota_brc]
128 134
 
129 135
 
130 136
 ##################### South-eastern Belt ################
@@ -141,49 +147,54 @@
141 147
 vskp_bza = ['VSKP', 'RJY', 'BZA']
142 148
 
143 149
 # Vijaywada(BZA) - Guntur - Chennai(MAS/MS)
144  
-bza_chennai = ['BZA', 'GNT', 'CHENNAI'] 
  150
+bza_chennai = ['BZA', 'GNT', 'CHENNAI']
  151
+
  152
+# Belt info
  153
+se_belt = [kolkata_kgp, kgp_bbs, bbs_vskp, vskp_bza, bza_chennai]
145 154
 
146 155
 
147 156
 ##################### Central Belt #################
148 157
 
149  
-# Agra(AF/AGC)- Gwalior(GWL) - Jhansi(JHS) 
  158
+# Agra(AF/AGC)- Gwalior(GWL) - Jhansi(JHS)
150 159
 agc_jhs= ['AGC','GWL','JHS']
151 160
 
152  
-# Jhansi(JHS)- Bina - Bhopal(BPL) 
  161
+# Jhansi(JHS)- Bina - Bhopal(BPL)
153 162
 jhs_bpl= ['JHS','BINA','BPL']
154 163
 
155  
-# Bina - Katni(KTE) 
  164
+# Bina - Katni(KTE)
156 165
 bina_kte= ['BINA','KTE']
157 166
 
158  
-# Ujjain-Bhopal(BPL)- Itarsi(ET) 
  167
+# Ujjain-Bhopal(BPL)- Itarsi(ET)
159 168
 ujn_et= ['UJN', 'BPL', 'ET']
160 169
 
161  
-# Katni(KTE)- Jabalpur(JBP)- Itarsi(ET) 
  170
+# Katni(KTE)- Jabalpur(JBP)- Itarsi(ET)
162 171
 kte_et= ['KTE','JBP','ET']
163 172
 
164  
-# Itarsi(ET)- Bhusaval(BSL) 
  173
+# Itarsi(ET)- Bhusaval(BSL)
165 174
 et_bsl= ['ET','BSL']
166 175
 
167 176
 
168  
-# Itarsi(ET)- Amla(AMLA) - Nagpur(NGP) 
  177
+# Itarsi(ET)- Amla(AMLA) - Nagpur(NGP)
169 178
 et_ngp= ['ET','AMLA','NGP']
170 179
 
171  
-# Wardha - Kazipet - Secunderabad(SC) - Hyderabad(HYB) 
  180
+# Wardha - Kazipet - Secunderabad(SC) - Hyderabad(HYB)
172 181
 wardha_hydbad= ['WR', 'KZJ', 'HYDBAD']
173 182
 
174  
-# Katni(KTE)- Bilaspur(BSP) - Raipur(R) 
  183
+# Katni(KTE)- Bilaspur(BSP) - Raipur(R)
175 184
 kte_r= ['KTE','BSP','R']
176 185
 
177 186
 # Bilaspur - Rourkela
178 187
 bilaspur_rourkela = [ 'BSP', 'ROU' ]
179 188
 
180  
-# Raipur(R) - Titlagarh - Vizianagram - Vishakhapatnam(VSKP) 
  189
+# Raipur(R) - Titlagarh - Vizianagram - Vishakhapatnam(VSKP)
181 190
 r_vskp= ['R', 'TIG', 'VZM', 'VSKP']
182 191
 
183 192
 # Bhusaval(BSL)-Wardha-Nagpur(NGP)
184 193
 bsl_ngp= ['BSL', 'WR', 'NGP']
185 194
 
186  
-
  195
+# Belt info
  196
+central_belt = [ agc_jhs, jhs_bpl, bina_kte, ujn_et, kte_et, et_bsl, et_ngp, \
  197
+    wardha_hydbad, kte_r, bilaspur_rourkela, r_vskp, bsl_ngp]
187 198
 
188 199
 
189 200
 ##################### Southern Belt #################
@@ -191,13 +202,13 @@
191 202
 # Pune(PUNE) - Solapur(SUR) -  Wadi(WADI) - Secunderabad/Hyderabad(HYB)
192 203
 pune_hydbad = ['PUNE','SUR','WADI','HYDBAD']
193 204
 
194  
-# Wadi(WADI)- Guntakal(GTL) - Bangalore(SBC/BNC) 
  205
+# Wadi(WADI)- Guntakal(GTL) - Bangalore(SBC/BNC)
195 206
 wadi_blore = ['WADI','GTL','BLORE']
196 207
 
197  
-# Mumbai- RATNAGIRI(RN)-MADGAON(MAO) 
  208
+# Mumbai- RATNAGIRI(RN)-MADGAON(MAO)
198 209
 mumbai_mao= ['MUMBAI','RN','MAO']
199 210
 
200  
-# MADGAON(MAO)- MANGALORE(MAQ) 
  211
+# MADGAON(MAO)- MANGALORE(MAQ)
201 212
 mao_maq= ['MAO','MAQ']
202 213
 
203 214
 # MANGALORE(MAQ)-Cannanore-Calicut(CLT)-Ernakulum(ERS)
@@ -212,13 +223,28 @@
212 223
 # Coimbatore - Salem - Chennai
213 224
 coimbatore_chennai = [ 'CBE', 'SA', 'CHENNAI' ]
214 225
 
  226
+# Belt info
  227
+south_belt = [pune_hydbad, wadi_blore, mumbai_mao, mao_maq, maq_ers, \
  228
+    ers_tvc, gtl_chennai, coimbatore_chennai]
  229
+
215 230
 
216 231
 ###############################################
217 232
 # list containing all the above mentioned route segments
218 233
 
219 234
 all_segments = [ asr_umb, umb_delhi, umb_mb, delhi_jp, delhi_agc, delhi_cnb, delhi_mb, mb_lko, cnb_ald, ald_mgs, cnb_lko, lko_bsb, bsb_see, mgs_pnbe, see_kir, mgs_gaya, gaya_dhn, garwa_gomoh, pnbe_asn, dhanbad_kolkata, kolkata_mldt, njp_guwahati, jp_mj, mj_adi, adi_surat, bsl_kalyan, st_mumbai, kota_brc, kolkata_kgp, kgp_bbs, bbs_vskp, vskp_bza, bza_chennai, agc_jhs, jhs_bpl, bina_kte, ujn_et, kte_et, et_bsl, et_ngp, wardha_hydbad, kte_r, bilaspur_rourkela, r_vskp, bsl_ngp, mumbai_pune, pune_hydbad, wadi_blore, mumbai_mao, mao_maq, maq_ers, ers_tvc, gtl_chennai, coimbatore_chennai ]
220 235
 
  236
+if __name__=='__main__':
  237
+
  238
+  # Check if the belts have been defined for all segments
221 239
 
222  
-segments_with_max_traffic = [asr_umb, umb_delhi, delhi_cnb, delhi_agc, cnb_ald, ald_mgs, mgs_pnbe, see_kir, dhanbad_kolkata, adi_surat, bsl_kalyan, st_mumbai, kolkata_kgp, vskp_bza, agc_jhs, jhs_bpl, kte_et, et_bsl, wardha_hydbad, bza_chennai, lko_bsb, ujn_et ]
  240
+  print len(all_segments)
  241
+  for s in all_segments:
223 242
 
  243
+    print s
  244
+    if s in north_belt: print 'North'
  245
+    if s in igp_belt: print 'IGP'
  246
+    if s in west_belt: print 'WEST'
  247
+    if s in se_belt: print 'SE BELT'
  248
+    if s in central_belt: print 'CENTRAL'
  249
+    if s in  south_belt: print 'SOUTH'
224 250
 
20  delay_simulation/README
... ...
@@ -0,0 +1,20 @@
  1
+How to run this application
  2
+==========================
  3
+
  4
+The ideal way is to have a apache.conf file (as in this folder) and link it
  5
+with you main apache2.conf file. In your /etc/apache2/apache.conf file
  6
+put this line:
  7
+* Include "/home/sanket/irn-hacku/apache.conf" -- this is for me
  8
+
  9
+Next you need to configure the local apache.conf file, there is a directory location. Just change it to wherever your source is, ex:
  10
+* Alias "/home/sanket/irn-hacku/src/"
  11
+
  12
+To set the config right, just do this:
  13
+
  14
+* sudo service apache2 restart
  15
+
  16
+Your code should be available at:
  17
+
  18
+* http://localhost/irn/
  19
+
  20
+Just make sure your browser has proxy disabled
9  delay_simulation/apache.conf
... ...
@@ -0,0 +1,9 @@
  1
+# Install this file in apache2.conf file
  2
+
  3
+Alias /irn_delay "/home/sanket/src/IRN/delay_simulation/"
  4
+
  5
+<Directory "/home/sanket/src/IRN/delay_simulation/">
  6
+	   Options FollowSymLinks
  7
+	   Order allow,deny
  8
+	   Allow from all
  9
+</Directory>
428,478  delay_simulation/data/NewTrainStationDetailWDelayWSegments.json
428478 additions, 0 deletions not shown
50,757  delay_simulation/data/NewTrainStationWSegmentsWDays.min.json
50757 additions, 0 deletions not shown
59  delay_simulation/data/segments.js
... ...
@@ -0,0 +1,59 @@
  1
+{"segments": [
  2
+	     {"segment":{ 
  3
+		     "seg_name": "mgs_gaya", 
  4
+			 "seg_list": [{"lat": "25.2814947", "lng": "83.1198203"},{"lat": "24.900207", "lng": "84.181077"},{"lat": "24.7800113", "lng": "84.9818234"}]}},
  5
+	     {"segment":{"seg_name": "bsl_kalyan", "seg_list": [{"lat": "21.0473709", "lng": "75.787659"},{"lat": "20.249901", "lng": "74.43586"},{"lat": "19.25", "lng": "73.13"}]}},
  6
+	     {"segment":{"seg_name": "cnb_ald", "seg_list": [{"lat": "26.4546472", "lng": "80.3510491"},{"lat": "25.4358011", "lng": "81.846311"}]}},
  7
+	     {"segment":{"seg_name": "dhanbad_kolkata", "seg_list": [{"lat": "23.7956531", "lng": "86.4303859"},{"lat": "23.68721", "lng": "86.973343"},{"lat": "23.496531", "lng": "87.324203"},{"lat": "22.5957689", "lng": "88.2636394"}]}},
  8
+	     {"segment":{"seg_name": "mao_maq", "seg_list": [{"lat": "15.2719444", "lng": "73.9583333"},{"lat": "12.9141417", "lng": "74.8559568"}]}},
  9
+	     {"segment":{"seg_name": "bza_chennai", "seg_list": [{"lat": "16.5061743", "lng": "80.6480153"},{"lat": "16.3066525", "lng": "80.4365402"},{"lat": "13.0820617", "lng": "80.2755868"}]}},
  10
+	     {"segment":{"seg_name": "pune_hydbad", "seg_list": [{"lat": "18.5204303", "lng": "73.8567437"},{"lat": "17.6599188", "lng": "75.9063906"},{"lat": "17.05397", "lng": "76.993767"},{"lat": "17.453333", "lng": "78.4625"}]}},
  11
+	     {"segment":{"seg_name": "kota_brc", "seg_list": [{"lat": "25.1695114", "lng": "75.8539898"},{"lat": "23.330412", "lng": "75.044315"},{"lat": "22.3073095", "lng": "73.1810976"}]}},
  12
+	     {"segment":{"seg_name": "lko_bsb", "seg_list": [{"lat": "26.8465108", "lng": "80.9466832"},{"lat": "26.2647757", "lng": "82.0727061"},{"lat": "25.3176452", "lng": "82.9739144"}]}},
  13
+	     {"segment":{"seg_name": "st_mumbai", "seg_list": [{"lat": "21.195", "lng": "72.819444"},{"lat": "18.9709308", "lng": "72.8188191"}]}},
  14
+	     {"segment":{"seg_name": "maq_ers", "seg_list": [{"lat": "12.9141417", "lng": "74.8559568"},{"lat": "11.8688889", "lng": "75.3555556"},{"lat": "11.2587531", "lng": "75.78041"},{"lat": "10.01486", "lng": "76.303467"}]}},
  15
+	     {"segment":{"seg_name": "mgs_pnbe", "seg_list": [{"lat": "25.2814947", "lng": "83.1198203"},{"lat": "25.5587969", "lng": "84.667097"},{"lat": "25.6125", "lng": "85.1283333"}]}},
  16
+	     {"segment":{"seg_name": "kte_r", "seg_list": [{"lat": "23.836081", "lng": "80.39547"},{"lat": "22.0796251", "lng": "82.1391412"},{"lat": "21.2513844", "lng": "81.6296413"}]}},
  17
+	     {"segment":{"seg_name": "gtl_chennai", "seg_list": [{"lat": "15.16782", "lng": "77.37117"},{"lat": "14.4673541", "lng": "78.8241339"},{"lat": "13.6373112", "lng": "79.5035957"},{"lat": "13.0820617", "lng": "80.2755868"}]}},
  18
+	     {"segment":{"seg_name": "ujn_et", "seg_list": [{"lat": "23.1793013", "lng": "75.7849097"},{"lat": "23.2599333", "lng": "77.412615"},{"lat": "22.609801", "lng": "77.769424"}]}},
  19
+	     {"segment":{"seg_name": "cnb_lko", "seg_list": [{"lat": "26.4546472", "lng": "80.3510491"},{"lat": "26.8465108", "lng": "80.9466832"}]}},
  20
+	     {"segment":{"seg_name": "kolkata_mldt", "seg_list": [{"lat": "22.5957689", "lng": "88.2636394"},{"lat": "25.0108408", "lng": "88.1410967"}]}},
  21
+	     {"segment":{"seg_name": "bbs_vskp", "seg_list": [{"lat": "20.2960587", "lng": "85.8245398"},{"lat": "18.1066576", "lng": "83.3955506"},{"lat": "17.6868159", "lng": "83.2184815"}]}},
  22
+	     {"segment":{"seg_name": "wardha_hydbad", "seg_list": [{"lat": "20.745319", "lng": "78.6021946"},{"lat": "17.972366", "lng": "79.5034501"},{"lat": "17.453333", "lng": "78.4625"}]}},
  23
+	     {"segment":{"seg_name": "delhi_agc", "seg_list": [{"lat": "28.635308", "lng": "77.22496"},{"lat": "27.4924134", "lng": "77.673673"},{"lat": "27.1766701", "lng": "78.0080745"}]}},
  24
+	     {"segment":{"seg_name": "agc_jhs", "seg_list": [{"lat": "27.1766701", "lng": "78.0080745"},{"lat": "26.2182871", "lng": "78.1828308"},{"lat": "25.444121", "lng": "78.567604"}]}},
  25
+	     {"segment":{"seg_name": "bilaspur_rourkela", "seg_list": [{"lat": "22.0796251", "lng": "82.1391412"},{"lat": "22.249444", "lng": "84.882988"}]}},
  26
+	     {"segment":{"seg_name": "umb_delhi", "seg_list": [{"lat": "30.3781788", "lng": "76.7766974"},{"lat": "29.39", "lng": "76.97"},{"lat": "28.635308", "lng": "77.22496"}]}},
  27
+	     {"segment":{"seg_name": "umb_mb", "seg_list": [{"lat": "30.3781788", "lng": "76.7766974"},{"lat": "28.8315925", "lng": "78.7782764"}]}},
  28
+	     {"segment":{"seg_name": "ers_tvc", "seg_list": [{"lat": "10.01486", "lng": "76.303467"},{"lat": "9.4980667", "lng": "76.3388484"},{"lat": "8.4874949", "lng": "76.948623"}]}},
  29
+	     {"segment":{"seg_name": "gaya_dhn", "seg_list": [{"lat": "24.7800113", "lng": "84.9818234"},{"lat": "23.874821", "lng": "86.159767"},{"lat": "23.7956531", "lng": "86.4303859"}]}},
  30
+	     {"segment":{"seg_name": "bsb_see", "seg_list": [{"lat": "25.3176452", "lng": "82.9739144"},{"lat": "25.70774360", "lng": "85.18900180"}]}},
  31
+	     {"segment":{"seg_name": "jhs_bpl", "seg_list": [{"lat": "25.444121", "lng": "78.567604"},{"lat": "24.169331", "lng": "78.187897"},{"lat": "23.2599333", "lng": "77.412615"}]}},
  32
+	     {"segment":{"seg_name": "kte_et", "seg_list": [{"lat": "23.836081", "lng": "80.39547"},{"lat": "23.165586", "lng": "79.9430299"},{"lat": "22.609801", "lng": "77.769424"}]}},
  33
+	     {"segment":{"seg_name": "ald_mgs", "seg_list": [{"lat": "25.4358011", "lng": "81.846311"},{"lat": "25.2814947", "lng": "83.1198203"}]}},
  34
+	     {"segment":{"seg_name": "njp_guwahati", "seg_list": [{"lat": "26.6824333", "lng": "88.4438898"},{"lat": "26.3490445", "lng": "89.4659462"},{"lat": "26.4757382", "lng": "90.5359743"},{"lat": "26.147129", "lng": "91.7355511"}]}},
  35
+	     {"segment":{"seg_name": "see_kir", "seg_list": [{"lat": "25.70774360", "lng": "85.18900180"},{"lat": "25.68", "lng": "85.22"},{"lat": "25.469312", "lng": "85.987525"},{"lat": "25.53754", "lng": "87.566093"}]}},
  36
+	     {"segment":{"seg_name": "mumbai_mao", "seg_list": [{"lat": "18.9709308", "lng": "72.8188191"},{"lat": "16.99202", "lng": "73.2923129"},{"lat": "15.2719444", "lng": "73.9583333"}]}},
  37
+	     {"segment":{"seg_name": "garwa_gomoh", "seg_list": [{"lat": "24.2146681", "lng": "83.8870563"},{"lat": "23.6199939", "lng": "85.4558069"},{"lat": "23.874821", "lng": "86.159767"}]}},
  38
+	     {"segment":{"seg_name": "asr_umb", "seg_list": [{"lat": "31.6339793", "lng": "74.8722642"},{"lat": "31.3260152", "lng": "75.5761829"},{"lat": "31.3260152", "lng": "75.5761829"},{"lat": "30.900965", "lng": "75.8572758"},{"lat": "30.3781788", "lng": "76.7766974"}]}},
  39
+	     {"segment":{"seg_name": "mumbai_pune", "seg_list": [{"lat": "18.9709308", "lng": "72.8188191"},{"lat": "18.5204303", "lng": "73.8567437"}]}},
  40
+	     {"segment":{"seg_name": "vskp_bza", "seg_list": [{"lat": "17.6868159", "lng": "83.2184815"},{"lat": "17.4268845", "lng": "82.6896447"},{"lat": "16.5061743", "lng": "80.6480153"}]}},
  41
+	     {"segment":{"seg_name": "delhi_cnb", "seg_list": [{"lat": "28.635308", "lng": "77.22496"},{"lat": "27.89381", "lng": "78.068138"},{"lat": "27.210246", "lng": "78.23297"},{"lat": "26.7793556", "lng": "79.0185723"},{"lat": "26.4546472", "lng": "80.3510491"}]}},
  42
+	     {"segment":{"seg_name": "bina_kte", "seg_list": [{"lat": "24.169331", "lng": "78.187897"},{"lat": "23.836081", "lng": "80.39547"}]}},
  43
+	     {"segment":{"seg_name": "wadi_blore", "seg_list": [{"lat": "17.05397", "lng": "76.993767"},{"lat": "15.16782", "lng": "77.37117"},{"lat": "12.9715987", "lng": "77.5945627"}]}},
  44
+	     {"segment":{"seg_name": "et_bsl", "seg_list": [{"lat": "22.609801", "lng": "77.769424"},{"lat": "21.0473709", "lng": "75.787659"}]}},
  45
+	     {"segment":{"seg_name": "adi_surat", "seg_list": [{"lat": "23.0395677", "lng": "72.5660045"},{"lat": "22.3073095", "lng": "73.1810976"},{"lat": "21.195", "lng": "72.819444"}]}},
  46
+	     {"segment":{"seg_name": "bsl_ngp", "seg_list": [{"lat": "21.0473709", "lng": "75.787659"},{"lat": "20.745319", "lng": "78.6021946"},{"lat": "21.1458004", "lng": "79.0881546"}]}},
  47
+	     {"segment":{"seg_name": "coimbatore_chennai", "seg_list": [{"lat": "11.0168445", "lng": "76.9558321"},{"lat": "11.664325", "lng": "78.1460142"},{"lat": "13.0820617", "lng": "80.2755868"}]}},
  48
+	     {"segment":{"seg_name": "mj_adi", "seg_list": [{"lat": "25.735571", "lng": "73.610893"},{"lat": "24.479394", "lng": "72.7838699"},{"lat": "23.0395677", "lng": "72.5660045"}]}},
  49
+	     {"segment":{"seg_name": "r_vskp", "seg_list": [{"lat": "21.2513844", "lng": "81.6296413"},{"lat": "20.2885278", "lng": "83.1511111"},{"lat": "18.1066576", "lng": "83.3955506"},{"lat": "17.6868159", "lng": "83.2184815"}]}},
  50
+	     {"segment":{"seg_name": "mb_lko", "seg_list": [{"lat": "28.8315925", "lng": "78.7782764"},{"lat": "26.8465108", "lng": "80.9466832"}]}},
  51
+	     {"segment":{"seg_name": "et_ngp", "seg_list": [{"lat": "22.609801", "lng": "77.769424"},{"lat": "21.9192675", "lng": "78.1279359"},{"lat": "21.1458004", "lng": "79.0881546"}]}},
  52
+	     {"segment":{"seg_name": "delhi_jp", "seg_list": [{"lat": "28.635308", "lng": "77.22496"},{"lat": "28.18811", "lng": "76.611542"},{"lat": "27.5609324", "lng": "76.6250168"},{"lat": "26.9124165", "lng": "75.7872879"}]}},
  53
+	     {"segment":{"seg_name": "jp_mj", "seg_list": [{"lat": "26.9124165", "lng": "75.7872879"},{"lat": "26.45", "lng": "74.64"},{"lat": "25.735571", "lng": "73.610893"}]}},
  54
+	     {"segment":{"seg_name": "kolkata_kgp", "seg_list": [{"lat": "22.5957689", "lng": "88.2636394"},{"lat": "22.3304", "lng": "87.318108"}]}},
  55
+	     {"segment":{"seg_name": "delhi_mb", "seg_list": [{"lat": "28.635308", "lng": "77.22496"},{"lat": "28.8315925", "lng": "78.7782764"}]}},
  56
+	     {"segment":{"seg_name": "pnbe_asn", "seg_list": [{"lat": "25.6125", "lng": "85.1283333"},{"lat": "23.68721", "lng": "86.973343"}]}},
  57
+	     {"segment":{"seg_name": "kgp_bbs", "seg_list": [{"lat": "22.3304", "lng": "87.318108"},{"lat": "20.2960587", "lng": "85.8245398"}]}} 
  58
+	     ]
  59
+	}
84  delay_simulation/index.html
... ...
@@ -0,0 +1,84 @@
  1
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2
+<html xmlns="http://www.w3.org/1999/xhtml">
  3
+  <head>
  4
+    <script src="http://maps.googleapis.com/maps/api/js?key=AIzaSyCu6j3hJiFtxsHfFXt5qCXK-kL81Vxvqj4&sensor=false" type="text/javascript"></script>
  5
+    <script src="http://code.jquery.com/jquery-latest.js"></script>
  6
+    <script src="js/epoly_v3.js" type="text/javascript"></script>
  7
+    <script src="js/jstat.js" type="text/javascript"></script>
  8
+    <!--script src="../NewTrainStationWSegmentsWDays.min.json" type="text/javascript"></script-->
  9
+  </head>
  10
+  <body  onunload="GUnload()" style="bgcolor: #ff0000; width: 1200px">
  11
+    <table>
  12
+
  13
+	<tr> <!-- Information row -->
  14
+		<td style="verticle-align: top; width: 6000px">
  15
+		  
  16
+			<button onclick="reset();" value="Reset" >Reset</button>
  17
+			<button onclick="start();" id="anim" >Start</button>
  18
+			<div id="time"><b>Time</b>(day:hr::min): 0 :: 0 :: 0</div>
  19
+			Speed:&nbsp &nbsp <input id="range" type="range" min="1" max="40" value="6" step="1" onkeyup="showValue(this.value)" /><span id="timeScale" >6</span>
  20
+			<br/>
  21
+			<br/>
  22
+		  
  23
+		 </td>
  24
+		 <td>
  25
+			 
  26
+			<button onCLick="setTime();" id="setTime" >Set</button>
  27
+			<button onCLick="viewAsyncTraffic();" id="viewAsyncTraffic" >View</button>
  28
+			<br/>
  29
+			Set Time:<input id="Trange" type="range" min="1" max="48" value="0" step="1" width="300px" onkeyup="showValueTime(this.value)" /> <span id="time-line" > 00::00 </span>
  30
+			<div id="SegTot_normal">Total running trains(MAP_NORMAL): </div>  
  31
+			<div id="SegTot_delay">Total running trains(MAP_DELAY) : </div>  
  32
+		</tr>
  33
+		
  34
+		  <!---
  35
+		  Enter Segment No.<input type=text onchange="search_seg(this.value);"/>
  36
+		  <div id="segName">Segment Name: </div>
  37
+		  <div id="segInfo">Number of Running Trains: </div>
  38
+		  --->
  39
+		  
  40
+		  <!---
  41
+		  <div>
  42
+			<h5>Graphical Visualisation:</h5>
  43
+			<div id="placeholder" style="width:600px;height:250px"></div>
  44
+		  </div>
  45
+		  Enter Segment No.<input type=text onchange="search(this.value);"/>
  46
+		  <div id="segInfo" style="border-style:solid;border-width:5px;height:150px;width:400px"/>
  47
+		  --->
  48
+	<tr>
  49
+		</td>
  50
+		
  51
+		<td>
  52
+		  <div id="map_normal" style="width: 700px;height: 700px;position: absolute"></div>
  53
+		  <div id="overlay_normal"style="width: 700px;height: 700px; background-color: #000; opacity: 0.6"/>
  54
+		</td>
  55
+		<td>
  56
+		  <div id="map_delay" style="width: 700px;height: 700px;position: absolute"></div>
  57
+		  <div id="overlay_delay"style="width: 700px;height: 700px; background-color: #000; opacity: 0.6"/>
  58
+		</td>
  59
+	</tr> <!-- Map table row ends -->
  60
+	 
  61
+	<tr> <!-- Bussiest segments row -->
  62
+	   <td>
  63
+		<h5>Three Bussiest Segments(MAP_NORMAL)</h5>
  64
+		  <div id="busy1_normal"></div>
  65
+		  <div id="busy2_normal"></div>
  66
+		  <div id="busy3_normal"></div>
  67
+	   </td>
  68
+	   <td>
  69
+		<h5>Three Bussiest Segments(MAP_DELAY)</h5>
  70
+		  <div id="busy1_delay"></div>
  71
+		  <div id="busy2_delay"></div>
  72
+		  <div id="busy3_delay"></div>
  73
+	   </td>
  74
+	</tr> <!-- Bussiest segments row ends -->
  75
+
  76
+    </table>
  77
+    <script src="js/helper.js" type="text/javascript"></script>
  78
+    <!--div onclick="MoveMarker()";> This is the place </div>
  79
+  <div id="encodedPolyline" onclick="setMarker()"><hr/>This is the encoded place<br/></div><hr/>
  80
+  <div id="distance">Distance <br/></div-->
  81
+    <script language="javascript" type="text/javascript" src="js/flot/jquery.js"></script>
  82
+    <script language="javascript" type="text/javascript" src="js/flot/jquery.flot.js"></script>
  83
+  </body>
  84
+</html>
324  delay_simulation/js/epoly_v3.js
... ...
@@ -0,0 +1,324 @@
  1
+/*********************************************************************\
  2
+*                                                                     *
  3
+* epolys.js                                          by Mike Williams *
  4
+* updated to API v3                                  by Larry Ross    *
  5
+*                                                                     *
  6
+* A Google Maps API Extension                                         *
  7
+*                                                                     *
  8
+* Adds various Methods to google.maps.Polygon and google.maps.Polyline *
  9
+*                                                                     *
  10
+* .Contains(latlng) returns true is the poly contains the specified   *
  11
+*                   GLatLng                                           *
  12
+*                                                                     *
  13
+* .Area()           returns the approximate area of a poly that is    *
  14
+*                   not self-intersecting                             *
  15
+*                                                                     *
  16
+* .Distance()       returns the length of the poly path               *
  17
+*                                                                     *
  18
+* .Bounds()         returns a GLatLngBounds that bounds the poly      *
  19
+*                                                                     *
  20
+* .GetPointAtDistance() returns a GLatLng at the specified distance   *
  21
+*                   along the path.                                   *
  22
+*                   The distance is specified in metres               *
  23
+*                   Reurns null if the path is shorter than that      *
  24
+*                                                                     *
  25
+* .GetPointsAtDistance() returns an array of GLatLngs at the          *
  26
+*                   specified interval along the path.                *
  27
+*                   The distance is specified in metres               *
  28
+*                                                                     *
  29
+* .GetIndexAtDistance() returns the vertex number at the specified    *
  30
+*                   distance along the path.                          *
  31
+*                   The distance is specified in metres               *
  32
+*                   Reurns null if the path is shorter than that      *
  33
+*                                                                     *
  34
+* .Bearing(v1?,v2?) returns the bearing between two vertices          *
  35
+*                   if v1 is null, returns bearing from first to last *
  36
+*                   if v2 is null, returns bearing from v1 to next    *
  37
+*                                                                     *
  38
+*                                                                     *
  39
+***********************************************************************
  40
+*                                                                     *
  41
+*   This Javascript is provided by Mike Williams                      *
  42
+*   Blackpool Community Church Javascript Team                        *
  43
+*   http://www.blackpoolchurch.org/                                   *
  44
+*   http://econym.org.uk/gmap/                                        *
  45
+*                                                                     *
  46
+*   This work is licenced under a Creative Commons Licence            *
  47
+*   http://creativecommons.org/licenses/by/2.0/uk/                    *
  48
+*                                                                     *
  49
+***********************************************************************
  50
+*                                                                     *
  51
+* Version 1.1       6-Jun-2007                                        *
  52
+* Version 1.2       1-Jul-2007 - fix: Bounds was omitting vertex zero *
  53
+*                                add: Bearing                         *
  54
+* Version 1.3       28-Nov-2008  add: GetPointsAtDistance()           *
  55
+* Version 1.4       12-Jan-2009  fix: GetPointsAtDistance()           *
  56
+* Version 3.0       11-Aug-2010  update to v3                         *
  57
+*                                                                     *
  58
+\*********************************************************************/
  59
+
  60
+// === first support methods that don't (yet) exist in v3
  61
+google.maps.LatLng.prototype.distanceFrom = function(newLatLng) {
  62
+  //var R = 6371; // km (change this constant to get miles)
  63
+  var R = 6378100; // meters
  64
+  var lat1 = this.lat();
  65
+  var lon1 = this.lng();
  66
+  var lat2 = newLatLng.lat();
  67
+  var lon2 = newLatLng.lng();
  68
+  var dLat = (lat2-lat1) * Math.PI / 180;
  69
+  var dLon = (lon2-lon1) * Math.PI / 180;
  70
+  var a = Math.sin(dLat/2) * Math.sin(dLat/2) +
  71
+    Math.cos(lat1 * Math.PI / 180 ) * Math.cos(lat2 * Math.PI / 180 ) *
  72
+    Math.sin(dLon/2) * Math.sin(dLon/2);
  73
+  var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
  74
+  var d = R * c;
  75
+  return d;
  76
+}
  77
+
  78
+google.maps.LatLng.prototype.latRadians = function() {
  79
+  return this.lat() * Math.PI/180;
  80
+}
  81
+
  82
+google.maps.LatLng.prototype.lngRadians = function() {
  83
+  return this.lng() * Math.PI/180;
  84
+}
  85
+
  86
+google.maps.LatLng.prototype.equals = function(otherLatLng) {
  87
+  var EQUALS_THRESHOLD = 0.001;
  88
+  return (this.distanceFrom(otherLatLng) < EQUALS_THRESHOLD);
  89
+}
  90
+
  91
+// === A method for testing if a point is inside a polygon
  92
+// === Returns true if poly contains point
  93
+// === Algorithm shamelessly stolen from http://alienryderflex.com/polygon/ 
  94
+google.maps.Polygon.prototype.Contains = function(point) {
  95
+  var j=0;
  96
+  var oddNodes = false;
  97
+  var x = point.lng();
  98
+  var y = point.lat();
  99
+  for (var i=0; i < this.getPath().getLength(); i++) {
  100
+    j++;
  101
+    if (j == this.getPath().getLength()) {j = 0;}
  102
+    if (((this.getPath().getAt(i).lat() < y) && (this.getPath().getAt(j).lat() >= y))
  103
+    || ((this.getPath().getAt(j).lat() < y) && (this.getPath().getAt(i).lat() >= y))) {
  104
+      if ( this.getPath().getAt(i).lng() + (y - this.getPath().getAt(i).lat())
  105
+      /  (this.getPath().getAt(j).lat()-this.getPath().getAt(i).lat())
  106
+      *  (this.getPath().getAt(j).lng() - this.getPath().getAt(i).lng())<x ) {
  107
+        oddNodes = !oddNodes
  108
+      }
  109
+    }
  110
+  }
  111
+  return oddNodes;
  112
+}
  113
+
  114
+// === A method which returns the approximate area of a non-intersecting polygon in square metres ===
  115
+// === It doesn't fully account for spherical geometry, so will be inaccurate for large polygons ===
  116
+// === The polygon must not intersect itself ===
  117
+//
  118
+// only calculates the area of the first path
  119
+//
  120
+google.maps.Polygon.prototype.Area = function() {
  121
+  var a = 0;
  122
+  var j = 0;
  123
+  var b = this.Bounds();
  124
+  var x0 = b.getSouthWest().lng();
  125
+  var y0 = b.getSouthWest().lat();
  126
+  for (var i=0; i < this.getPath().getLength(); i++) {
  127
+    j++;
  128
+    if (j == this.getPath().getLength()) {j = 0;}
  129
+    var x1 = this.getPath().getAt(i).distanceFrom(new google.maps.LatLng(this.getPath().getAt(i).lat(),x0));
  130
+    var x2 = this.getPath().getAt(j).distanceFrom(new google.maps.LatLng(this.getPath().getAt(j).lat(),x0));
  131
+    var y1 = this.getPath().getAt(i).distanceFrom(new google.maps.LatLng(y0,this.getPath().getAt(i).lng()));
  132
+    var y2 = this.getPath().getAt(j).distanceFrom(new google.maps.LatLng(y0,this.getPath().getAt(j).lng()));
  133
+    a += x1*y2 - x2*y1;
  134
+  }
  135
+  return Math.abs(a * 0.5);
  136
+}
  137
+
  138
+// == spherical area from
  139
+// http://forum.worldwindcentral.com/showthread.php?t=20724
  140
+/// <summary>
  141
+/// Haversine function : hav(x) = (1-cos(x))/2
  142
+/// </summary>
  143
+/// <param name="x"></param>
  144
+/// <returns>Returns the value of Haversine function</returns>
  145
+function Haversine( x ) {
  146
+   return ( 1.0 - Math.cos( x ) ) / 2.0;
  147
+}
  148
+
  149
+/// <summary>
  150
+/// Compute the Area of a Spherical Polygon
  151
+/// </summary>
  152
+/// <param name="paths">latlng array of all vertices</param>
  153
+/// <param name="r">spherical radius</param>
  154
+/// <returns>Returns the area of a spherical polygon</returns>
  155
+//
  156
+// only calculates the area of the first path
  157
+//
  158
+google.maps.Polygon.prototype.SphericalPolygonArea = function ( ) {
  159
+  var r= 6378100; // meters
  160
+
  161
+  var lam1 = 0, lam2 = 0, beta1 =0, beta2 = 0, cosB1 = 0, cosB2 = 0;
  162
+  var hav = 0;
  163
+  var sum = 0;
  164
+  var paths = this.getPath();
  165
+  if (paths.getLength() < 2) return 0;
  166
+  for( var j = 0 ; j < paths.getLength() ; j++ ) {
  167
+    var k = j + 1;
  168
+    if( j == 0 ) {
  169
+      lam1 = paths.getAt(j).lngRadians();
  170
+      beta1 = paths.getAt(j).latRadians();
  171
+      lam2 = paths.getAt(j + 1).lngRadians();
  172
+      beta2 = paths.getAt(j + 1).latRadians();
  173
+      cosB1 = Math.cos( beta1 );
  174
+      cosB2 = Math.cos( beta2 );
  175
+    }
  176
+    else
  177
+    {
  178
+      k = ( j + 1 ) % paths.getLength();
  179
+	lam1 = lam2;
  180
+	beta1 = beta2;
  181
+	lam2 = paths.getAt(k).lngRadians();
  182
+      beta2 = paths.getAt(k).latRadians();
  183
+	cosB1 = cosB2;
  184
+	cosB2 = Math.cos( beta2 );
  185
+    }
  186
+    if( lam1 != lam2 ) {
  187
+      var hav = Haversine( beta2 - beta1 ) + 
  188
+                          cosB1 * cosB2 * Haversine( lam2 - lam1 );
  189
+      var a = 2 * Math.asin( Math.sqrt( hav ) );
  190
+      var b = Math.PI / 2 - beta2;
  191
+      var c = Math.PI / 2 - beta1;
  192
+      var s = 0.5 * ( a + b + c );
  193
+      var t = Math.tan( s / 2 ) * Math.tan( ( s - a ) / 2 ) *  
  194
+              Math.tan( ( s - b ) / 2 ) * Math.tan( ( s - c ) / 2 );
  195
+
  196
+      var excess = Math.abs( 4 * Math.atan( Math.sqrt( 
  197
+                               Math.abs( t ) ) ) );
  198
+
  199
+      if( lam2 < lam1 ) {
  200
+        excess = -excess;
  201
+      }
  202
+
  203
+      sum += excess;
  204
+    }
  205
+  }
  206
+  return Math.abs( sum ) * r * r;
  207
+}
  208
+
  209
+// === A method which returns the length of a path in metres ===
  210
+google.maps.Polygon.prototype.Distance = function() {
  211
+  var dist = 0;
  212
+  for (var i=1; i < this.getPath().getLength(); i++) {
  213
+    dist += this.getPath().getAt(i).distanceFrom(this.getPath().getAt(i-1));
  214
+  }
  215
+  return dist;
  216
+}
  217
+
  218
+// === A method which returns the bounds as a GLatLngBounds ===
  219
+google.maps.Polygon.prototype.Bounds = function() {
  220
+  var bounds = new google.maps.LatLngBounds();
  221
+  for (var i=0; i < this.getPath().getLength(); i++) {
  222
+    bounds.extend(this.getPath().getAt(i));
  223
+  }
  224
+  return bounds;
  225
+}
  226
+
  227
+// === A method which returns a GLatLng of a point a given distance along the path ===
  228
+// === Returns null if the path is shorter than the specified distance ===
  229
+google.maps.Polygon.prototype.GetPointAtDistance = function(metres) {
  230
+  // some awkward special cases
  231
+  if (metres == 0) return this.getPath().getAt(0);
  232
+  if (metres < 0) return null;
  233
+  var dist=0;
  234
+  var olddist=0;
  235
+  for (var i=1; (i < this.getPath().getLength() && dist < metres); i++) {
  236
+    olddist = dist;
  237
+    dist += this.getPath().getAt(i).distanceFrom(this.getPath().getAt(i-1));
  238
+  }
  239
+  if (dist < metres) {return null;}
  240
+  var p1= this.getPath().getAt(i-2);
  241
+  var p2= this.getPath().getAt(i-1);
  242
+  var m = (metres-olddist)/(dist-olddist);
  243
+  return new google.maps.LatLng( p1.lat() + (p2.lat()-p1.lat())*m, p1.lng() + (p2.lng()-p1.lng())*m);
  244
+}
  245
+
  246
+// === A method which returns an array of GLatLngs of points a given interval along the path ===
  247
+google.maps.Polygon.prototype.GetPointsAtDistance = function(metres) {
  248
+  var next = metres;
  249
+  var points = [];
  250
+  // some awkward special cases
  251
+  if (metres <= 0) return points;
  252
+  var dist=0;
  253
+  var olddist=0;
  254
+  for (var i=1; (i < this.getPath().getLength()); i++) {
  255
+    olddist = dist;
  256
+    dist += this.getPath().getAt(i).distanceFrom(this.getPath().getAt(i-1));
  257
+    while (dist > next) {
  258
+      var p1= this.getPath().getAt(i-1);
  259
+      var p2= this.getPath().getAt(i);
  260
+      var m = (next-olddist)/(dist-olddist);
  261
+      points.push(new google.maps.LatLng( p1.lat() + (p2.lat()-p1.lat())*m, p1.lng() + (p2.lng()-p1.lng())*m));
  262
+      next += metres;    
  263
+    }
  264
+  }
  265
+  return points;
  266
+}
  267
+
  268
+// === A method which returns the Vertex number at a given distance along the path ===
  269
+// === Returns null if the path is shorter than the specified distance ===
  270
+google.maps.Polygon.prototype.GetIndexAtDistance = function(metres) {
  271
+  // some awkward special cases
  272
+  if (metres == 0) return this.getPath().getAt(0);
  273
+  if (metres < 0) return null;
  274
+  var dist=0;
  275
+  var olddist=0;
  276
+  for (var i=1; (i < this.getPath().getLength() && dist < metres); i++) {
  277
+    olddist = dist;
  278
+    dist += this.getPath().getAt(i).distanceFrom(this.getPath().getAt(i-1));
  279
+  }
  280
+  if (dist < metres) {return null;}
  281
+  return i;
  282
+}
  283
+
  284
+// === A function which returns the bearing between two vertices in decgrees from 0 to 360===
  285
+// === If v1 is null, it returns the bearing between the first and last vertex ===
  286
+// === If v1 is present but v2 is null, returns the bearing from v1 to the next vertex ===
  287
+// === If either vertex is out of range, returns void ===
  288
+google.maps.Polygon.prototype.Bearing = function(v1,v2) {
  289
+  if (v1 == null) {
  290
+    v1 = 0;
  291
+    v2 = this.getPath().getLength()-1;
  292
+  } else if (v2 ==  null) {
  293
+    v2 = v1+1;
  294
+  }
  295
+  if ((v1 < 0) || (v1 >= this.getPath().getLength()) || (v2 < 0) || (v2 >= this.getPath().getLength())) {
  296
+    return;
  297
+  }
  298
+  var from = this.getPath().getAt(v1);
  299
+  var to = this.getPath().getAt(v2);
  300
+  if (from.equals(to)) {
  301
+    return 0;
  302
+  }
  303
+  var lat1 = from.latRadians();
  304
+  var lon1 = from.lngRadians();
  305
+  var lat2 = to.latRadians();
  306
+  var lon2 = to.lngRadians();
  307
+  var angle = - Math.atan2( Math.sin( lon1 - lon2 ) * Math.cos( lat2 ), Math.cos( lat1 ) * Math.sin( lat2 ) - Math.sin( lat1 ) * Math.cos( lat2 ) * Math.cos( lon1 - lon2 ) );
  308
+  if ( angle < 0.0 ) angle  += Math.PI * 2.0;
  309
+  angle = angle * 180.0 / Math.PI;
  310
+  return parseFloat(angle.toFixed(1));
  311
+}
  312
+
  313
+// === Copy all the above functions to GPolyline ===
  314
+google.maps.Polyline.prototype.Contains             = google.maps.Polygon.prototype.Contains;
  315
+google.maps.Polyline.prototype.Area                 = google.maps.Polygon.prototype.Area;
  316
+google.maps.Polyline.prototype.Distance             = google.maps.Polygon.prototype.Distance;
  317
+google.maps.Polyline.prototype.Bounds               = google.maps.Polygon.prototype.Bounds;
  318
+google.maps.Polyline.prototype.GetPointAtDistance   = google.maps.Polygon.prototype.GetPointAtDistance;
  319
+google.maps.Polyline.prototype.GetPointsAtDistance  = google.maps.Polygon.prototype.GetPointsAtDistance;
  320
+google.maps.Polyline.prototype.GetIndexAtDistance   = google.maps.Polygon.prototype.GetIndexAtDistance;
  321
+google.maps.Polyline.prototype.Bearing              = google.maps.Polygon.prototype.Bearing;
  322
+google.maps.Polyline.prototype.SphericalPolygonArea  = google.maps.Polygon.prototype.SphericalPolygonArea
  323
+
  324
+
519  delay_simulation/js/helper.js
... ...
@@ -0,0 +1,519 @@
  1
+segments_normal = [];
  2
+segments_delay = [];
  3
+//for(var i=0;i<Segments.length;i++)
  4
+    //Segments[i]=0;
  5
+SegTrainList_normal = [];
  6
+SegTrainList_delay = [];
  7
+function updateSegments_normal(seg, tr_id){
  8
+    var tmp;
  9
+    if (seg){
  10
+	for(i in seg){
  11
+	    //if(tr_id  == "18110" && seg[0]!=[]) alert(i + " : " + seg[i].seg_no + " : " + seg[i].seg_label);
  12
+	    if(seg[i].seg_label==0){
  13
+		if( SegTrainList_normal[seg[i].seg_no].indexOf(tr_id)==-1){
  14
+		    segments_normal[seg[i].seg_no]++;Ccolor_normal(seg[i].seg_no);
  15
+		    SegTrainList_normal[seg[i].seg_no].push(tr_id);
  16
+		}else alert(tr_id+"Train already present. "+SegTrainList_normal[seg[i].seg_no]);
  17
+	    }
  18
+	    
  19
+	    if(seg[i].seg_label==2){
  20
+		if((tmp=SegTrainList_normal[seg[i].seg_no].indexOf(tr_id))>-1){
  21
+		    SegTrainList_normal[seg[i].seg_no].splice(tmp, 1);
  22
+		    segments_normal[seg[i].seg_no]--;
  23
+		    Ccolor_normal(seg[i].seg_no);
  24
+		}else alert(tr_id +"Train is not Found. " + SegTrainList_normal[seg[i].seg_no]+" " + tmp);
  25
+	    }
  26
+	}
  27
+    }
  28
+}
  29
+
  30
+function updateSegments_delay(seg, tr_id){
  31
+    var tmp;
  32
+    if (seg){
  33
+	for(i in seg){
  34
+	    //if(tr_id  == "18110" && seg[0]!=[]) alert(i + " : " + seg[i].seg_no + " : " + seg[i].seg_label);
  35
+	    if(seg[i].seg_label==0){
  36
+		if( SegTrainList_delay[seg[i].seg_no].indexOf(tr_id)==-1){
  37
+		    segments_delay[seg[i].seg_no]++;Ccolor_delay(seg[i].seg_no);
  38
+		    SegTrainList_delay[seg[i].seg_no].push(tr_id);
  39
+		}else alert(tr_id+"Train already present. "+SegTrainList_delay[seg[i].seg_no]);
  40
+	    }
  41
+	    
  42
+	    if(seg[i].seg_label==2){
  43
+		if((tmp=SegTrainList_delay[seg[i].seg_no].indexOf(tr_id))>-1){
  44
+		    SegTrainList_delay[seg[i].seg_no].splice(tmp, 1);
  45
+		    segments_delay[seg[i].seg_no]--;
  46
+		    Ccolor_delay(seg[i].seg_no);
  47
+		}else alert(tr_id +"Train is not Found. " + SegTrainList_delay[seg[i].seg_no]+" " + tmp);
  48
+	    }
  49
+	}
  50
+    }
  51
+}
  52
+
  53
+function async_update_normal(seg, tr_id){
  54
+    var tmp;
  55
+    var i;
  56
+    if (seg){
  57
+		for(i in seg){
  58
+			//if(tr_id  == "18110" && seg[0]!=[]) alert(i + " : " + seg[i].seg_no + " : " + seg[i].seg_label);
  59
+			if(seg[i].seg_label!=2)
  60
+			{
  61
+				if( SegTrainList_normal[seg[i].seg_no].indexOf(tr_id)==-1)
  62
+				{
  63
+					segments_normal[seg[i].seg_no]++;Ccolor_normal(seg[i].seg_no);
  64
+					SegTrainList_normal[seg[i].seg_no].push(tr_id);
  65
+				}
  66
+			}
  67
+		}
  68
+	}
  69
+}
  70
+
  71
+function async_update_delay(seg, tr_id){
  72
+    var tmp;
  73
+    var i;
  74
+    if (seg){
  75
+		for(i in seg){
  76
+			//if(tr_id  == "18110" && seg[0]!=[]) alert(i + " : " + seg[i].seg_no + " : " + seg[i].seg_label);
  77
+			if(seg[i].seg_label!=2){
  78
+				if( SegTrainList_delay[seg[i].seg_no].indexOf(tr_id)==-1){
  79
+				segments_delay[seg[i].seg_no]++;Ccolor_delay(seg[i].seg_no);
  80
+				SegTrainList_delay[seg[i].seg_no].push(tr_id);
  81
+				}
  82
+			}
  83
+		}
  84
+	}
  85
+}
  86
+
  87
+var WeekDays = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"];
  88
+function Train(train, mode){
  89
+    this.reInitialize = function(){
  90
+	this.finished = 1;
  91
+	this.cur_stn = 0;
  92
+	this.startedAt=0;
  93
+	this.day=0;
  94
+    }
  95
+
  96
+    this.Initialize = function(mode){
  97
+	this.mode = mode;
  98
+	this.id = train.tr_id;
  99
+	this.stn_list = train.stn_list;
  100
+	var l = this.stn_list.length;
  101
+	this.stn_list[l-1].sch_dep = this.stn_list[l-1].sch_arr;
  102
+	/*
  103
+	this.daysRun = [];
  104
+	for(i in WeekDays){
  105
+	    if(train.days.indexOf(WeekDays[i]) != 1)
  106
+		this.daysRun[i] = 1;
  107
+	    else this.daysRun[i] = 0;
  108
+	}
  109
+	*/	
  110
+	this.reInitialize();
  111
+    }
  112
+    this.Initialize(mode);
  113
+
  114
+    this.start = function(c){
  115
+	
  116
+	//if(this.daysRun[Math.floor(c/1440)%7] == 1){
  117
+	    if(c%1440 > this.stn_list[0].sch_dep){
  118
+		this.day=0;
  119
+		this.startedAt = c;
  120
+		if(this.mode == 1)
  121
+			updateSegments_normal(this.stn_list[0].seg_list, this.id);
  122
+		else if(this.mode == 2)
  123
+			updateSegments_delay(this.stn_list[0].seg_list, this.id);
  124
+		this.cur_stn++;
  125
+		//if(this.id=="18110") alert("Starting again" + c/1440);
  126
+		//		this.	move(c);
  127
+	    }
  128
+	//}
  129
+	
  130
+    }
  131
+    
  132
+    this.move = function(c){
  133
+	if(this.cur_stn==0 && this.finished==1) {
  134
+	    this.start(c); return;
  135
+	}
  136
+	var s = this.cur_stn;
  137
+	t = this.day*1440 + this.stn_list[s].sch_dep - this.stn_list[0].sch_dep
  138
+	if(t < c-this.startedAt){
  139
+	    if (s==this.stn_list.length-1){
  140
+		this.finished = 1;
  141
+	    }
  142
+	    if(this.mode == 1)
  143
+			updateSegments_normal(this.stn_list[s].seg_list, this.id);
  144
+		else if(this.mode == 2)
  145
+			updateSegments_delay(this.stn_list[s].seg_list, this.id);
  146
+	    if(this.cur_stn<this.stn_list-1 && this.stn_list[this.cur_stn+1].sch_dep < this.stn_list[this.cur_stn].sch_dep){
  147
+		this.day++;
  148
+		if(this.id=="18110") alert("Day: "+ this.day);
  149
+	    }
  150
+	    this.cur_stn = (this.cur_stn+1)%this.stn_list.length;
  151
+	    //	    this.move(c);
  152
+	}
  153
+    }
  154
+    this.move_async = function(c){
  155
+		var s = 0;
  156
+		var g = 0;
  157
+		for(s = 0; s < this.stn_list.length; s++)
  158
+		{
  159
+			var t = this.stn_list[s].sch_dep - c;
  160
+			if(t>0)
  161
+			{
  162
+				if(s!=0)
  163
+				{
  164
+					if(this.mode == 1)
  165
+						async_update_normal(this.stn_list[s-1].seg_list, this.id);
  166
+					else if(this.mode == 2)
  167
+						async_update_delay(this.stn_list[s-1].seg_list, this.id);
  168
+					break;
  169
+				}
  170
+			}
  171
+		}
  172
+	}
  173
+};
  174
+
  175
+var Segments, Trains_normal=[], Trains_delay = [];
  176
+$.getJSON("data/NewTrainStationWSegmentsWDays.min.json", function(json) {
  177
+	T = eval(json);
  178
+	for( i in T.trains){
  179
+	    Trains_normal[i] = new Train(T.trains[i].train, 1);
  180
+	}
  181
+    });
  182
+$.getJSON("data/NewTrainStationDetailWDelayWSegments.json", function(json) {
  183
+	T = eval(json);
  184
+	for( i in T){
  185
+	    Trains_delay[i] = new Train(T[i].train, 2)
  186
+	}
  187
+    });
  188
+$.getJSON("data/segments.js", function(json) {
  189
+	T = eval(json);
  190
+	Segments = T.segments;
  191
+	Initialize();
  192
+    });
  193
+var segNames = [];
  194
+$.getJSON("data/segmentName.js", function(json) {
  195
+	T = eval(json);
  196
+	segNames = T.segNames;
  197
+    });
  198
+
  199
+function viewAsyncTraffic()
  200
+{
  201
+	Initialize();
  202
+	var i;
  203
+	for(i=0;i<Trains_normal.length;i++)
  204
+	{
  205
+		Trains_normal[i].move_async(clock);
  206
+	}
  207
+	for(i=0;i<Trains_normal.length;i++)
  208
+	{
  209
+		Trains_delay[i].move_async(clock);
  210
+	}		
  211
+	var s = 0; 
  212
+	for( i in segments_normal) s+= segments_normal[i];
  213
+    $("#SegTot_normal").html("Total running trains(MAP_NORMAL): " + s);
  214
+    
  215
+    s = 0; 
  216
+    for( i in segments_delay) s+= segments_delay[i];
  217
+    $("#SegTot_delay").html("Total running trains(MAP_DELAY) : " + s);
  218
+    
  219
+    busy3high_normal();
  220
+    busy3high_delay();
  221
+}
  222
+	
  223
+function Ccolor_normal(i){
  224
+    c = segments_normal[i];
  225
+    if (i in poly_seg_normal)   
  226
+	//poly_seg[i].setOptions({strokeColor: 'blue'});
  227
+	poly_seg_normal[i].setOptions({strokeWeight: (c/3) });
  228
+}
  229
+	
  230
+function Ccolor_delay(i){
  231
+    c = segments_delay[i];
  232
+    if (i in poly_seg_delay)   
  233
+	//poly_seg[i].setOptions({strokeColor: 'blue'});
  234
+	poly_seg_delay[i].setOptions({strokeWeight: (c/3) });
  235
+}
  236
+
  237
+poly_seg_normal = [];
  238
+poly_seg_delay = [];
  239
+function Initialize() {
  240
+    stop = 1;
  241
+    var myOptions = {
  242
+	center: new google.maps.LatLng(22.5, 82),
  243
+	zoom: 5,
  244
+	mapTypeId: google.maps.MapTypeId.ROADMAP
  245
+    };
  246
+    map_normal = new google.maps.Map(document.getElementById("map_normal"), myOptions);
  247
+    map_delay = new google.maps.Map(document.getElementById("map_delay"), myOptions);
  248
+    var c = [23,34,12];
  249
+    for(i=0;i<Segments.length;i++){
  250
+	segments_normal[i] = 0;
  251
+	SegTrainList_normal[i] = [];
  252
+	segments_delay[i] = 0;
  253
+	SegTrainList_delay[i] = [];
  254
+	var tmp = [];
  255
+	for(j in Segments[i].segment.seg_list)
  256
+	    tmp[j] = new google.maps.LatLng(
  257
+					    Segments[i].segment.seg_list[j].lat, 
  258
+					    Segments[i].segment.seg_list[j].lng
  259
+					    );
  260
+	//alert(tmp);
  261
+	var color = '#' + c[0].toString(16)+c[1].toString(16)+c[2].toString(16);
  262
+	c[i%3] = 100 + (c[i%3]*2) % 100;
  263
+	poly_seg_normal[i] = new google.maps.Polyline({
  264
+		path: tmp,  
  265
+		strokeColor: color,  
  266
+		strokeOpacity: 1.0,  
  267
+		strokeWeight: 2, 
  268
+		map: map_normal
  269
+	    });
  270
+    
  271
+    poly_seg_delay[i] = new google.maps.Polyline({
  272
+		path: tmp,  
  273
+		strokeColor: color,  
  274
+		strokeOpacity: 1.0,  
  275
+		strokeWeight: 2, 
  276
+		map: map_delay
  277
+	    });
  278
+    }
  279
+}
  280
+last = 0;clock=0;
  281
+
  282
+/*
  283
+function Update(t,c){
  284
+    for(i=0;i<Trains_normal.length;i++){
  285
+		Trains_normal[i].move(clock);
  286
+	}
  287
+	for(i=0;i<Trains_delay.length;i++){
  288
+		Trains_delay[i].move(clock);
  289
+	}
  290
+    clock+=20;c+=20;
  291
+    //setTimeout("animate(0)",0);
  292
+    updateClock();
  293
+    setTimeout("Update("+t+","+c+")", 5)
  294
+}
  295
+
  296
+function setStartPoint1(t){
  297
+    $("#time-line").html(Math.floor(t/60) + "::" + t%60);
  298
+    var c = clock%1440;
  299
+    if(t<c) {t+=1440;}
  300
+    for(i=0;i<Trains.length;i++)
  301
+	Trains[i].move(clock);
  302
+    clock+=20;c+=20;
  303
+    //setTimeout("animate(0)",0);
  304
+	updateClock();
  305
+}
  306
+function setStartPoint(t){
  307
+    $("#time-line").html(Math.floor(t/60) + "::" + t%60);
  308
+    var c = clock%1440;
  309
+    if(t<c) {t+=1440;}
  310
+    while(t<c){
  311
+	for(i=0;i<Trains.length/100;i++)
  312
+	    Trains[i].move(clock);
  313
+	clock+=20;c+=20;
  314
+    }
  315
+    updateClock();
  316
+}
  317
+*/
  318
+
  319
+function showValue(value){
  320
+    $("#timeScale").html(value);
  321
+    t_incr = parseInt(value);
  322
+    //    alert(t_incr);
  323
+}
  324
+
  325
+function showValueTime(value){
  326
+	$("#time-line").html(value);	
  327
+}
  328
+
  329
+function setTime(){
  330
+	var str = $("#time-line").html();
  331
+	var t = str.split("::");
  332
+	clock = parseInt(t[0])*60 + parseInt(t[1]) - t_incr;
  333
+	updateClock();
  334
+}
  335
+
  336
+function setOpacity(value) {
  337
+    var t = $("#overlay_normal");
  338
+    t.css("opacity", value);
  339
+    t = $("#overlay_delay");
  340
+    t.css("opacity", value);
  341
+    //    t.style.filter = 'alpha(opacity=' + value*10 + ')';
  342
+}
  343
+
  344
+function reset(){
  345
+	Initialize();
  346
+    $("#SegTot_normal").html("Total running trains(MAP_NORMAL): 0");
  347
+    $("#SegTot_delay").html("Total running trains(MAP_DELAY) : 0");
  348
+    stop=1;
  349
+    document.getElementById("range").value = 6;
  350
+    showValue(6);
  351
+    clock=-t_incr;
  352
+    updateClock();
  353
+    var i;
  354
+    for(i=0;i<Segments.length;i++){
  355
+	segments_normal[i] = 0;
  356
+	segments_delay[i] = 0;
  357
+	SegTrainList_normal[i] = [];
  358
+	SegTrainList_delay[i] = [];
  359
+    }
  360
+    for(i=0;i<Trains_normal.length;i++){
  361
+        Trains_normal[i].reInitialize();
  362
+        //marker[i].setPosition(Trains[i].ptset[Trains[i].cur_stn]);
  363
+    }
  364
+    for(i=0;i<Trains_delay.length;i++){
  365
+        Trains_delay[i].reInitialize();
  366
+        //marker[i].setPosition(Trains[i].ptset[Trains[i].cur_stn]);
  367
+    }
  368
+}
  369
+
  370
+function updateClock(){
  371
+    clock+=t_incr;
  372
+    var d = Math.floor(clock/1440);
  373
+    var h = Math.floor((clock%1440)/60);
  374
+    var m = clock%60;
  375
+    document.getElementById("time").innerHTML = "<b>Time</b>(day:hr::min)&nbsp " + d + " :: " + h + " :: " + m;
  376
+    var value;
  377
+    value = 0.3 + 0.3 * Math.cos(h*3.141/12);
  378
+    setOpacity(value);
  379
+}
  380
+
  381
+var incr = 10;
  382
+var tick = 50;
  383
+var t_incr = 6;
  384
+var stop=1;
  385
+function animate(d) {
  386
+    if(stop==1) {return;}
  387
+    var i;
  388
+    for(i=0;i<Trains_normal.length;i++){
  389
+        Trains_normal[i].move(clock);
  390
+    }
  391
+    for(i=0;i<Trains_delay.length;i++){
  392
+        Trains_delay[i].move(clock);
  393
+    }
  394
+    updateClock();
  395
+    setTimeout("animate("+(d+incr)+")", tick);
  396
+    //setTimeout("showGraph()", tick*30);
  397
+    var s = 0; 
  398
+    for( i in segments_normal) s+= segments_normal[i];
  399
+    $("#SegTot_normal").html("Total running trains(MAP_NORMAL): " + s);
  400
+    s = 0; for( i in segments_delay) s+= segments_delay[i];
  401
+    $("#SegTot_delay").html("Total running trains(MAP_DELAY) : " + s);
  402
+}
  403
+//marker = [];
  404
+function start() {
  405
+    s = $("#anim").html();
  406
+    if(s=="Pause"){
  407
+	stop=1;
  408
+	//showGraph();
  409
+	$("#anim").html("Start");
  410
+    }
  411
+    else if(s=="Start"){
  412
+	$("#anim").html("Pause");
  413
+	stop=0;
  414
+	setTimeout("animate(0)",0);
  415
+    }
  416
+}
  417
+
  418
+function showGraph(){
  419
+    $(function () 
  420
+      {
  421
+	  var d1 = [];
  422
+	  for (i in segments )
  423
+	      d1.push([i, segments[i]]);
  424
+	  $.plot($("#placeholder"), 
  425
+		 [{ data: d1, bars: { show: true }}]);
  426
+      });
  427
+}
  428
+
  429
+function search(v){
  430
+    v = parseInt(v);
  431
+    if(v in segments){
  432
+	var s = Segments[v].segment;
  433
+	t = "<b>Name</b>: "+ s.seg_name + "<br/>";
  434
+	t+=segNames[v].list.join("->")+"<br/>";
  435
+	t+= "<b>Number of Trains</b>: " + segments[v];
  436
+	$("#segInfo").html(t);
  437
+    }
  438
+}
  439
+
  440
+function search_seg(v){
  441
+	v = parseInt(v);
  442
+	if(v in segments){
  443
+		var s = Segments[v].segment;
  444
+		$("#segName").html("Segment Name: " + s.seg_name);
  445
+		$("#segInfo").html("Number of Running Trains: " + segments[v]);
  446
+	}
  447
+}
  448
+
  449
+function busy3high_normal(){
  450
+	var busy1_name, busy2_name, busy3_name;
  451
+	var busy1_info = 0, busy2_info = 0, busy3_info = 0;
  452
+	var i;
  453
+	for(i in segments_normal)
  454
+	{
  455
+		if(segments_normal[i] > busy1_info)
  456
+		{
  457
+			busy1_info = segments_normal[i];
  458
+			var s = Segments[i].segment;
  459
+			busy1_name = s.seg_name;
  460
+		}		
  461
+	}
  462
+	for(i in segments_normal)
  463
+	{
  464
+		if(segments_normal[i] > busy2_info && segments_normal[i] < busy1_info)
  465
+		{
  466
+			busy2_info = segments_normal[i];
  467
+			var s = Segments[i].segment;
  468
+			busy2_name = s.seg_name;
  469
+		}		
  470
+	}
  471
+	for(i in segments_normal)
  472
+	{
  473
+		if(segments_normal[i] > busy3_info && segments_normal[i] < busy2_info)
  474
+		{
  475
+			busy3_info = segments_normal[i];
  476
+			var s = Segments[i].segment;
  477
+			busy3_name = s.seg_name;
  478
+		}		
  479
+	}
  480
+	$("#busy1_normal").html("1. " + busy1_name + "\t" + busy1_info);
  481
+	$("#busy2_normal").html("2. " + busy2_name + "\t" + busy2_info);
  482
+	$("#busy3_normal").html("3. " + busy3_name + "\t" + busy3_info);
  483
+}
  484
+
  485
+function busy3high_delay(){
  486
+	var busy1_name, busy2_name, busy3_name;
  487
+	var busy1_info = 0, busy2_info = 0, busy3_info = 0;
  488
+	var i;
  489
+	for(i in segments_delay)
  490
+	{
  491
+		if(segments_delay[i] > busy1_info)
  492
+		{
  493
+			busy1_info = segments_delay[i];
  494
+			var s = Segments[i].segment;
  495
+			busy1_name = s.seg_name;
  496
+		}		
  497
+	}
  498
+	for(i in segments_delay)
  499
+	{
  500
+		if(segments_delay[i] > busy2_info && segments_delay[i] < busy1_info)
  501
+		{
  502
+			busy2_info = segments_delay[i];
  503
+			var s = Segments[i].segment;
  504
+			busy2_name = s.seg_name;
  505
+		}		
  506
+	}
  507
+	for(i in segments_delay)
  508
+	{
  509
+		if(segments_delay[i] > busy3_info && segments_delay[i] < busy2_info)
  510
+		{
  511
+			busy3_info = segments_delay[i];
  512
+			var s = Segments[i].segment;
  513
+			busy3_name = s.seg_name;
  514
+		}		
  515
+	}
  516
+	$("#busy1_delay").html("1. " + busy1_name + "\t" + busy1_info);
  517
+	$("#busy2_delay").html("2. " + busy2_name + "\t" + busy2_info);
  518
+	$("#busy3_delay").html("3. " + busy3_name + "\t" + busy3_info);
  519
+}

No commit comments for this range

Something went wrong with that request. Please try again.