/**---------------------------------------------------------------------------
 ** 
 ** pos.h -- 
 ** 
 ** Author          : Pierre Jaccard
 ** Created On      : 1999/07/14 21:14:57
 ** Last Modified By: Pierre Jaccard
 ** Last Modified On: 1999/07/16 21:23:10
 ** Update Count    : 15
 ** Directory       : /home/pego/pcd1/codas3c/gfi/src/libs/misc/
 ** Version         : 0.0
 ** Status          : Unknown
 ** ---------------------------------------------------------------------- ** 
 ** DESCRIPTION: 
 ** 
 **    See associated file pos.c
 ** 
 ** ---------------------------------------------------------------------- ** 
 ** REVISIONS: 
 ** ---------------------------------------------------------------------- ** 
 ** CHANGES: 
 **------------------------------------------------------------------------**/


#ifndef gfilib_misc_pos_already_included
#define gfilib_misc_pos_already_included

#include "geninc.h"
#include "use_db.h"
#include "ioserv.h"
#include "gficnv.h"

/* 
   Codes for expected position type.
*/
#define LONGITUDE_180_CODE      -1  /* Longitude from -180 to +180 */
#define LONGITUDE_360_CODE       0  /* Longitude from    0 to  360 */    
#define LATITUDE_CODE            1  /* Latitude                    */

/*
  Codes specifying the format for writing positions. The value of S is one of
  {+,-} if the sign is in the front, {E,W,X} for longitudes and {N,S,Y} for
  latitudes, where X or Y are for bad positions. 
*/ 
#define D_FORMAT_CODE            0  /* S{d}dd.hhhhhh    */
#define SD_FORMAT_CODE           1  /* {d}dd.hhhhh S    */ 
#define DM_FORMAT_CODE           2  /* ddd mm.hhhh' S   */
#define DMS_FORMAT_CODE          3  /* ddd mm' dd.hh" S */

/*
  Available positon projection codes
*/
#define POLAR_STEREO_PROJ_CODE   1


/*------------------------------------------------------------------
  Functions Declaration:
  ------------------------------------------------------------------ */

#if PROTOTYPE_ALLOWED

DOUBLE posdiff_meter(DMSH_POSITION_TYPE *lon1, DMSH_POSITION_TYPE *lat1,
                     DMSH_POSITION_TYPE *lon2, DMSH_POSITION_TYPE *lat2);
DOUBLE posdiff_meter_d(double lon1, double lat1, double lon2, double lat2);
DOUBLE posdiff_direction(DMSH_POSITION_TYPE *lon1, DMSH_POSITION_TYPE *lat1,
                         DMSH_POSITION_TYPE *lon2, DMSH_POSITION_TYPE *lat2);
DOUBLE posdiff_direction_d(double lon1, double lat1, double lon2, double lat2);
int inv_polar_stereo_proj(double xp, double yp, double an, double fi, 
													int *x, int *y, int nx, int ny, 
													double *lon, double *lat);
int dmsh_to_bad(DMSH_POSITION_TYPE *pos, int lat);
int dmsh_to_min(DMSH_POSITION_TYPE *p, int code);
int dmsh_to_max(DMSH_POSITION_TYPE *p, int code);
int copy_dmsh_position(DMSH_POSITION_TYPE *dst, DMSH_POSITION_TYPE *src);
int position_inside_range(DMSH_POSITION_TYPE *p1, DMSH_POSITION_TYPE *p2,
													DMSH_POSITION_TYPE *p, int code);
int dmsh_to_str(char *str, DMSH_POSITION_TYPE *pos, int code, int fmt);
int str_to_dmsh(DMSH_POSITION_TYPE *pos, char *str, int code);
int get_dmsh_position(FILE *fp, DMSH_POSITION_TYPE *pos, int code);
int hun_to_dmsh(DMSH_POSITION_TYPE *pos, LONG hun, char hemi, int code);
int position_range_to_str(char *str, DMSH_POSITION_TYPE *pos, int fmt);
int write_dmsh_position(FILE * fp, DMSH_POSITION_TYPE *pos, int code, int fmt);
int get_position_range(FILE *fp, DMSH_POSITION_TYPE *start, 
											 DMSH_POSITION_TYPE *end);
int degree_to_str(char *str, double deg, int code, int fmt);

#else

DOUBLE posdiff_meter();
DOUBLE posdiff_meter_d();
DOUBLE posdiff_direction();
DOUBLE posdiff_direction_d();
int inv_polar_stereo_proj();
int dmsh_to_bad();
int dmsh_to_min();
int dmsh_to_max();
int copy_dmsh_position();
int position_inside_range();
int dmsh_to_str();
int str_to_dmsh();
int get_dmsh_position();
int hun_to_dmsh();
int position_range_to_str();
int write_dmsh_position();
int get_position_range();
int degree_to_str();

#endif /* PROTOTYPE_ALLOWED */

#endif /* gfilib_misc_pos_already_included */
