#!/usr/bin/perl use strict; =comment This program assumes creates a netcdf file to be pulled by the seacoos data loader/aggregation scripts =cut use XML::LibXML; my ($operator_name,$platform_name) = @ARGV; `unzip -p -qq /var/www/html/obskml/feeds/scdnr/scdnr_metadata_latest.kmz | cat > latest_obskml.kml`; my $content; my $measurement_date; my $file_ref = "obskml_$operator_name\_$platform_name"; my $netcdf_header = './netcdf/obskml_header.txt'; my $netcdf_final = './netcdf/obskml_final.txt'; open (NETCDF_FILE, ">$netcdf_final"); $content = `cat $netcdf_header`; my $xp = XML::LibXML->new->parse_file('latest_obskml.kml'); #my $xp_xml = $xp->serialize; #debug #print $xp_xml; foreach my $platform ($xp->findnodes('//Placemark')) { #print "platform:$platform\n"; #debug my $lon_lat_string = sprintf("%s",$platform->find('Point/coordinates')); my ($lon,$lat) = split(/,/,$lon_lat_string); #print "$lon $lat \n"; $content =~ s//$lon/g; $content =~ s//$lat/g; my $timestamp = sprintf("%s",$platform->find('TimeStamp')); #print "$time \n"; $timestamp =~ s/T/ /g; $measurement_date = substr($timestamp,0,19); my $time_zone = substr($timestamp,19,3).substr($timestamp,23,2); #print "$measurement_date $time_zone \n"; my $time_sec = `date --date='$measurement_date $time_zone' +%s`; chomp($time_sec); $content =~ s//$measurement_date$time_zone/g; $content =~ s/