forked from fahimcsebuet/thesis_javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainScript.js
More file actions
193 lines (139 loc) · 4.3 KB
/
mainScript.js
File metadata and controls
193 lines (139 loc) · 4.3 KB
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
/**
* Created by milu on 11/18/15.
*/
$( document ).ready(function() {
console.log( "ready!" );
$('.selectpicker').selectpicker();
var map = initMap();
$('#run_button').click(function(){
console.log("Run Pressed");
var algorithm = $('#algo_selector').val();
runAlgorithm(map,algorithm);
});
$('#clear_button').click(function(){
map.clearMap();
});
$('#algo_selector').change(function(){
//console.log("ddd>>>");
if($(this).val()=="6"){
//console.log(">>>");
map.alter_path_select = true;
}
else{
map.alter_path_select = false;
}
});
$("#visited_button").click(function(){
if(global_graph){
global_graph.showVisitedNode(map);
}
});
cache_map();
$(".scroll").removeClass("scroll");
setupTitle();
console.log( "End!" );
});
function setupTitle(){
$(".title_container").empty();
var milu_link = '<a href="http://milubuet.pythonanywhere.com/">Lutfar Rahman Milu</a>';
var fahim_link = '<a href="http://www.linkedin.com/in/fahim-tahmid-chowdhury-01664a61">Fahim Tahmid Chowdhury</a>';
var combined_link = '<div>' + 'created by:' + milu_link + ' & ' + fahim_link + '</div>';
var title_text = 'Surveillance System of Dhaka City';
$(".title_container").html(title_text+combined_link);
}
function initMap(){
var map = new Map("OSM_Map");
map.initOSM();
map.setMidPoint(90.3989,23.7937,12);
map.setClickEvents();
return map;
}
function cache_map(){
$.get(node_list_url, function(data) {
console.log("node caching done ..." + data[0]);
}, 'text');
$.get(edge_list_dist_url, function(data) {
console.log("edge caching done ..."+ data[0]);
}, 'text');
}
function runAlgorithm(map,algorithm){
var style = map.getSampleStyle();
if(algorithm == "0"){
console.log("Select an algo..");
}
else if(algorithm == "1"){
console.log("Running Sample ....");
var sdata = map.getSampleDataforLineString();
GraphTest();
load_graph(map,after);
map.plotResult(sdata,style);
}
else if(algorithm == "2"){
if(map.s_lon == -1 || map.s_lat == -1 || map.d_lon == -1 || map.d_lat == -1){
alert("Select Source and Destination point!");
}
else{
console.log("Running Sample Dijkstra ....");
//simple_dijkstra(map);
var alg = new SimpleDijkstra(map);
alg.run();
global_graphA = global_graph;
}
}
else if(algorithm == "3"){
if(map.s_lon == -1 || map.s_lat == -1 || map.d_lon == -1 || map.d_lat == -1){
alert("Select Source and Destination point!");
}
else{
console.log("Running Sample Dijkstra ....");
//simple_dijkstra(map);
var alg = new CircularDijkstra(map);
alg.run();
}
}
else if(algorithm == "4"){
if(map.s_lon == -1 || map.s_lat == -1 || map.d_lon == -1 || map.d_lat == -1){
alert("Select Source and Destination point!");
}
else{
console.log("Running Sample Dijkstra ....");
//simple_dijkstra(map);
var alg = new BandDijkstra(map);
alg.run();
}
}
else if(algorithm == "5"){
if(map.s_lon == -1 || map.s_lat == -1 || map.d_lon == -1 || map.d_lat == -1){
alert("Select Source and Destination point!");
}
else{
console.log("Running AStar Search ....");
//simple_dijkstra(map);
var alg = new AStar(map);
alg.run();
global_graphA = global_graph;
}
}
else if(algorithm == "6"){
if(map.s_lon == -1 || map.s_lat == -1 || map.d_lon == -1 || map.d_lat == -1){
alert("Run dijkstra first!");
}
else{
console.log("Running Alter Path ....");
//simple_dijkstra(map);
var alg = new AlterPath(map);
alg.run();
}
}
else if(algorithm == "7"){
console.log("Showing Vertex Cover ....");
show_vertex_cover(map);
console.log("Showing Vertex Cover Ended ....");
}
else{
console.log("Unimplemented algo ....");
}
}
function after(graph){
console.log('callback....');
}