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

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

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

Last code checkout from earlier SVN instance

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 //                  $codar_request_time = date('Y-m-d H\:i', $offset);
81 //                    $oLayer->setFilter('((select count(*) from current_prod where (report_time_stamp = date_trunc(\'hour\',timestamp without time zone \''.$codar_request_time.'\'))) < 1)');
82 //              }       
83                
84           }
85
86      return $bRes;
87      }
88
89      else
90      {
91      return $bRes;
92      }
93  
94   }
95 }
96
97 $oApp =  new SampleApp();
98 $oApp->registerSkin( 'skins/sample' );
99 $oApp->CWCInitialize( $szTemplate, $szMapFile  );
100 $oApp->CWCExecute();
101
102 ?>
Note: See TracBrowser for help on using the browser.