-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRegions.py
475 lines (370 loc) · 12.3 KB
/
Regions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
def BTAsiaPacific_Region():
"""Returns the nodes, midpoint and region name for BT Asia Pacific Region.
Returns:
nodes (dict): Dictionary of nodes with their details.
midpoint (dict): Dictionary of midpoint with its details.
region_name (str): Name of the region.
"""
nodes = {}
# Jakarta
nodes["Jakarta"] = {}
nodes["Jakarta"]["Country"] = "Indonesia"
nodes["Jakarta"]["Longitude"] = 106.84513
nodes["Jakarta"]["Latitude"] = -6.21462
# Perth
nodes["Perth"] = {}
nodes["Perth"]["Country"] = "Australia"
nodes["Perth"]["Longitude"] = 115.83333
nodes["Perth"]["Latitude"] = -31.93333
# Singapore
nodes["Singapore"] = {}
nodes["Singapore"]["Country"] = "Singapore"
nodes["Singapore"]["Longitude"] = 103.85007
nodes["Singapore"]["Latitude"] = 1.28967
# Kuala Lumpur
nodes["Kuala Lumpur"] = {}
nodes["Kuala Lumpur"]["Country"] = "Malaysia"
nodes["Kuala Lumpur"]["Longitude"] = 101.68653
nodes["Kuala Lumpur"]["Latitude"] = 3.1412
# Sydney
nodes["Sydney"] = {}
nodes["Sydney"]["Country"] = "Australia"
nodes["Sydney"]["Longitude"] = 151.20732
nodes["Sydney"]["Latitude"] = -33.86785
# Auckland
nodes["Auckland"] = {}
nodes["Auckland"]["Country"] = "New Zealand"
nodes["Auckland"]["Longitude"] = 174.76667
nodes["Auckland"]["Latitude"] = -36.86667
# New Delhi
nodes["New Delhi"] = {}
nodes["New Delhi"]["Country"] = "India"
nodes["New Delhi"]["Longitude"] = 77.22445
nodes["New Delhi"]["Latitude"] = 28.63576
# Mumbai
nodes["Mumbai"] = {}
nodes["Mumbai"]["Country"] = "India"
nodes["Mumbai"]["Longitude"] = 72.84794
nodes["Mumbai"]["Latitude"] = 19.01441
# Seoul
nodes["Seoul"] = {}
nodes["Seoul"]["Country"] = "South Korea"
nodes["Seoul"]["Longitude"] = 126.97783
nodes["Seoul"]["Latitude"] = 37.56826
# Tokyo
nodes["Tokyo"] = {}
nodes["Tokyo"]["Country"] = "Japan"
nodes["Tokyo"]["Longitude"] = 139.5813
nodes["Tokyo"]["Latitude"] = 35.61488
# Taipei
nodes["Taipei"] = {}
nodes["Taipei"]["Country"] = "Taiwan"
nodes["Taipei"]["Longitude"] = 121.53185
nodes["Taipei"]["Latitude"] = 25.04776
# Hong Kong
nodes["Hong Kong"] = {}
nodes["Hong Kong"]["Country"] = "Hong Kong"
nodes["Hong Kong"]["Longitude"] = 114.15769
nodes["Hong Kong"]["Latitude"] = 22.28552
# Manila
nodes["Manila"] = {}
nodes["Manila"]["Country"] = "Philippines"
nodes["Manila"]["Longitude"] = 120.9822
nodes["Manila"]["Latitude"] = 14.6042
# Bangkok
nodes["Bangkok"] = {}
nodes["Bangkok"]["Country"] = "Thailand"
nodes["Bangkok"]["Longitude"] = 100.51667
nodes["Bangkok"]["Latitude"] = 13.75
# Chenai
nodes["Chenai"] = {}
nodes["Chenai"]["Country"] = "India"
nodes["Chenai"]["Longitude"] = 80.27847
nodes["Chenai"]["Latitude"] = 13.08784
# Mumbai
nodes["Mumbai"] = {}
nodes["Mumbai"]["Country"] = "India"
nodes["Mumbai"]["Longitude"] = 72.84794
nodes["Mumbai"]["Latitude"] = 19.01441
# Assigning Node ID
i = 1
for name in nodes:
nodes[name]["Node ID"] = i
i += 1
# Mid-Point
midpoint = {}
midpoint["Label"] = "Banda Sea"
midpoint["Longitude"] = 124.568393
midpoint["Latitude"] = -2.539676
# Region Name
region_name = "BT Asia Pacific"
return nodes, midpoint, region_name
def Quest_Region():
"""Returns the nodes, midpoint and region name for Quest Region.
Returns:
nodes (dict): Dictionary of nodes with their details.
midpoint (dict): Dictionary of midpoint with its details.
region_name (str): Name of the region.
"""
nodes = {}
file = open("F:\Python Programming\IEEE Task\QUEST_Region_Nodes.txt", "r")
lines = file.readlines()
for i in range(0, len(lines), 8):
if "node" in lines[i]:
name = lines[i+2].split()[1].replace("\"", "")
nodes[name] = {}
country = lines[i+3].split()[1].replace("\"", "")
nodes[name]["Country"] = country
long = float(lines[i+4].split()[1])
nodes[name]["Longitude"] = long
lat = float(lines[i+6].split()[1])
nodes[name]["Latitude"] = lat
# Assigning Node ID
i = 1
for name in nodes:
nodes[name]["Node ID"] = i
i += 1
# Mid-Point
midpoint = {}
midpoint["Label"] = "Nagpur"
midpoint["Longitude"] = -172.854899
midpoint["Latitude"] = 34.782258
# Region Name
region_name = "QUEST"
return nodes, midpoint, region_name
def TATA_Region():
"""Returns the nodes, midpoint and region name for TATA Region.
Returns:
nodes (dict): Dictionary of nodes with their details.
midpoint (dict): Dictionary of midpoint with its details.
region_name (str): Name of the region.
"""
nodes = {}
file = open("F:\Python Programming\IEEE Task\TATA_Region_Nodes.txt", "r")
lines = file.readlines()
# Extracting Nodes from the file
for i in range(0, len(lines), 8):
if "node" in lines[i]:
name = lines[i+2].split()[1].replace("\"", "")
nodes[name] = {}
country = lines[i+3].split()[1].replace("\"", "")
nodes[name]["Country"] = country
long = float(lines[i+4].split()[1])
nodes[name]["Longitude"] = long
lat = float(lines[i+6].split()[1])
nodes[name]["Latitude"] = lat
# Assigning Node ID
i = 1
for name in nodes:
nodes[name]["Node ID"] = i
i += 1
# Mid-Point
midpoint = {}
midpoint["Label"] = "Nagpur"
midpoint["Longitude"] = 79.0809
midpoint["Latitude"] = 21.1467
# Region Name
region_name = "TATA"
return nodes, midpoint, region_name
def ERNET_Region():
"""Returns the nodes, midpoint and region name for ERNET Region.
Returns:
nodes (dict): Dictionary of nodes with their details.
midpoint (dict): Dictionary of midpoint with its details.
region_name (str): Name of the region.
"""
nodes = {}
# Pune
nodes["Pune"] = {}
nodes["Pune"]["Country"] = "India"
nodes["Pune"]["Longitude"] = 73.85535
nodes["Pune"]["Latitude"] = 18.51957
# Indore
nodes["Indore"] = {}
nodes["Indore"]["Country"] = "India"
nodes["Indore"]["Longitude"] = 75.8333
nodes["Indore"]["Latitude"] = 22.71792
# Trivandrum
nodes["Trivandrum"] = {}
nodes["Trivandrum"]["Country"] = "India"
nodes["Trivandrum"]["Longitude"] = 76.91667
nodes["Trivandrum"]["Latitude"] = 8.48333
# Mumbai
nodes["Mumbai"] = {}
nodes["Mumbai"]["Country"] = "India"
nodes["Mumbai"]["Longitude"] = 72.84794
nodes["Mumbai"]["Latitude"] = 19.01441
# Ahmedabad
nodes["Ahmedabad"] = {}
nodes["Ahmedabad"]["Country"] = "India"
nodes["Ahmedabad"]["Longitude"] = 72.61667
nodes["Ahmedabad"]["Latitude"] = 23.03333
# Jaipur
nodes["Jaipur"] = {}
nodes["Jaipur"]["Country"] = "India"
nodes["Jaipur"]["Longitude"] = 75.81667
nodes["Jaipur"]["Latitude"] = 26.91667
# Chennai
nodes["Chennai"] = {}
nodes["Chennai"]["Country"] = "India"
nodes["Chennai"]["Longitude"] = 80.27847
nodes["Chennai"]["Latitude"] = 13.08784
# Bengaluru
nodes["Bengaluru"] = {}
nodes["Bengaluru"]["Country"] = "India"
nodes["Bengaluru"]["Longitude"] = 77.60329
nodes["Bengaluru"]["Latitude"] = 12.97623
# Delhi
nodes["Delhi"] = {}
nodes["Delhi"]["Country"] = "India"
nodes["Delhi"]["Longitude"] = 77.22445
nodes["Delhi"]["Latitude"] = 28.63576
# Guwahati
nodes["Guwahati"] = {}
nodes["Guwahati"]["Country"] = "India"
nodes["Guwahati"]["Longitude"] = 91.75095
nodes["Guwahati"]["Latitude"] = 26.18617
# Gorakhpur
nodes["Gorakhpur"] = {}
nodes["Gorakhpur"]["Country"] = "India"
nodes["Gorakhpur"]["Longitude"] = 75.68333
nodes["Gorakhpur"]["Latitude"] = 29.45
# Kanpur
nodes["Kanpur"] = {}
nodes["Kanpur"]["Country"] = "India"
nodes["Kanpur"]["Longitude"] = 80.35
nodes["Kanpur"]["Latitude"] = 26.46667
# Allahabad
nodes["Kanpur"] = {}
nodes["Kanpur"]["Country"] = "India"
nodes["Kanpur"]["Longitude"] = 81.85
nodes["Kanpur"]["Latitude"] = 25.45
# Kalkota
nodes["Kalkota"] = {}
nodes["Kalkota"]["Country"] = "India"
nodes["Kalkota"]["Longitude"] = 88.36972
nodes["Kalkota"]["Latitude"] = 22.56972
# Bhubaneswar
nodes["Bhubaneswar"] = {}
nodes["Bhubaneswar"]["Country"] = "India"
nodes["Bhubaneswar"]["Longitude"] = 85.83333
nodes["Bhubaneswar"]["Latitude"] = 20.23333
# Hyderabad
nodes["Hyderabad"] = {}
nodes["Hyderabad"]["Country"] = "India"
nodes["Hyderabad"]["Longitude"] = 78.47444
nodes["Hyderabad"]["Latitude"] = 17.37528
# Assigning Node ID
i = 1
for name in nodes:
nodes[name]["Node ID"] = i
i += 1
# Mid-Point
midpoint = {}
midpoint["Label"] = "Nagpur"
midpoint["Longitude"] = 79.0809
midpoint["Latitude"] = 21.1467
# Region Name
region_name = "ERNET"
return nodes, midpoint, region_name
def PERN_Region():
"""Returns the nodes, midpoint and region name for PERN Region.
Returns:
nodes (dict): Dictionary of nodes with their details.
midpoint (dict): Dictionary of midpoint with its details.
region_name (str): Name of the region.
"""
nodes = {}
# Peshawar
nodes["Peshawar"] = {}
nodes["Peshawar"]["Country"] = "Pakistan"
nodes["Peshawar"]["Longitude"] = 71.58018
nodes["Peshawar"]["Latitude"] = 34.00837
# Karachi
nodes["Karachi"] = {}
nodes["Karachi"]["Country"] = "Pakistan"
nodes["Karachi"]["Longitude"] = 67.0822
nodes["Karachi"]["Latitude"] = 24.9056
# Faisalabad
nodes["Faisalabad"] = {}
nodes["Faisalabad"]["Country"] = "Pakistan"
nodes["Faisalabad"]["Longitude"] = 73.08333
nodes["Faisalabad"]["Latitude"] = 31.41667
# Quetta
nodes["Quetta"] = {}
nodes["Quetta"]["Country"] = "Pakistan"
nodes["Quetta"]["Longitude"] = 67.0125
nodes["Quetta"]["Latitude"] = 30.18722
# Lahore
nodes["Lahore"] = {}
nodes["Lahore"]["Country"] = "Pakistan"
nodes["Lahore"]["Longitude"] = 74.34361
nodes["Lahore"]["Latitude"] = 31.54972
# Abbottabad
nodes["Abbottabad"] = {}
nodes["Abbottabad"]["Country"] = "Pakistan"
nodes["Abbottabad"]["Longitude"] = 73.21449
nodes["Abbottabad"]["Latitude"] = 34.14685
# Islamabad
nodes["Islamabad"] = {}
nodes["Islamabad"]["Country"] = "Pakistan"
nodes["Islamabad"]["Longitude"] = 73.04329
nodes["Islamabad"]["Latitude"] = 33.72148
# Assigning Node ID
i = 1
for name in nodes:
nodes[name]["Node ID"] = i
i += 1
# Mid-Point
midpoint = {}
midpoint["Label"] = "Banda Sea"
midpoint["Longitude"] = 73.260825
midpoint["Latitude"] = 29.195361
# Region Name
region_name = "PERN"
return nodes, midpoint, region_name
def getRegionName(region_number):
"""Returns the name of the region based on the region number.
Args:
region_number (int): Number of the region.
Returns:
region_name (str): Name of the region.
"""
if region_number == 1:
return "BT Asia Pacific"
elif region_number == 2:
return "Quest"
elif region_number == 3:
return "TATA"
elif region_number == 4:
return "ERNET"
elif region_number == 5:
return "PERN"
def getData():
choice = None
nodes = None
midpoint = None
region_name = None
print("Which Region?\n")
print("Region 1: BT Asia-Pacific")
print("Region 2: Quest")
print("Region 3: TATA")
print("Region 4: ERNET")
print("Region 5: PERN")
while True:
choice = int(input("Enter your choice (1-5): "))
if choice in range(1, 5+1):
break
else:
print("Invalid Choice. Enter again")
if choice == 1:
nodes, midpoint, region_name = BTAsiaPacific_Region()
elif choice == 2:
nodes, midpoint, region_name = Quest_Region()
elif choice == 3:
nodes, midpoint, region_name = TATA_Region()
elif choice == 4:
nodes, midpoint, region_name = ERNET_Region()
elif choice == 5:
nodes, midpoint, region_name = PERN_Region()
return nodes, midpoint, region_name