#!/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 decimal degrees to degress, minutes, # seconds (DMS). # #***************************************************************************** # $Id$ print ("\nEnter \"q\" to quit.\n"); while (1) { &getDegrees; # Compute the answer. $deg = int ($floatDeg); if ($deg) { $floatMin = (($floatDeg - $deg) * 60); } else { $floatMin = $floatDeg * 60; } $min = int ($floatMin); if ($min) { $floatSec = ($floatMin - $min) * 60; } else { $floatSec = $floatMin * 60; } if ($negativeHemisphere) { $deg = $deg * -1; } print ("$floatDeg = $deg degrees, $min minutes, $floatSec seconds. \n"); } # Get degrees sub getDegrees { { print ("\nEnter degrees: "); $floatDeg = ; chop ($floatDeg); if ($floatDeg =~ /q/i) { exit(0); } # Check for negative. Some users will use negative to indicate # hemisphere. $negativeHemisphere = 0; if ($floatDeg < 0) { $negativeHemisphere = 1; $floatDeg = abs ($floatDeg); } # Check the range. if ($floatDeg > 179) { die ("Degrees must be 179 or less. Exiting\n"); } } }