/* survey.java */

// contain useful terrestrial survey functions

// This program 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; either version 2 of the License,
// or (at your option) any later version.

// This program 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.
// See the GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// alongwith this program; if not, write to the Free Software Foundation, Inc.,
// 675 Mass Ave, Cambridge, MA 02139, USA.

class survey {
   static double hms2hr(double hms)
   {  
      /* converts minutes-seconds format to decimal fraction */
      int deg, min;
      double sec;   
      
      // extract the three components

      deg = (int)hms;
      min = (int)((hms - deg) * 100);
      sec = 10000 * (hms - deg - (double)min/100);

      return(deg + (double)min/60 + (double)sec/3600);
   }

   /* hr2hms -- converts decimal fraction to minutes-seconds format */
   static double hr2hms(double hr)
   {  int deg, min;
      double sec;

      // extract the three components
      deg = (int)hr;
      min = (int)((hr - deg) * 60);
      sec = (double)( hr - deg - (double)min/60) * 3600;

      return( deg + (double)min/100 + sec/10000);
   }
}   // end of survey.java
