Changeset 251
- Timestamp:
- 05/21/09 16:03:39
- Files:
-
- obskml/trunk/General/obsKMLSubRoutines.pm (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
obskml/trunk/General/obsKMLSubRoutines.pm
r248 r251 1 1 ####################################################################################################### 2 2 #Revisions 3 #Rev: 1.2.0.0 4 #Author: DWR 5 #Sub: KMLAddObsToHash, KMLAddObsList 6 #Changes: In the observation hash, the sorder is now a hash key and not simply a value. This allows us to have the same sensor 7 # at the same elevation, and we can distinguish them by the sorder. 3 8 #Rev: 1.1.0.0 4 9 #Author: DWR … … 229 234 return( $iFoundItems ); 230 235 } 236 ####################################################################################################### 237 #Subroutine: GetConversionUnits 238 #Given a unit of one measurement system, this subroutine will return the equivalent unit from the 239 # specified system. IE if you have "m" in the metric system and want the equivalent in the Imperial system. 240 ####################################################################################################### 241 sub GetConversionUnits #($strCurrentUnits, $strDesiredUOMSystem ) 242 { 243 my ( $strCurrentUnits, $strDesiredUOMSystem ) = @_; 244 if( $strDesiredUOMSystem eq 'en' ) 245 { 246 if( $strCurrentUnits eq 'm' ) 247 { 248 return( 'ft' ); 249 } 250 elsif( $strCurrentUnits eq 'm_s-1' ) 251 { 252 return( 'mph' ); 253 } 254 elsif( $strCurrentUnits eq 'celsius' ) 255 { 256 return( 'fahrenheit' ); 257 } 258 elsif( $strCurrentUnits eq 'cm_s-1' ) 259 { 260 return( 'mph' ); 261 } 262 elsif( $strCurrentUnits eq 'mph' ) 263 { 264 return( 'knots' ); 265 } 266 } 267 else 268 { 269 } 270 return('') 271 } 231 272 232 273 ####################################################################################################### … … 328 369 { 329 370 my ( $strPlatformID, $strPlatformURL, $Latitude, $Longitude, $rObsHash ) = @_; 330 331 371 $rObsHash->{PlatformID}{$strPlatformID}{Latitude} = $Latitude; 332 372 $rObsHash->{PlatformID}{$strPlatformID}{Longitude} = $Longitude; 333 $rObsHash->{PlatformID}{$strPlatformID}{PlatformURL} = $strPlatformURL; 334 373 $rObsHash->{PlatformID}{$strPlatformID}{PlatformURL} = $strPlatformURL; 335 374 } 336 375 ####################################################################################################### … … 398 437 { 399 438 my ( $strObsName, $strDate, $Value, $SensorSOrder, $strPlatformID, $ObsElevation, $strUnits, $rObsHash ) = @_; 400 print( "KMLAddObsToHash:: Obs: $strObsName Date: $strDate Val: $Value SORder: $SensorSOrder Platform: $strPlatformID Elev: $ObsElevation Units: $strUnits\n" );439 print( "KMLAddObsToHash::Adding Obs: $strObsName Date: $strDate Val: $Value SORder: $SensorSOrder Platform: $strPlatformID Elev: $ObsElevation Units: $strUnits Lat: $rObsHash->{PlatformID}{$strPlatformID}{Latitude} Long: $rObsHash->{PlatformID}{$strPlatformID}{Longitude}\n" ); 401 440 my $QCLevel = $QCLEVEL_DATANOTEVALD; 402 $rObsHash->{PlatformID}{$strPlatformID}{TimeStamp}{$strDate}{elev}{$ObsElevation}{obsType}{$strObsName}{uomType} = $strUnits; 403 $rObsHash->{PlatformID}{$strPlatformID}{TimeStamp}{$strDate}{elev}{$ObsElevation}{obsType}{$strObsName}{sorder} = $SensorSOrder; 441 #DWR v1.2.0.0 Use the sorder as a has key, not just a value. 442 $rObsHash->{PlatformID}{$strPlatformID}{TimeStamp}{$strDate}{elev}{$ObsElevation}{sorder}{$SensorSOrder}{obsType}{$strObsName}{uomType} = $strUnits; 443 #$rObsHash->{PlatformID}{$strPlatformID}{TimeStamp}{$strDate}{elev}{$ObsElevation}{obsType}{$strObsName}{sorder} = $SensorSOrder; 404 444 if( $Value ne 'NULL') 405 445 { 406 $rObsHash->{PlatformID}{$strPlatformID}{TimeStamp}{$strDate}{elev}{$ObsElevation}{obsType}{$strObsName}{value} = $Value; 446 #$rObsHash->{PlatformID}{$strPlatformID}{TimeStamp}{$strDate}{elev}{$ObsElevation}{obsType}{$strObsName}{value} = $Value; 447 #DWR v1.2.0.0 Use the sorder as a has key. 448 $rObsHash->{PlatformID}{$strPlatformID}{TimeStamp}{$strDate}{elev}{$ObsElevation}{sorder}{$SensorSOrder}{obsType}{$strObsName}{value} = $Value; 407 449 } 408 450 else … … 410 452 $QCLevel = $QCLEVEL_DATAMISSING; 411 453 } 412 $rObsHash->{PlatformID}{$strPlatformID}{TimeStamp}{$strDate}{elev}{$ObsElevation}{obsType}{$strObsName}{QCLevel} = $QCLevel; 413 } 414 415 ####################################################################################################### 454 #$rObsHash->{PlatformID}{$strPlatformID}{TimeStamp}{$strDate}{elev}{$ObsElevation}{obsType}{$strObsName}{QCLevel} = $QCLevel; 455 #DWR v1.2.0.0 Use the sorder as a has key. 456 $rObsHash->{PlatformID}{$strPlatformID}{TimeStamp}{$strDate}{elev}{$ObsElevation}{sorder}{$SensorSOrder}{obsType}{$strObsName}{QCLevel} = $QCLevel; 457 } 458 459 460 ###################################################################################################### 416 461 #Subroutine: BuildKMLFile 417 462 # Given a hash and a filename, this set of subroutines will build an obsKML file. … … 539 584 my $Latitude = $hObsList->{PlatformID}{$strPlatformID}{Latitude}; 540 585 my $Longitude = $hObsList->{PlatformID}{$strPlatformID}{Longitude}; 541 542 586 KMLAddLatLong( $Doc, $Placemark, $Latitude, $Longitude ); 543 587 KMLAddTimeStamp( $Doc, $Placemark, $Date ); … … 620 664 foreach my $Elev ( reverse sort { $a <=> $b } keys %{$hObsList->{elev}} ) 621 665 { 622 foreach my $ObsType ( sort keys %{$hObsList->{elev}{$Elev}{obsType}} ) 623 { 624 625 #Create the obs child tag. 626 my $Obs = $Doc->createElement( 'obs'); 627 628 #my $strVal = $hObsList->{elev}{$Elev}{obsType}{$ObsType}{value}; 629 #my $strUOM = $hObsList->{elev}{$Elev}{obsType}{$ObsType}{uomType}; 630 #Add all the data for the obs. 631 AddChild( $Doc, $Obs, 'obsType', $ObsType ); 632 AddChild( $Doc, $Obs, 'value', $hObsList->{elev}{$Elev}{obsType}{$ObsType}{value} ); 633 AddChild( $Doc, $Obs, 'uomType', $hObsList->{elev}{$Elev}{obsType}{$ObsType}{uomType} ); 634 AddChild( $Doc, $Obs, 'elev', $Elev ); 635 AddChild( $Doc, $Obs, 'sorder', $hObsList->{elev}{$Elev}{obsType}{$ObsType}{sorder} ); 636 if( exists $hObsList->{elev}{$Elev}{obsType}{$ObsType}{QCLevel} ) 666 #foreach my $ObsType ( sort keys %{$hObsList->{elev}{$Elev}{obsType}} ) 667 foreach my $SensorSOrder ( sort keys %{$hObsList->{elev}{$Elev}{sorder}} ) 668 { 669 foreach my $ObsType ( sort keys %{$hObsList->{elev}{$Elev}{sorder}{$SensorSOrder}{obsType}} ) 637 670 { 638 my $QCLevel = $hObsList->{elev}{$Elev}{obsType}{$ObsType}{QCLevel}; 639 AddChild( $Doc, $Obs, 'QCLevel', $QCLevel ); 671 #Create the obs child tag. 672 my $Obs = $Doc->createElement( 'obs'); 673 674 #my $strVal = $hObsList->{elev}{$Elev}{obsType}{$ObsType}{value}; 675 #my $strUOM = $hObsList->{elev}{$Elev}{obsType}{$ObsType}{uomType}; 676 #Add all the data for the obs. 677 AddChild( $Doc, $Obs, 'obsType', $ObsType ); 678 679 #DWR v1.2.0.0 Use the sorder as a has key. 680 #AddChild( $Doc, $Obs, 'value', $hObsList->{elev}{$Elev}{obsType}{$ObsType}{value} ); 681 AddChild( $Doc, $Obs, 'value', $hObsList->{elev}{$Elev}{sorder}{$SensorSOrder}{obsType}{$ObsType}{value} ); 682 #AddChild( $Doc, $Obs, 'uomType', $hObsList->{elev}{$Elev}{obsType}{$ObsType}{uomType} ); 683 AddChild( $Doc, $Obs, 'uomType', $hObsList->{elev}{$Elev}{sorder}{$SensorSOrder}{obsType}{$ObsType}{uomType} ); 684 AddChild( $Doc, $Obs, 'elev', $Elev ); 685 #DWR v1.2.0.0 Use the sorder as a has key. 686 #AddChild( $Doc, $Obs, 'sorder', $hObsList->{elev}{$Elev}{obsType}{$ObsType}{sorder} ); 687 AddChild( $Doc, $Obs, 'sorder', $SensorSOrder ); 688 #DWR v1.2.0.0 Use the sorder as a has key. 689 #if( exists $hObsList->{elev}{$Elev}{obsType}{$ObsType}{QCLevel} ) 690 if( exists $hObsList->{elev}{$Elev}{sorder}{$SensorSOrder}{obsType}{$ObsType}{QCLevel} ) 691 { 692 #my $QCLevel = $hObsList->{elev}{$Elev}{obsType}{$ObsType}{QCLevel}; 693 my $QCLevel = $hObsList->{elev}{$Elev}{sorder}{$SensorSOrder}{obsType}{$ObsType}{QCLevel}; 694 AddChild( $Doc, $Obs, 'QCLevel', $QCLevel ); 695 } 696 #Add the child tag to the parent, ObsList. 697 $ObsList->appendChild( $Obs ); 698 #print( "obsType: $ObsType value: $hObsList->{elev}{$Elev}{obsType}{$ObsType}{value} uomType: $hObsList->{elev}{$Elev}{obsType}{$ObsType}{uomType}\n" ); 699 #DWR v1.1.0.0 700 #Each obs has its own row with the observation type, value, and units of measurement. 701 #DWR v1.2.0.0 Use the sorder as a has key. 702 $$strDescription = $$strDescription."<tr><td>$ObsType</td><td>$hObsList->{elev}{$Elev}{sorder}{$SensorSOrder}{obsType}{$ObsType}{value}</td><td>$hObsList->{elev}{$Elev}{sorder}{$SensorSOrder}{obsType}{$ObsType}{uomType}</td></tr>"; 703 #print( "KMLAddObsList::strDescription: $$strDescription\n" ); 640 704 } 641 #Add the child tag to the parent, ObsList.642 $ObsList->appendChild( $Obs );643 #print( "obsType: $ObsType value: $hObsList->{elev}{$Elev}{obsType}{$ObsType}{value} uomType: $hObsList->{elev}{$Elev}{obsType}{$ObsType}{uomType}\n" );644 #DWR v1.1.0.0645 #Each obs has its own row with the observation type, value, and units of measurement.646 $$strDescription = $$strDescription."<tr><td>$ObsType</td><td>$hObsList->{elev}{$Elev}{obsType}{$ObsType}{value}</td><td>$hObsList->{elev}{$Elev}{obsType}{$ObsType}{uomType}</td></tr>";647 #print( "KMLAddObsList::strDescription: $$strDescription\n" );648 705 } 649 706 }
