NCCOOS Trac Projects: Top | Web | Platforms | Processing | Viz | Sprints | Sandbox | (Wind)

root/Interactive_Map/trunk/Interactive_Map/htdocs/nccoos.phtml

Revision 20 (checked in by jcleary, 17 years ago)

Production version from Maury

Line 
1 <?php
2 /*
3  * this is a sample of a minimal application script required to
4  * get a chameleon application running with a template and a
5  * local map file.  Most applications should actually just
6  * copy this file and modify the template and mapfile
7  * parts and should not need to do a lot more here.
8  */
9 include( "/usr/local/chameleon-2.2.1/htdocs/chameleon.php" );
10
11
12 $szTemplate = "./nccoos.html";
13 $szMapFile = "../maps/nccoos.map";
14
15 class SampleApp extends Chameleon
16 {
17   function SampleApp()
18   {
19     parent::Chameleon();
20     $this->moMapSession = new MapSession_RW;
21     $this->moMapSession->setTempDir( getSessionSavePath());
22   }
23  
24   function CWCProcessURL(&$oHTTPFormVars)
25   {
26      $bRes =  parent::CWCProcessURL($oHTTPFormVars);
27      
28      if(empty($_REQUEST['OFFSET']))     
29      {
30           $oMap = $this->moMapSession->oMap;         
31           $label_layer = $oMap->getLayerByName('request_timestamp');                                               
32           $class = $label_layer->getClass(0);                       
33                                                                  
34           //Eastern Time - offset for timestamp labels
35           $time_eastern = time() - (2 * 60 * 60);
36
37           //GMT - 2 hr offset for DB requests
38           $time_gmt = strtotime (gmdate('d M Y H:i:s'));
39           $offset = $time_gmt - (2 * 60 * 60);
40          
41           //GMT - 4 for CODAR default
42           $codar_offset = $time_gmt - (4 * 60 * 60);
43          
44           $timestamp = date('m-d-Y g\:\0\0 a', $time_eastern) ."\n";
45           $class->settext($label_layer,"$timestamp");
46                    
47           $nLayers = $oMap->numlayers;
48           for ($i=0;$i<$nLayers;$i++)
49           {
50                $oLayer = $oMap->getLayer($i);
51                $db_processing = $oLayer->getMetaData('db_processing');
52
53                if ($oLayer->connectiontype == MS_WMS && $oLayer->group == 'Observations')
54                {
55                   $con_string = $oLayer->GetMetaData("wms_onlineresource");                   
56                   $value = '&time_offset_hours=2';
57                   $new_con_string = $con_string.$value;
58                   //print $new_con_string;
59                   $oLayer->set('connection', $new_con_string);
60                }
61
62                if ($oLayer->connectiontype == MS_POSTGIS && $db_processing == '1')
63                 {
64                     //timestamp format is 2006-01-16 16:00
65                     $db_request_time = date('Y-m-d H\:i', $offset);
66                     $oLayer->setFilter('report_time_stamp = date_trunc(\'hour\',timestamp without time zone \''.$db_request_time.'\')');
67                    
68                 }
69
70                 if ($oLayer->connectiontype == MS_POSTGIS && $db_processing == '3')
71                 {
72                     //timestamp format is 2006-01-19 16:00
73                     $codar_request_time = date('Y-m-d H\:i', $codar_offset);   
74                     $oLayer->setFilter('report_time_stamp = date_trunc(\'hour\',timestamp without time zone \''.$codar_request_time.'\')');
75                 }
76
77
78                 if ($oLayer->connectiontype == MS_POSTGIS && $db_processing == '2')
79                 {
80                     $cur_request_time = date('Y-m-d H\:i', $codar_offset);
81                     $oLayer->setFilter('(report_time_stamp = date_trunc(\'hour\',timestamp without time zone \''.$cur_request_time.'\')) and (surface_or_bottom = \'surface\')');
82                 }       
83
84                 // for ADCP currents from Xenia - codar TS
85                 if ($oLayer->connectiontype == MS_POSTGIS && $db_processing == '4')
86                 {
87                     //timestamp format is 2006-01-19 16:00
88                     $cur_request_time = date('Y-m-d H\:i', $codar_offset);
89                     //$oLayer->setFilter('m_type_id = 41 and (sensor_id IN (select row_id from sensor where type_id = 4 )) and (d_report_hour = (timestamp without time zone \''.$cur_request_time.'\')) and (d_top_of_hour = 1 )');
90                     $oLayer->setFilter('m_type_id = 41 and (sensor_id IN (select row_id from sensor where type_id = 4 )) and  (m_date > (timestamp without time zone \''.$cur_request_time.'\' - interval \'30 minutes\' )) and (m_date < (timestamp without time zone \''.$cur_request_time.'\' + interval \'31 minutes\'))');
91                 }
92
93                
94           }
95
96      return $bRes;
97      }
98
99      else
100      {
101      return $bRes;
102      }
103  
104   }
105 }
106
107 $oApp =  new SampleApp();
108 $oApp->registerSkin( 'skins/sample' );
109 $oApp->CWCInitialize( $szTemplate, $szMapFile  );
110 $oApp->CWCExecute();
111
112 ?>
Note: See TracBrowser for help on using the browser.