1// All functions which enable user's interaction with PDC Search interface are defined 2// Note: some functions require a parameter n to be passed in. 3// n simply indicates which map is currently active 4// 0 - the arctic map is active 5// 1 - the antarctic map is active 6// 2 - the "All Regions" tab is active, which doesn't contain a map 7// Return an integer indicating which map is actives 8function getActiveMapNumber() { 9 var activeTabId = layout.getRegion("center").getTabs().getActiveTab().id; 10 if (activeTabId == "arctic") { 11 return 0; 12 } 13 else if (activeTabId == "antarctic") { 14 return 1; 15 } 16 /* 17 else if (activeTabId == "gis_map") { 18 return 2; 19 } 20 */ 21 else { 22 return 5; 23 } 24 //return 2;//used to be -1 here when I edited on Feb 26th 2013 after I found out only 2 will make it "all regions - arctic and antarctic" ... 25} 26 27function clearSelection(n) { 28 selectionMarkerLayers[n].clearMarkers(); 29 30 //clean the info in lon and lat forms in search.jsp 31 for (var i = 0; i < 4; i++) { 32 var num = (i + 1).toString(); 33 document.getElementById("lon_" + num).value = ""; 34 document.getElementById("lat_" + num).value = ""; 35 } 36 37 //reset the check boxes to unchecked states 38 document.getElementById("showAvailable").checked = false; 39 document.getElementById("showMapData").checked = false; 40 41 42 polygonLayers[n].destroyFeatures(); 43 points.length = 0; 44 lonlats[n].length = 0; 45} 46 47function clearFootprints(n) { 48 //solve GIS tab problem 49 var activeTabId = layout.getRegion("center").getTabs().getActiveTab().id; 50 if ((activeTabId == "arctic") || (activeTabId == "antarctic")){ 51 52 if (resultsIdArrays[n].length > 0) { 53 for (var i = 0; i < resultsIdArrays[n].length; i ++) { 54 removeSelectionFromArray(resultsIdArrays[n][i]); 55 } 56 } 57 58 resultsLayers[n].destroyFeatures(); 59 resultsIdArrays[n].length = 0; 60 resultsVectorArrays[n].length = 0; 61 resultsMarkerArrays[n].length = 0; 62 briefPopupIdArrays[n].length = 0; 63 briefPopupContentArrays[n].length = 0; 64} 65} 66 67function clearResults() { 68 document.getElementById("results").src = ""; 69 document.getElementById("metadata").src = ""; 70 document.getElementById("Rdata").src = ""; 71 72 document.getElementById("freekey").value = ""; 73 document.getElementById("id").value = ""; 74 document.getElementById("CISsmonth").value = "month"; 75 document.getElementById("CISsday").value = "day"; 76 document.getElementById("CISsyear").value = "year"; 77 document.getElementById("rsmonth").value = "month"; 78 document.getElementById("rsday").value = "day"; 79 document.getElementById("rsyear").value = "year"; 80 document.getElementById("smonth").value = "month"; 81 document.getElementById("sday").value = "day"; 82 document.getElementById("syear").value = "year"; 83 document.getElementById("emonth").value = "month"; 84 document.getElementById("eday").value = "day"; 85 document.getElementById("eyear").value = "year"; 86 document.getElementById("remonth").value = "month"; 87 document.getElementById("reday").value = "day"; 88 document.getElementById("reyear").value = "year"; 89 document.getElementById("CISemonth").value = "month"; 90 document.getElementById("CISeday").value = "day"; 91 document.getElementById("CISeyear").value = "year"; 92 document.getElementById("direction").value = "Both"; 93 document.getElementById("beam").value = "ALL"; 94 95 document.getElementById("beam").value = "ALL"; 96 document.getElementById("startEndDate").value = "ALL"; 97 document.getElementById("bitMode").value = "ALL"; 98 document.getElementById("productType").value = "ALL"; 99 100 document.getElementById("chartType").value = "RegnlCharts"; 101 getChartYears(); 102 //document.getElementById("dataType").value = "ALL"; 103 104 //dldetailsearch 105 hide_advSrch_lines(); 106 document.getElementById("search_line").value = "0"; 107 //dldetailsearch end 108 layout.getRegion('east').getTabs().activate("search_div"); 109 layout.getRegion('east').getTabs().disableTab("results_div"); 110 layout.getRegion('east').getTabs().disableTab("R1_data"); 111 layout.getRegion('east').getTabs().disableTab("metadata_popup"); 112} 113 114function disableTabBeforeSearch(){ 115 layout.getRegion('east').getTabs().activate("search_div"); 116 layout.getRegion('east').getTabs().disableTab("results_div"); 117 layout.getRegion('east').getTabs().disableTab("R1_data"); 118 layout.getRegion('east').getTabs().disableTab("metadata_popup"); 119} 120 121function clearSearch(n) { 122 //May 24 2013 - we decided to clear foot prints in both maps when a clear is used in search form 123 clearSelection(0); 124 clearSelection(1); 125 clearFootprints(0); 126 clearFootprints(1); 127 clearResults(); 128 129 // YD version 4.1.1 clear search will zoom two maps to the same extent 130 131 maps[0].zoomToExtent(extentFrameForDisplay); 132 maps[1].zoomToExtent(extentFrameForDisplay); 133// document.getElementById('gismap').src = "./pdcgis.ccin"; 134} 135 136// Preprocess the search criteria and pass them to searchprocess1.0.jsp 137// Puts together the date as one day+month+year and points etc 138function goSearch(n) { 139 140 clearFootprints(0); 141 clearFootprints(1); 142 disableTabBeforeSearch(); 143// document.getElementById('gismap').src = "./pdcgis.ccin"; 144 checkCoords(n); 145 146 document.getElementById("metadata").src = ""; 147 document.getElementById("results").src = ""; 148 //this is mainly to clean the data download page from results from previous searches before loading new downloads for new search results 149 document.getElementById("Rdata").src = "./PDC_Metadata_Data_Download_WaitPage.ccin"; 150 var cat = document.getElementById("category").value; 151 var start_date, end_date; 152 var sm, sd, sy,em,ed,ey,rsm,rsd,rsy,rem,red,rey; 153 rsm =document.getElementById("rsmonth").value; 154 rsd = document.getElementById("rsday").value ; 155 rsy = document.getElementById("rsyear").value ; 156 sm = document.getElementById("smonth").value ; 157 sd = document.getElementById("sday").value ; 158 sy = document.getElementById("syear").value ; 159 em = document.getElementById("emonth").value ; 160 ed = document.getElementById("eday").value ; 161 ey = document.getElementById("eyear").value ; 162 rem = document.getElementById("remonth").value ; 163 red = document.getElementById("reday").value ; 164 rey = document.getElementById("reyear").value ; 165 166 CISsm = document.getElementById("CISsmonth").value ; 167 CISsd = document.getElementById("CISsday").value ; 168 CISsy = document.getElementById("CISsyear").value ; 169 CISem = document.getElementById("CISemonth").value ; 170 CISed = document.getElementById("CISeday").value ; 171 CISey = document.getElementById("CISeyear").value ; 172 173 // Format the dates 174 if(cat == "2") { 175 if (rsy == "year") { 176 rsm = "Jan"; rsd = "01"; rsy="1000"; 177 } 178 else { 179 if (rsm == "month") { rsm = "Jan";} 180 if (rsd == "day") { rsd = "1";} 181 } 182 183 if (rey == "year") { 184 rem = "Dec"; red = "31"; rey="4000"; 185 } 186 else { 187 if (rem == "month") { rem = "Dec";} 188 if (red == "day") { red = "28";} 189 } 190 start_date = new Date(rsm + " " + rsd + ", " + rsy); 191 end_date = new Date(rem + " " + red + ", " + rey); 192 } 193 else 194 if (cat== "1") {
195 if (sy == "year") { 196 sm = "Jan"; sd = "01"; sy="1000"; 197 } 198 else { 199 if (sm == "month") { sm = "Jan";} 200 if (sd == "day") { sd = "1";} 201 } 202 203 if (ey == "year") { 204 em = "Dec"; ed = "31"; ey="4000"; 205 } 206 else { 207 if (em == "month") { em = "Dec";} 208 if (ed == "day") { ed = "28";} 209 } 210 start_date = new Date(sm + " " + sd + ", " + sy); 211 end_date = new Date(em + " " + ed + ", " + ey); 212 } 213 else 214 if (cat== "4") { 215 // put the antarctic code here 216 } 217 else 218 { 219 if (CISsy == "year") { 220 CISsm = "Jan"; CISsd = "01"; CISsy="1000"; 221 } 222 else { 223 if (CISsm == "month") { CISsm = "Jan";} 224 if (CISsd == "day") { CISsd = "1";} 225 } 226 227 if (CISey == "year") { 228 CISem = "Dec"; CISed = "31"; CISey="4000"; 229 } 230 else { 231 if (CISem == "month") { CISem = "Dec";} 232 if (CISed == "day") { CISed = "28";} 233 } 234 start_date = new Date(CISsm + " " + CISsd + ", " + CISsy); 235 end_date = new Date(CISem + " " + CISed + ", " + CISey); 236 237 } 238 239 if (start_date > end_date) { 240 search_flag = false; 241 Ext.MessageBox.alert('Search Error', 'Your end date cannot be before your start date.'); 242 return; 243 } 244 245 clearFootprints(n); 246 247 248 var searchp = ""; 249 var useAOI = true; //use spatial coordinates - area of interest 250 var src; 251 var dest = projGlobal; 252 search_flag = true; 253 src = projArctic; 254 if (n == 0) { 255 src = projArctic; 256 } else if (n == 1) { 257 src = projAntarctic; 258 } 259 // error message for searching on gis tab 260 //Ext.MessageBox.alert('Search Error', 'Use the Arctic or Antartic tab to do a search'); 261 //return; 262 263 document.getElementById("searchform").target = "results"; 264 265 // solves search on GIS tab - when searching on GIS tab, the coordinates for searchp are entered manually 266 if (lonlats[n]===undefined) 267 {useAOI = false; 268 269 searchp = "125;40;35;35;-55;35;-145;35"; 270 } 271 272 else if (lonlats[n]!=undefined) 273 { 274 275 276 if (lonlats[n].length == 0) 277 { 278 //if values are filled in the form because of cache memory of browser 279 if (document.getElementById("lat_1").value != "") 280 { 281 Ext.MessageBox.alert('Search Error', 'Area of Interest from past search found. Use <b>Clear</b> button or press <b>Apply Changes</b> button before using <b>Search</b>.'); 282 return; 283 } 284 else 285 { 286 if (cat=="2") //Area of interest must be selected for RADARSAT-1 287 { 288 if (document.getElementById("lat_1").value == "") 289 { 290 Ext.MessageBox.alert('Search Error', 'Please select an area of interest.'); 291 return; 292 } 293 } 294 } 295 } 296 297 // 4 points need to be selected for the search... 1,2,3 points display error 298 299 if (lonlats[n].length == 3 || lonlats[n].length == 2 || lonlats[n].length == 1) { 300 Ext.MessageBox.alert('Search Error', 'Please select four points on map'); 301 clearSearch(n); 302 return; 303 } 304 305 // All Regions is selected 306 if (n==2 || lonlats[n].length != 4) { 307 useAOI = false; 308 } 309 310 // All Regions is not selected 311 // Searching either the arctic or antarctic regions for area of interest selected 312 if (useAOI == true) { 313 // If the user selects exactly 4 points on the arctic or antarctic map 314 for (var i = 0; i < lonlats[n].length; i ++) { 315 var point= new OpenLayers.Geometry.Point(lonlats[n][i].lon, lonlats[n][i].lat); 316 OpenLayers.Projection.transform(point, src, dest); 317 searchp += point.x.toString() + ";" + point.y.toString(); 318 319 if ( i < lonlats[n].length - 1) { 320 searchp += ";"; 321 } 322 } 323 // All Regions is not selected and Area of interest is also not selected 324 } else if (n != 2){ 325 // make sure only search within the boundaries of the arctic map or antarctic map 326 for (var i = 0; i < 4; i ++) { 327 var point= new OpenLayers.Geometry.Point(wholeMapLonlats[n][i].lon, wholeMapLonlats[n][i].lat); 328 searchp += point.x.toString() + ";" + point.y.toString(); 329 330 if ( i < 3) { 331 searchp += ";"; 332 } 333 } 334 } 335 } 336 337 document.getElementById("searchform").target = "results"; 338 activateResultsTab(); 339 document.getElementById("searchform").spoints.value = searchp; 340 document.getElementById("searchform").submit(); 341 342 return true; 343} 344 345function activateResultsTab() { 346 layout.getRegion("east").getTabs().getTab("results_div").enable(); 347 layout.getRegion('east').getTabs().activate("results_div"); 348} 349 350// quick key words search 351function goQuickSearch() { 352 353 document.getElementById("results").src = ""; 354 //this is mainly to clean the data download page from results from previous searches before loading new downloads for new search results 355 document.getElementById("Rdata").src = "./PDC_Metadata_Data_Download_WaitPage.ccin"; 356 document.getElementById("quick_form").target = "results"; 357 activateResultsTab(); 358 document.getElementById("quick_form").submit(); 359 return true; 360} 361 362//Apply any changes made manually by the user 363//Daniel: recreate lonlats list to reproject the points (inefficient) 364function getOutputPoints(n) { 365 var n = getActiveMapNumber(); 366 var src = projGlobal; 367 var dest= projArctic; 368 if (n == 0) { 369 dest = projArctic; 370 } else if (n == 1) { 371 dest = projAntarctic; 372 } 373 374//Freddy - compares coordinates on the form against tab active in order to display message if the values don't match with the correct projection 375 var latitude = []; 376 377 378 for (var i = 0; i < 4; i ++) { 379 var num = (i + 1).toString(); 380 var lon_value = document.getElementById("lon_" + num).value; 381 var lat_value = document.getElementById("lat_" + num).value; 382 latitude[i] = lat_value; 383 } 384 385 if (n == 1 && latitude[0] > 0 && latitude[1] > 0 && latitude[2] > 0 && latitude[3] > 0){ 386 Ext.MessageBox.alert('Search Error', 'Note: To update the Latitude/Longitude values to match the box on the map, please click the Update Points button in the right panel.'); 387 return; 388 389 } 390 else if (n == 0 && latitude[0] < 0 && latitude[1] < 0 && latitude[2] < 0 && latitude[3] < 0){ 391 Ext.MessageBox.alert('Search Error', 'Note: To update the Latitude/Longitude values to match the box on the map, please click the Update Points button in the right panel.'); 392 return; 393 } 394 395 396 lonlats[n].length = 0; 397 398 for (var i = 0; i < 4; i ++) { 399 var num = (i + 1).toString(); 400 var lon_value = document.getElementById("lon_" + num).value; 401 var lat_value = document.getElementById("lat_" + num).value; 402 403 if (lon_value != "" && lat_value != "") { // need to restrict the input value 404 var point = new OpenLayers.Geometry.Point(lon_value, lat_value); 405 406 OpenLayers.Projection.transform(point, src, dest); 407 408 409 lonlats[n].push(new OpenLayers.LonLat(point.x, point.y)); 410 } 411 } 412 413 414 drawUniversalSelection(n); 415} 416 417 418//button to update coordinates from the map to the form 419//Freddy July 11 2013 420function updatePoints(n) { 421 var n = getActiveMapNumber(); 422 var src = projGlobal; 423 var dest= projArctic; 424 if (n == 0) { 425 dest = projArctic; 426 } else if (n == 1) { 427 dest = projAntarctic; 428 } 429 430 if (n == 0){ 431 for (var i = 0; i < 4; i ++) { 432 if (i < lonlats[n].length) { 433 var num = (i + 1).toString(); 434 var point = new OpenLayers.Geometry.Point(lonlats[0][i].lon, lonlats[0][i].lat); 435 OpenLayers.Projection.transform(point, dest, src); 436 document.getElementById("lon_" + num).value = point.x; 437 document.getElementById("lat_" + num).value = point.y; 438 439 } 440 } 441 } 442 else if (n == 1){ 443 for (var i = 0; i < 4; i ++) { 444 if (i < lonlats[n].length) { 445 var num = (i + 1).toString(); 446 var point = new OpenLayers.Geometry.Point(lonlats[1][i].lon, lonlats[1][i].lat); 447 OpenLayers.Projection.transform(point, dest, src); 448 document.getElementById("lon_" + num).value = point.x; 449 document.getElementById("lat_" + num).value = point.y; 450 451 } 452 } 453 } 454} 455 456 457 458 //Modified by Freddy in order to correct the active tab problem (if tab active coordinates wasn't the same as the coordinates on the form, it wouldnt delete the correct points) 459function deleteLastPoint(n) { 460 461 var n = getActiveMapNumber(); 462 if (n == 0){ 463 464 var num = (lonlats[n].length).toString(); 465 if (lonlats[n].length > 1) { 466 lonlats[0].pop(); 467 document.getElementById("lon_" + num).value = ""; 468 document.getElementById("lat_" + num).value = ""; 469 470 drawUniversalSelection(n); 471 } 472 else if (lonlats[n].length == 1){ 473 clearMarks(n); 474 } 475} 476 else if (n == 1){ 477 var num = (lonlats[n].length).toString(); 478 if (lonlats[n].length > 1) { 479 lonlats[1].pop(); 480 document.getElementById("lon_" + num).value = ""; 481 document.getElementById("lat_" + num).value = ""; 482 483 drawUniversalSelection(n); 484 } 485 else if (lonlats[n].length == 1){ 486 //clearMarks(n); 487 } 488 } 489 490 } 491 492
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.