Changeset 197

Show
Ignore:
Timestamp:
04/28/08 15:56:03
Author:
dan
Message:

Fixed date issue.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • obskml/trunk/General/ObsKMLToGeoRSS.pl

    r196 r197  
    77use constant MICROSOFT_PLATFORM => 0; 
    88use constant USE_DEBUG_PRINTS => 1; 
     9 
     10my $strEmail = 'dan@inlet.geol.sc.edu (Dan Ramage)'; 
     11#use $strRSSXML = "<?xml version="1.0" encoding="UTF-8"?>\n 
    912 
    1013my %CommandLineOptions; 
     
    184187    $strRow = '<channel>'; 
    185188    print( $GeoRSSFile  $strRow."\n" ); 
    186     $strRow = "<title>$platform_id latest observations</title>\n<link>$platform_url</link>\n<description>Latest observation data</description>\n"; 
    187     print( $GeoRSSFile  $strRow ); 
    188      
    189     $strRow = '<item>'; 
    190     print( $GeoRSSFile  $strRow."\n" ); 
    191      
    192     $strRow = "<title>$platform_id Latest observations</title>"; 
    193     print( $GeoRSSFile  $strRow."\n" ); 
    194  
    195     #Convert the DB date into RFC822 as per the RSS spec. 
     189     
     190    my $strChannelDate; 
    196191    my $strRFCDate = $datetime; 
    197192    $strRFCDate =~ s/Z//; 
     193    $strRFCDate =~ s/T/ /; 
    198194    if( !MICROSOFT_PLATFORM ) 
    199195    { 
     196      #Convert the DB date into RFC822 as per the RSS spec. 
    200197      $strRFCDate = `date --date=\"$strRFCDate\" -R`; 
    201     } 
    202     else 
    203     { 
     198      #Get the current RFC822 date to use as channel publication date. 
     199      $strChannelDate = `date -R`; 
     200    } 
     201    else 
     202    { 
     203      #Convert the DB date into RFC822 as per the RSS spec. 
    204204      $strRFCDate = `\\UnixUtils\\usr\\local\\wbin\\date.exe --date=\"$strRFCDate\" -R`; 
     205      #Get the current RFC822 date to use as channel publication date. 
     206      $strChannelDate = `\\UnixUtils\\usr\\local\\wbin\\date.exe -R`; 
    205207    } 
    206208    chomp( $strRFCDate ); 
     209    chomp( $strChannelDate ); 
     210     
     211    $strRow = "<title>$platform_id latest observations</title>\n<description>Latest observation data</description>\n<pubDate>$strChannelDate</pubDate>\n<webMaster>$strEmail</webMaster>\n"; 
     212    print( $GeoRSSFile  $strRow ); 
     213     
     214    #We must have a valid link to add the tag. 
     215    if( length( $platform_url ) > 0 ) 
     216    { 
     217      $strRow = "<link>$platform_url</link>\n"; 
     218    } 
     219    else 
     220    { 
     221      #We MUST have a link for the georss, so if the obsKML file didn't have one, we dummy something up for now. 
     222      $strRow = "<link>http://$platform_id</link>\n"; 
     223    } 
     224    print( $GeoRSSFile  $strRow ); 
     225   
     226    ####################################################################################################################################### 
     227    # The <item> children begin here. 
     228    $strRow = '<item>'; 
     229    print( $GeoRSSFile  $strRow."\n" ); 
     230     
     231    $strRow = "<title>$platform_id Latest observations</title>"; 
     232    print( $GeoRSSFile  $strRow."\n" ); 
     233 
    207234    $strRow = "<pubDate>$strRFCDate</pubDate>"; 
    208235    print( $GeoRSSFile  $strRow."\n" ); 
    209236     
    210     $strRow = "<link>$platform_url</link>"; 
     237    #We must have a valid link to add the tag. 
     238    if( length( $platform_url ) > 0 ) 
     239    { 
     240      $strRow = "<link>$platform_url</link>\n"; 
     241    } 
     242    else 
     243    { 
     244      #We MUST have a link for the georss, so if the obsKML file didn't have one, we dummy something up for now. 
     245      $strRow = "<link>http://$platform_id</link>\n"; 
     246    } 
     247    print( $GeoRSSFile  $strRow ); 
     248     
     249    $strRow = "<author>$strEmail</author>"; 
    211250    print( $GeoRSSFile  $strRow."\n" ); 
    212251 
     
    223262      my $data_url          = sprintf("%s",$observation->find('dataURL')); 
    224263      #Create the row. we use html table formatting to help present the data in a more readable fashion.  
    225       $strDesc = $strDesc."<tr><td>$parameter:</td><td>$measurement</td><td>$uom</td><td>Depth: $depth </td></tr>\n"; 
     264      #$strDesc = $strDesc."<tr><td>$parameter:</td><td>$measurement</td><td>$uom</td><td>Depth</td><td>$depth </td></tr>\n"; 
     265      $strDesc = $strDesc."<tr><td>$parameter:</td><td>$measurement</td><td>$uom</td></tr>\n"; 
    226266    } #obs 
    227267    #We use the ![CDATA]] directive to tell teh parser not to mess with the contents so we can take advantage of the HTML table