/**---------------------------------------------------------------------------
 ** 
 ** putnav.c -- 
 ** 
 ** Author          : Pierre Jaccard
 ** Created On      : 1999/08/04 13:20:24
 ** Last Modified By: Pierre Jaccard
 ** Last Modified On: 1999/08/04 13:45:29
 ** Update Count    : 4
 ** Directory       : /home/pego/pcd1/codas3c/gfi/src/plugs/
 ** Version         : 0.0
 ** Status          : Unknown
 ** ---------------------------------------------------------------------- ** 
 ** DESCRIPTION: 
 ** 
 **    Pluggin for reading navigation from the output of getnav. This can be
 **    turned on with compile time option -DUSE_GFI_PUTNAV. Note that this
 **    option does not set a special bit in the dpmask.
 ** 
 ** ---------------------------------------------------------------------- ** 
 ** REVISIONS: 
 ** ---------------------------------------------------------------------- ** 
 ** CHANGES: 
 **------------------------------------------------------------------------**/

/* 1999/08/04 Pierre Jaccard
   First pluggin for reading navigation from output of getnav
   Definition of NAV_SOURCE_POSITION and new option list
*/

#ifdef  gfiplug_putnav_from_getnav_1
#ifndef gfiplug_putnav_from_getnav_1_already_included
#define gfiplug_putnav_from_getnav_1_already_included

/* 1998/11/25 PJ
	            Adding option nav_pos for reading positions output by
							getnav and putting them temporarly in the database. */
#define NAV_SOURCE_POSITION 31
static OPTION_TYPE nav_source_options[] =
{
   {"end"         , 0                  , NULL         , NULL},
   {"gps"         , NAV_SOURCE_GPS     , set_long_bit , (char *)&nav_source},
   {"transit"     , NAV_SOURCE_TRANSIT , set_long_bit , (char *)&nav_source},
   {"loran"       , NAV_SOURCE_LORAN   , set_long_bit , (char *)&nav_source},
   {"omega"       , NAV_SOURCE_OMEGA   , set_long_bit , (char *)&nav_source},
   {"radar"       , NAV_SOURCE_RADAR   , set_long_bit , (char *)&nav_source},
   {"nav_pos"     , NAV_SOURCE_POSITION, set_long_bit , (char *)&nav_source},
   {NULL          , 0                  , NULL         , NULL}
};

#endif /* gfiplug_putnav_from_getnav_1_already_included */
#endif /* gfiplug_putnav_from_getnav_1 */

/* 1999/08/04 Pierre Jaccard
   Second pluggin for reading navigation from output of getnav
   The original loop and scanning had to be a little modified
*/
#ifdef gfiplug_putnav_from_getnav_2
#ifndef  gfiplug_putnav_from_getnav_2_already_included
#define gfiplug_putnav_from_getnav_2_already_included
      
   while ( IERR == 0 && getline_nc(fp_pos, buf, 120) != EOF ){

	 /* 1998/11/25 PJ
			           Modifying how data are read from the navigation file to allow
			           reading from getnav output file */
		 if(nav_source & (1L<<NAV_SOURCE_POSITION)){
			 /* Read from getnav output */
			 if(error_found(sscanf(buf, " %lf  %lf %lf",
														 &nav.t, &nav.lon, &nav.lat) != 3,
											"Reading getnav data")) goto close_all;
			 /* Reference velocities must be zero to pass test below */
			 nav.ref_u = 0.0;
			 nav.ref_v = 0.0;
		 }
		 else
			 /* Reading data as originally written in putnav */
			 if(error_found(sscanf(buf, " %lf  %lf %lf %lf %lf %lf %lf %lf",
														 &nav.t, &nav.ref_u, &nav.ref_v,
														 &nav.ship_u, &nav.ship_v, &nav.lon, &nav.lat,
														 &nav.filt_fract) != 8,
											"Reading navigation data")) goto close_all;
		 
#endif /* gfiplug_putnav_from_getnav_2_already_included */
#endif /* gfiplug_putnav_from_getnav_2 */
