Changeset 304 in tmcsimulator
- Timestamp:
- 03/10/2019 07:50:12 PM (7 years ago)
- Location:
- trunk/src/cptms
- Files:
-
- 5 added
- 2 edited
-
cctvToJson.awk (added)
-
cctv_locations_D12.csv (added)
-
cctv_locations_D12.json (added)
-
cptms_map.html (modified) (11 diffs)
-
images/CPTMSImages/icon_cctvBlue.png (added)
-
prep_cctv.py (added)
-
prep_postmiles.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/cptms/cptms_map.html
r303 r304 126 126 <body> 127 127 <!-- 128 Version 5.7 integrates CCTV icons and button (but empty click handler) 128 129 Version 5.6 integrates CMS features 129 130 Version 5.5 renames title to CPTMS, loads static data on startup and dynamic data … … 146 147 <!--The div element where the buttons appears --> 147 148 <div id="ctrButton" class="unstyled-button">⊕</div> 148 <button id="cmsButton" class="unstyled-button"><img id="cmsBtnImg" src="images/CPTMSImages/btnDepressed_CMS.png"></button> 149 <button id="cctvButton" class="unstyled-button"><img id="cctvBtnImg" src="images/CPTMSImages/btnReady_CCTV.png"></button> 150 <button id="cmsButton" class="unstyled-button"><img id="cmsBtnImg" src="images/CPTMSImages/btnReady_CMS.png"></button> 149 151 <button id="vdsButton" class="unstyled-button"><img id="vdsBtnImg" src="images/CPTMSImages/btnDepressed_VDS.png"></button> 150 152 <!-- The div element for the popup dialog --> … … 195 197 var colorZvalues = {"white":5,"lime":10,"yellow":20,"red":30}; 196 198 var kCMSstartupFile = "cmsStatusD12.json"; 199 var kCCTVfile = "cctv_locations_D12.json"; 197 200 var blueFlag = "images/CPTMSImages/icon_cmsBlue.png"; 198 201 var yellowFlag = "images/CPTMSImages/icon_cmsYellow.png"; 202 var cctvIcon = "images/CPTMSImages/icon_cctvBlue.png"; 199 203 var messageList; 200 204 var cms_info; 201 var markerList = []; 202 var cms_showing = true; 205 var cmsList = []; 206 var cctvList = []; 207 var cms_showing = false; 203 208 var vds_showing = true; 204 209 var cctv_showing = false; 205 210 // Build a solid colored icon to use instead of the classic pin 206 211 // Use a diamond on N and E directions, circle on S and W directions … … 436 441 function initButton() 437 442 { 443 var cctvBtnDiv = document.getElementById('cctvButton'); 444 map.controls[google.maps.ControlPosition.LEFT_BOTTOM].push(cctvBtnDiv) 445 cctvBtnDiv.title = 'Click to toggle cctv view'; 446 // Setup the click event listeners to toggle icon display 447 cctvBtnDiv.addEventListener('click', function() { 448 cctv_showing = !cctv_showing; 449 // reveal or hide all the icons 450 for (var i = 0; i < cctvList.length; i++) 451 { 452 cctvList[i].setVisible(cctv_showing); 453 } 454 // Determine which button image to show 455 if (cctv_showing) 456 { 457 pic = "images/CPTMSImages/btnDepressed_CCTV.png" 458 } 459 else 460 { 461 pic = "images/CPTMSImages/btnReady_CCTV.png" 462 } 463 document.getElementById('cctvBtnImg').src=pic; 464 }); 465 438 466 var cmsBtnDiv = document.getElementById('cmsButton'); 439 467 map.controls[google.maps.ControlPosition.LEFT_BOTTOM].push(cmsBtnDiv) 440 468 cmsBtnDiv.title = 'Click to toggle cms view'; 441 442 469 // Setup the click event listeners to toggle icon display 443 470 cmsBtnDiv.addEventListener('click', function() { 444 471 cms_showing = !cms_showing; 445 472 // reveal or hide all the icons 446 for (var i = 0; i < markerList.length; i++)447 { 448 markerList[i].setVisible(cms_showing);473 for (var i = 0; i < cmsList.length; i++) 474 { 475 cmsList[i].setVisible(cms_showing); 449 476 } 450 477 // Determine which button image to show … … 459 486 document.getElementById('cmsBtnImg').src=pic; 460 487 }); 488 461 489 var vdsBtnDiv = document.getElementById('vdsButton'); 462 490 map.controls[google.maps.ControlPosition.LEFT_BOTTOM].push(vdsBtnDiv) … … 483 511 }); 484 512 } 485 function set Markers()513 function setCMSmarkers() 486 514 { 487 515 var simpleImage = ""; 488 load cmsJSON(function(response)516 loadJSON(kCMSstartupFile, function(response) 489 517 { 490 518 // Parse JSON string into object 491 519 cms_info = JSON.parse(response); 492 console.log(cms_info.data[0].cms);520 //console.log(cms_info.data[0].cms); 493 521 // Process each new marker 494 522 for (var i = 0; i < cms_info.data.length; i++) … … 506 534 .route + " " + cms.location.postmile + " " + cms 507 535 .location.locationName 508 markerList[i] = new google.maps.Marker(536 cmsList[i] = new google.maps.Marker( 509 537 { 510 538 position: … … 519 547 location: locationInfo 520 548 }); 521 google.maps.event.addListener(markerList[i], 'click', 549 cmsList[i].setVisible(false); // initially hidden 550 google.maps.event.addListener(cmsList[i], 'click', 522 551 function() 523 552 { … … 545 574 }); 546 575 } 547 548 function loadcmsJSON(callback) 576 function setCCTVmarkers() 549 577 { 550 var xobj = new XMLHttpRequest();551 xobj.overrideMimeType("application/json");552 xobj.open('GET', kCMSstartupFile, true);553 xobj.onreadystatechange = function()554 {555 if (xobj.readyState == 4 && xobj.status == "200")578 loadJSON(kCCTVfile, function(response) 579 { 580 // Parse JSON string into object 581 cctv_info = JSON.parse(response); 582 // Process each new marker 583 for (var i = 0; i < cctv_info.data.length; i++) 556 584 { 557 callback(xobj.responseText); 558 } 559 }; 560 // We want ajax to ignore any cached responses 561 xobj.setRequestHeader('If-Modified-Since', 'Sat, 01 Jan 2000 01:01:01 GMT') 562 xobj.send(null); 585 var cctv = cctv_info.data[i].cctv; 586 var currLat = Number(cctv.location.latitude); 587 var currLong = Number(cctv.location.longitude); 588 var locationInfo = cctv.location.locationName; 589 cctvList[i] = new google.maps.Marker( 590 { 591 position: 592 { 593 lat: currLat, 594 lng: currLong 595 }, 596 map: map, 597 icon: cctvIcon, 598 title: "#"+i+" " +locationInfo, 599 cctvid: "" + i, 600 location: locationInfo, 601 index: cctv.index, 602 nearVDS: cctv.location.nearVDS 603 }); 604 cctvList[i].setVisible(false); // initially hidden 605 google.maps.event.addListener(cctvList[i], 'click', 606 function() 607 { 608 // fetch the sequential msg # 609 cctvIndex = this.index; 610 alert("here will be the view of cctv: " + cctvIndex); 611 }); 612 } 613 }); 563 614 } 615 616 617 564 618 565 619 function handleSubmit() … … 621 675 // Change icon if something was saved 622 676 if (outMessage == "||") 623 markerList[cmsID].setIcon(yellowFlag);677 cmsList[cmsID].setIcon(yellowFlag); 624 678 else 625 markerList[cmsID].setIcon(blueFlag);679 cmsList[cmsID].setIcon(blueFlag); 626 680 627 681 var xhttp = new XMLHttpRequest(); … … 655 709 initButton(); 656 710 getMessage(1); // load the current message file 657 set Markers();658 711 setCMSmarkers(); 712 setCCTVmarkers(); 659 713 660 714 // Start a timer to refresh the map every 10 seconds -
trunk/src/cptms/prep_postmiles.py
r284 r304 44 44 def loadHighways(): 45 45 46 # f = open("pm_coords_uniq_sorted.csv",'r')47 46 f = open(postmileFile,'r') 48 47 lines = [line.split(',') for line in f.readlines()]
Note: See TracChangeset
for help on using the changeset viewer.
