#!/usr/bin/perl
#round_MOLA_data.pl -- Rounds the longitude and latitude to the nearest thousanth.

use Getopt::Std;
getopt('f:');

$usage = "round_MOLA_data.pl -f <MOLA xyz table>";

if (! $opt_f ) { die "\nUsage: $usage\n\n"; }

open(MOLATABLE,"$opt_f") || die "Could not open file.\n";

while(<MOLATABLE>) {

   $line = $_;
   if ( $line =~ /^(\S+)\s+(\S+)\s+(\S+)/ ) {             
    #Grab the first two columns of data

      $longitude = $1;     
      $latitude = $2;
      $topography = $3;

      if ( $longitude =~ /\s(\d+\.\d+)/ )  {
      printf("%.3f\t%.3f\t", $longitude, $latitude);
      print "$topography\n";
   }
}
