#!/usr/bin/perl #****************************************************************************** # Copyright (C) 2000 ImageLinks Inc. # # OSSIM is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation. # # This software is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # # You should have received a copy of the GNU General Public License # along with this software. If not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111- # 1307, USA. # # See the GPL in the COPYING.GPL file for more details. # # Author: David Burken (dburken@imagelinks.com) # # DESCRIPTION: # This script is used to convert degrees, minutes seconds (DMS) # to decimal degrees. # #****************************************************************************** # $Id$ print ("\nEnter \"q\" to quit.\n\n"); while (1) { &getDegrees; &getMinutes; &getSeconds; # Compute the answer. $decdegrees = $deg + ($min/60) + ($sec/3600); if ($negativeHemisphere) { $decdegrees = $decdegrees * -1.0; } print ("Decimal degrees = $decdegrees \n\n"); } # Get degrees sub getDegrees { { print ("Enter degrees: "); $deg = ; chop ($deg); if ($deg =~ /q/i) { exit(0); } # Check for negative. Some users will use negative to indicate # hemisphere. $negativeHemisphere = 0; if ($deg < 0) { $negativeHemisphere = 1; $deg = abs ($deg); } # Check the range. if ($deg > 179) { die ("Degrees must be 179 or less. Exiting\n"); } } } # Get minutes sub getMinutes { { print ("Enter minutes: "); $min = ; chop ($min); if ($min =~ /q/i) { exit(0); } $min = abs ($min); # Check the range. if ($min > 60) { die ("Minutes must be 60 or less. Exiting\n"); } } } # Get seconds sub getSeconds { { print ("Enter seconds: "); $sec = ; chop ($sec); if ($sec =~ /q/i) { exit(0); } $sec = abs ($sec); # Check the range. if ($sec > 60) { die ("Seconds must be 60 or less. Exiting\n"); } } }