Exemplo n.º 1
0
/*--------------------------------------------------------------------*/
int mbsys_surf_insert(int verbose, void *mbio_ptr, void *store_ptr,
		int kind, int time_i[7], double time_d,
		double navlon, double navlat,
		double speed, double heading,
		int nbath, int namp, int nss,
		char *beamflag, double *bath, double *amp,
		double *bathacrosstrack, double *bathalongtrack,
		double *ss, double *ssacrosstrack, double *ssalongtrack,
		char *comment, int *error)
{
	char	*function_name = "mbsys_surf_insert";
	int	status = MB_SUCCESS;
	struct mb_io_struct *mb_io_ptr;
	struct mbsys_surf_struct *store;
	int	i;

	/* print input debug statements */
	if (verbose >= 2)
		{
		fprintf(stderr,"\ndbg2  MBIO function <%s> called\n",function_name);
		fprintf(stderr,"dbg2  Revision id: %s\n",rcs_id);
		fprintf(stderr,"dbg2  Input arguments:\n");
		fprintf(stderr,"dbg2       verbose:    %d\n",verbose);
		fprintf(stderr,"dbg2       mbio_ptr:   %p\n",(void *)mbio_ptr);
		fprintf(stderr,"dbg2       store_ptr:  %p\n",(void *)store_ptr);
		fprintf(stderr,"dbg2       kind:       %d\n",kind);
		}
	if (verbose >= 2 && kind == MB_DATA_DATA)
		{
		fprintf(stderr,"dbg2       time_i[0]:  %d\n",time_i[0]);
		fprintf(stderr,"dbg2       time_i[1]:  %d\n",time_i[1]);
		fprintf(stderr,"dbg2       time_i[2]:  %d\n",time_i[2]);
		fprintf(stderr,"dbg2       time_i[3]:  %d\n",time_i[3]);
		fprintf(stderr,"dbg2       time_i[4]:  %d\n",time_i[4]);
		fprintf(stderr,"dbg2       time_i[5]:  %d\n",time_i[5]);
		fprintf(stderr,"dbg2       time_i[6]:  %d\n",time_i[6]);
		fprintf(stderr,"dbg2       time_d:     %f\n",time_d);
		fprintf(stderr,"dbg2       navlon:     %f\n",navlon);
		fprintf(stderr,"dbg2       navlat:     %f\n",navlat);
		fprintf(stderr,"dbg2       speed:      %f\n",speed);
		fprintf(stderr,"dbg2       heading:    %f\n",heading);
		fprintf(stderr,"dbg2       nbath:      %d\n",nbath);
		if (verbose >= 3)
		 for (i=0;i<nbath;i++)
		  fprintf(stderr,"dbg3       beam:%d  flag:%3d  bath:%f   acrosstrack:%f  alongtrack:%f\n",
			i,beamflag[i],bath[i],
			bathacrosstrack[i],bathalongtrack[i]);
		fprintf(stderr,"dbg2       namp:       %d\n",namp);
		if (verbose >= 3)
		 for (i=0;i<namp;i++)
		  fprintf(stderr,"dbg3        beam:%d   amp:%f  acrosstrack:%f  alongtrack:%f\n",
			i,amp[i],bathacrosstrack[i],bathalongtrack[i]);
		fprintf(stderr,"dbg2        nss:       %d\n",nss);
		if (verbose >= 3)
		 for (i=0;i<nss;i++)
		  fprintf(stderr,"dbg3        beam:%d   ss:%f  acrosstrack:%f  alongtrack:%f\n",
			i,ss[i],ssacrosstrack[i],ssalongtrack[i]);
		}
	if (verbose >= 2 && kind == MB_DATA_COMMENT)
		{
		fprintf(stderr,"dbg2       comment:     \ndbg2       %s\n",
			comment);
		}

	/* get mbio descriptor */
	mb_io_ptr = (struct mb_io_struct *) mbio_ptr;

	/* get data structure pointer */
	store = (struct mbsys_surf_struct *) store_ptr;

	/* set data kind */
	store->kind = kind;

	/* insert data in structure */
	if (store->kind == MB_DATA_DATA)
		{
		/* set time */
		store->SoundingData.relTime = (float) (time_d
		    - store->AbsoluteStartTimeOfProfile);

		/* set navigation */
		store->CenterPosition[0].centerPositionX = (float)
			(DTR * navlon - store->GlobalData.referenceOfPositionX);
		store->CenterPosition[0].centerPositionY = (float)
			(DTR * navlat - store->GlobalData.referenceOfPositionY);

		/* set heading */
		store->SoundingData.headingWhileTransmitting = (float) (DTR * heading);

		/* set speed  */
		store->CenterPosition[0].speed = (float) (speed / 3.6);

		/* write distance and depth values into storage arrays */
		if (store->GlobalData.typeOfSounder == 'B'
			|| store->GlobalData.typeOfSounder == 'F')
			{
			store->NrBeams = nbath;
			for (i=0;i<store->NrBeams;i++)
				{
				store->MultiBeamDepth[i].depth = bath[i];
				if (beamflag[i] == MB_FLAG_NULL)
			    		store->MultiBeamDepth[i].depthFlag
						= store->MultiBeamDepth[i].depthFlag | SB_DELETED;
				else if (!mb_beam_check_flag(beamflag[i]))
			    		store->MultiBeamDepth[i].depthFlag
						= store->MultiBeamDepth[i].depthFlag
							& 2046;
				else
			    		store->MultiBeamDepth[i].depthFlag
						= store->MultiBeamDepth[i].depthFlag
							| SB_DEPTH_SUPPRESSED;
				store->MultiBeamDepth[i].beamPositionStar = (float) bathacrosstrack[i];
				store->MultiBeamDepth[i].beamPositionAhead = (float) bathalongtrack[i];
				}
			}
		else if (store->GlobalData.typeOfSounder == 'V')
			{
			store->NrBeams = 0;
  			if (store->SingleBeamDepth.depthHFreq > 0.0)
  				store->SingleBeamDepth.depthHFreq = bath[0];
			else if (store->SingleBeamDepth.depthMFreq > 0.0)
				store->SingleBeamDepth.depthMFreq = bath[0];
			else if (store->SingleBeamDepth.depthLFreq > 0.0)
				store->SingleBeamDepth.depthLFreq = bath[0];
			else
				store->SingleBeamDepth.depthMFreq = bath[0];
			if (beamflag[i] == MB_FLAG_NULL)
			   	store->SingleBeamDepth.depthFlag
					= store->SingleBeamDepth.depthFlag | SB_DELETED;
			else if (!mb_beam_check_flag(beamflag[i]))
			    	store->SingleBeamDepth.depthFlag
					= store->SingleBeamDepth.depthFlag & 2046;
			else
			    	store->SingleBeamDepth.depthFlag
					= store->SingleBeamDepth.depthFlag | SB_DEPTH_SUPPRESSED;
			}

		/* set beam amplitudes */
		store->NrAmplitudes = namp;
		for (i=0;i<store->NrAmplitudes;i++)
			{
			store->MultibeamBeamAmplitudes[i].beamAmplitude = (unsigned short) amp[i];
			}

		if (nss == store->SidescanData.actualNrOfSsDataPort
				 + store->SidescanData.actualNrOfSsDataStb)
			{
    		for (i=0;i<store->SidescanData.actualNrOfSsDataPort;i++)
    			{
    			store->SidescanData.ssData[i] = ss[store->SidescanData.actualNrOfSsDataPort - i - 1];
    			}
    		for (i=store->SidescanData.actualNrOfSsDataStb;i<nss;i++)
    			{
    			store->SidescanData.ssData[i] = ss[i];
    			}
    		}
		}

	/* insert comment in structure */
	else if (store->kind == MB_DATA_COMMENT)
		{
		/*strncpy(store->comment,comment,
			MBSYS_SURF_COMMENT_LENGTH);*/
		}

	/* print output debug statements */
	if (verbose >= 2)
		{
		fprintf(stderr,"\ndbg2  MBIO function <%s> completed\n",function_name);
		fprintf(stderr,"dbg2  Return value:\n");
		fprintf(stderr,"dbg2       error:      %d\n",*error);
		fprintf(stderr,"dbg2  Return status:\n");
		fprintf(stderr,"dbg2       status:  %d\n",status);
		}

	/* return status */
	return(status);
}
Exemplo n.º 2
0
/*--------------------------------------------------------------------*/
int mb_get(int verbose, void *mbio_ptr, int *kind, int *pings, 
		int time_i[7], double *time_d,
		double *navlon, double *navlat, 
		double *speed, double *heading, 
		double *distance, double *altitude, double *sonardepth,
		int *nbath, int *namp, int *nss,
		char *beamflag, double *bath, double *amp,
		double *bathacrosstrack, double *bathalongtrack,
		double *ss, double *ssacrosstrack, double *ssalongtrack,
		char *comment, int *error)
{
	char	*function_name = "mb_get";
	int	status;
	struct mb_io_struct *mb_io_ptr;
	char	*store_ptr;
	int	i;
	int	done;
	int	reset_last;
	double	mtodeglon, mtodeglat;
	double	dx, dy;
	double	delta_time;
	double	headingx, headingy;
	double	denom;

	/* print input debug statements */
	if (verbose >= 2)
		{
		fprintf(stderr,"\ndbg2  MBIO function <%s> called\n",function_name);
		fprintf(stderr,"dbg2  Input arguments:\n");
		fprintf(stderr,"dbg2       verbose:    %d\n",verbose);
		fprintf(stderr,"dbg2       mb_ptr:     %lu\n",(size_t)mbio_ptr);
		}

	/* get mbio descriptor */
	mb_io_ptr = (struct mb_io_struct *) mbio_ptr;
	store_ptr = (char *) mb_io_ptr->store_data;

	/* initialize binning values */
	mb_io_ptr->pings_read = 0;
	mb_io_ptr->pings_binned = 0;
	mb_io_ptr->time_d = 0.0;
	mb_io_ptr->lon = 0.0;
	mb_io_ptr->lat = 0.0;
	mb_io_ptr->speed = 0.0;
	mb_io_ptr->heading = 0.0;
	headingx = 0.0;
	headingy = 0.0;
	for (i=0;i<mb_io_ptr->beams_bath_max;i++)
		{
		mb_io_ptr->beamflag[i] = MB_FLAG_NULL;
		mb_io_ptr->bath[i] = 0.0;
		mb_io_ptr->bath_acrosstrack[i] = 0.0;
		mb_io_ptr->bath_alongtrack[i] = 0.0;
		mb_io_ptr->bath_num[i] = 0;
		}
	for (i=0;i<mb_io_ptr->beams_amp_max;i++)
		{
		mb_io_ptr->amp[i] = 0.0;
		mb_io_ptr->amp_num[i] = 0;
		}
	for (i=0;i<mb_io_ptr->pixels_ss_max;i++)
		{
		mb_io_ptr->ss[i] = 0.0;
		mb_io_ptr->ss_acrosstrack[i] = 0.0;
		mb_io_ptr->ss_alongtrack[i] = 0.0;
		mb_io_ptr->ss_num[i] = 0;
		}

	/* read the data */
	done = MB_NO;
	while (done == MB_NO)
		{

		/* print debug statements */
		if (verbose >= 4)
			{
			fprintf(stderr,"\ndbg2  About to read ping in function <%s>\n",
				function_name);
			fprintf(stderr,"dbg2       need_new_ping: %d\n",
				mb_io_ptr->need_new_ping);
			fprintf(stderr,"dbg2       ping_count:    %d\n",
				mb_io_ptr->ping_count);
			fprintf(stderr,"dbg2       pings_read:    %d\n",
				mb_io_ptr->pings_read);
			fprintf(stderr,"dbg2       status:        %d\n",status);
			fprintf(stderr,"dbg2       error:         %d\n",*error);
			}

		/* get next ping */
		if (mb_io_ptr->need_new_ping)
			{
			status = mb_read_ping(verbose,mbio_ptr,store_ptr,
						&mb_io_ptr->new_kind,error);
			
			/* log errors */
			if (*error < MB_ERROR_NO_ERROR)
				mb_notice_log_error(verbose, mbio_ptr, *error);
				
			/* if io arrays have been reallocated, update the
				pointers of arrays passed into this function,
				as these pointers may have changed */
			if (status == MB_SUCCESS
				&& mb_io_ptr->new_kind == MB_DATA_DATA)
				{
				if (mb_io_ptr->bath_arrays_reallocated == MB_YES)
					{
					status = mb_update_arrayptr(verbose, mbio_ptr, (void **) &beamflag, error);
					status = mb_update_arrayptr(verbose, mbio_ptr, (void **) &bath, error);
					status = mb_update_arrayptr(verbose, mbio_ptr, (void **) &bathacrosstrack, error);
					status = mb_update_arrayptr(verbose, mbio_ptr, (void **) &bathalongtrack, error);
					mb_io_ptr->bath_arrays_reallocated = MB_NO;
					}
				if (mb_io_ptr->amp_arrays_reallocated == MB_YES)
					{
					status = mb_update_arrayptr(verbose, mbio_ptr, (void **) &amp, error);
					mb_io_ptr->amp_arrays_reallocated = MB_NO;
					}
				if (mb_io_ptr->ss_arrays_reallocated == MB_YES)
					{
					status = mb_update_arrayptr(verbose, mbio_ptr, (void **) &ss, error);
					status = mb_update_arrayptr(verbose, mbio_ptr, (void **) &ssacrosstrack, error);
					status = mb_update_arrayptr(verbose, mbio_ptr, (void **) &ssalongtrack, error);
					mb_io_ptr->ss_arrays_reallocated = MB_NO;
					}
				}
			
			/* if survey data read into storage array */
			if (status == MB_SUCCESS
				&& (mb_io_ptr->new_kind == MB_DATA_DATA
				    || mb_io_ptr->new_kind == MB_DATA_COMMENT))
				{
				status = mb_extract(verbose, 
					mbio_ptr, store_ptr, 
					&mb_io_ptr->new_kind,
					mb_io_ptr->new_time_i, 
					&mb_io_ptr->new_time_d,
					&mb_io_ptr->new_lon, 
					&mb_io_ptr->new_lat,
					&mb_io_ptr->new_speed, 
					&mb_io_ptr->new_heading,
					&mb_io_ptr->new_beams_bath, 
					&mb_io_ptr->new_beams_amp, 
					&mb_io_ptr->new_pixels_ss, 
					mb_io_ptr->new_beamflag, 
					mb_io_ptr->new_bath, 
					mb_io_ptr->new_amp, 
					mb_io_ptr->new_bath_acrosstrack, 
					mb_io_ptr->new_bath_alongtrack, 
					mb_io_ptr->new_ss, 
					mb_io_ptr->new_ss_acrosstrack, 
					mb_io_ptr->new_ss_alongtrack, 
					mb_io_ptr->new_comment, 
					error);
				}
			if (status == MB_SUCCESS
				&& mb_io_ptr->new_kind == MB_DATA_DATA)
				{
				status = mb_extract_altitude(verbose, 
					mbio_ptr, store_ptr, 
					&mb_io_ptr->new_kind,
					sonardepth, 
					altitude, 
					error);
				}

			/* set errors if not survey data */
			if (status == MB_SUCCESS)
				{
				mb_io_ptr->need_new_ping = MB_NO;
				if (mb_io_ptr->new_kind == MB_DATA_DATA)
					mb_io_ptr->ping_count++;
				else if (mb_io_ptr->new_kind == MB_DATA_COMMENT)
					{
					mb_io_ptr->comment_count++;
					status = MB_FAILURE;
					*error = MB_ERROR_COMMENT;
					mb_io_ptr->new_error = *error;
					mb_notice_log_error(verbose, mbio_ptr, *error);
					}
				else if (mb_io_ptr->new_kind == MB_DATA_SUBBOTTOM_MCS
					|| mb_io_ptr->new_kind == MB_DATA_SUBBOTTOM_CNTRBEAM
					|| mb_io_ptr->new_kind == MB_DATA_SUBBOTTOM_SUBBOTTOM)
					{
					status = MB_FAILURE;
					*error = MB_ERROR_SUBBOTTOM;
					mb_io_ptr->new_error = *error;
					mb_notice_log_error(verbose, mbio_ptr, *error);
					}
				else
					{
					status = MB_FAILURE;
					*error = MB_ERROR_OTHER;
					mb_io_ptr->new_error = *error;
					mb_notice_log_error(verbose, mbio_ptr, *error);
					}
				}
			}
		else
			{
			*error = mb_io_ptr->new_error;
			if (*error == MB_ERROR_NO_ERROR)
				status = MB_SUCCESS;
			else
				status = MB_FAILURE;
			}

		/* if not a fatal error, increment ping counter */
		if (status == MB_SUCCESS 
			&& mb_io_ptr->new_kind == MB_DATA_DATA)
			mb_io_ptr->pings_read++;

		/* if first ping read set "old" navigation values */
		if (status == MB_SUCCESS 
			&& mb_io_ptr->new_kind == MB_DATA_DATA
			&& mb_io_ptr->ping_count == 1)
			{
			mb_io_ptr->old_time_d = mb_io_ptr->new_time_d;
			mb_io_ptr->old_lon = mb_io_ptr->new_lon;
			mb_io_ptr->old_lat = mb_io_ptr->new_lat;
			}

		/* print debug statements */
		if (verbose >= 4)
			{
			fprintf(stderr,"\ndbg2  New ping read in function <%s>\n",
				function_name);
			fprintf(stderr,"dbg2       need_new_ping: %d\n",
				mb_io_ptr->need_new_ping);
			fprintf(stderr,"dbg2       ping_count:    %d\n",
				mb_io_ptr->ping_count);
			fprintf(stderr,"dbg2       comment_count: %d\n",
				mb_io_ptr->comment_count);
			fprintf(stderr,"dbg2       pings_read:    %d\n",
				mb_io_ptr->pings_read);
			fprintf(stderr,"dbg2       status:        %d\n",
				status);
			fprintf(stderr,"dbg2       error:         %d\n",
				*error);
			fprintf(stderr,"dbg2       new_error:     %d\n",
				mb_io_ptr->new_error);
			}

		/* check for out of location or time bounds */
		if (status == MB_SUCCESS 
			&& mb_io_ptr->new_kind == MB_DATA_DATA)
		{
		if (mb_io_ptr->new_lon < mb_io_ptr->bounds[0] 
			|| mb_io_ptr->new_lon > mb_io_ptr->bounds[1] 
			|| mb_io_ptr->new_lat < mb_io_ptr->bounds[2] 
			|| mb_io_ptr->new_lat > mb_io_ptr->bounds[3])
			{
			status = MB_FAILURE;
			*error = MB_ERROR_OUT_BOUNDS;
			mb_notice_log_error(verbose, mbio_ptr, *error);
			}
		else if (mb_io_ptr->etime_d > mb_io_ptr->btime_d
			&& mb_io_ptr->new_time_d > MB_TIME_D_UNKNOWN 
			&& (mb_io_ptr->new_time_d > mb_io_ptr->etime_d 
				|| mb_io_ptr->new_time_d < mb_io_ptr->btime_d))
			{
			status = MB_FAILURE;
			*error = MB_ERROR_OUT_TIME;
			mb_notice_log_error(verbose, mbio_ptr, *error);
			}
		else if (mb_io_ptr->etime_d < mb_io_ptr->btime_d
			&& mb_io_ptr->new_time_d > MB_TIME_D_UNKNOWN 
			&& (mb_io_ptr->new_time_d > mb_io_ptr->etime_d 
				&& mb_io_ptr->new_time_d < mb_io_ptr->btime_d))
			{
			status = MB_FAILURE;
			*error = MB_ERROR_OUT_TIME;
			mb_notice_log_error(verbose, mbio_ptr, *error);
			}
		}

		/* check for time gap */
		if (status == MB_SUCCESS 
			&& mb_io_ptr->new_time_d > MB_TIME_D_UNKNOWN 
			&& mb_io_ptr->new_kind == MB_DATA_DATA
			&& mb_io_ptr->ping_count > 1)
		{
		if ((mb_io_ptr->new_time_d - mb_io_ptr->last_time_d) 
			> 60*mb_io_ptr->timegap)
			{
			status = MB_FAILURE;
			*error = MB_ERROR_TIME_GAP;
			mb_notice_log_error(verbose, mbio_ptr, *error);
			}
		}
			
		/* log errors */
		if (*error < MB_ERROR_NO_ERROR)
			mb_notice_log_error(verbose, mbio_ptr, *error);

		/* print debug statements */
		if (verbose >= 4)
			{
			fprintf(stderr,"\ndbg4  New ping checked by MBIO function <%s>\n",
				function_name);
			fprintf(stderr,"dbg4  New ping values:\n");
			fprintf(stderr,"dbg4       ping_count:    %d\n",
				mb_io_ptr->ping_count);
			fprintf(stderr,"dbg4       comment_count: %d\n",
				mb_io_ptr->comment_count);
			fprintf(stderr,"dbg4       pings_avg:     %d\n",
				mb_io_ptr->pings_avg);
			fprintf(stderr,"dbg4       pings_read:    %d\n",
				mb_io_ptr->pings_read);
			fprintf(stderr,"dbg4       error:         %d\n",
				mb_io_ptr->new_error);
			fprintf(stderr,"dbg4       status:        %d\n",
				status);
			}
		if (verbose >= 4 
			&& mb_io_ptr->new_kind == MB_DATA_COMMENT)
			{
			fprintf(stderr,"dbg4       comment:     \ndbg4       %s\n",
				mb_io_ptr->new_comment);
			}
		else if (verbose >= 4 
			&& mb_io_ptr->new_kind == MB_DATA_DATA
			&& *error <= MB_ERROR_NO_ERROR
			&& *error > MB_ERROR_COMMENT)
			{
			fprintf(stderr,"dbg4       time_i[0]:     %d\n",
				mb_io_ptr->new_time_i[0]);
			fprintf(stderr,"dbg4       time_i[1]:     %d\n",
				mb_io_ptr->new_time_i[1]);
			fprintf(stderr,"dbg4       time_i[2]:     %d\n",
				mb_io_ptr->new_time_i[2]);
			fprintf(stderr,"dbg4       time_i[3]:     %d\n",
				mb_io_ptr->new_time_i[3]);
			fprintf(stderr,"dbg4       time_i[4]:     %d\n",
				mb_io_ptr->new_time_i[4]);
			fprintf(stderr,"dbg4       time_i[5]:     %d\n",
				mb_io_ptr->new_time_i[5]);
			fprintf(stderr,"dbg4       time_i[6]:     %d\n",
				mb_io_ptr->new_time_i[6]);
			fprintf(stderr,"dbg4       time_d:        %f\n",
				mb_io_ptr->new_time_d);
			fprintf(stderr,"dbg4       longitude:     %f\n",
				mb_io_ptr->new_lon);
			fprintf(stderr,"dbg4       latitude:      %f\n",
				mb_io_ptr->new_lat);
			fprintf(stderr,"dbg4       speed:         %f\n",
				mb_io_ptr->new_speed);
			fprintf(stderr,"dbg4       heading:       %f\n",
				mb_io_ptr->new_heading);
			fprintf(stderr,"dbg4       beams_bath:    %d\n",
				mb_io_ptr->new_beams_bath);
			if (mb_io_ptr->new_beams_bath > 0)
			  {
			  fprintf(stderr,"dbg4       beam   flag   bath  crosstrack alongtrack\n");
			  for (i=0;i<mb_io_ptr->new_beams_bath;i++)
			    fprintf(stderr,"dbg4       %4d   %3d    %f    %f     %f\n",
				i,mb_io_ptr->new_beamflag[i],
				mb_io_ptr->new_bath[i],
				mb_io_ptr->new_bath_acrosstrack[i],
				mb_io_ptr->new_bath_alongtrack[i]);
			  }
			fprintf(stderr,"dbg4       beams_amp:     %d\n",
				mb_io_ptr->new_beams_amp);
			if (mb_io_ptr->new_beams_amp > 0)
			  {
			  fprintf(stderr,"dbg4       beam    amp  crosstrack alongtrack\n");
			  for (i=0;i<mb_io_ptr->new_beams_bath;i++)
			    fprintf(stderr,"dbg4       %4d   %f    %f     %f\n",
				i,mb_io_ptr->new_amp[i],
				mb_io_ptr->new_bath_acrosstrack[i],
				mb_io_ptr->new_bath_alongtrack[i]);
			  }
			fprintf(stderr,"dbg4       pixels_ss:     %d\n",
				mb_io_ptr->new_pixels_ss);
			if (mb_io_ptr->new_pixels_ss > 0)
			  {
			  fprintf(stderr,"dbg4       pixel sidescan crosstrack alongtrack\n");
			  for (i=0;i<mb_io_ptr->new_pixels_ss;i++)
			    fprintf(stderr,"dbg4       %4d   %f    %f     %f\n",
				i,mb_io_ptr->new_ss[i],
				mb_io_ptr->new_ss_acrosstrack[i],mb_io_ptr->new_ss_alongtrack[i]);
			  }
			}

		/* now bin the data if appropriate */
		if (mb_io_ptr->new_kind == MB_DATA_DATA &&

			/* if data is ok */
			(status == MB_SUCCESS

			/* or if nonfatal error and only one ping read, 
				bin the ping */
			|| (*error < MB_ERROR_NO_ERROR 
			&& *error > MB_ERROR_COMMENT
			&& mb_io_ptr->pings_read == 1))
			)

			{
			/* bin the values */
			mb_io_ptr->pings_binned++;
			mb_io_ptr->time_d = mb_io_ptr->time_d 
				+ mb_io_ptr->new_time_d;
			mb_io_ptr->lon = mb_io_ptr->lon 
				+ mb_io_ptr->new_lon;
			mb_io_ptr->lat = mb_io_ptr->lat 
				+ mb_io_ptr->new_lat;
			mb_io_ptr->speed = mb_io_ptr->speed 
				+ mb_io_ptr->new_speed;
			mb_io_ptr->heading = mb_io_ptr->heading 
				+ mb_io_ptr->new_heading;
			headingx = headingx + sin(DTR*mb_io_ptr->new_heading);
			headingy = headingy + cos(DTR*mb_io_ptr->new_heading);
		        if (mb_io_ptr->pings == 1)
			  {
			  for (i=0;i<mb_io_ptr->new_beams_bath;i++)
			    {
			    mb_io_ptr->beamflag[i] = mb_io_ptr->new_beamflag[i];
			    mb_io_ptr->bath[i] = mb_io_ptr->new_bath[i];
			    mb_io_ptr->bath_acrosstrack[i] = mb_io_ptr->new_bath_acrosstrack[i];
			    mb_io_ptr->bath_alongtrack[i] = mb_io_ptr->new_bath_alongtrack[i];
			    mb_io_ptr->bath_num[i] = 1;
			    }
			  for (i=0;i<mb_io_ptr->new_beams_amp;i++)
			    {
			    mb_io_ptr->amp[i] = mb_io_ptr->new_amp[i];
			    mb_io_ptr->amp_num[i] = 1;
			    }
			  for (i=0;i<mb_io_ptr->new_pixels_ss;i++)
			    {
			    mb_io_ptr->ss[i] = mb_io_ptr->new_ss[i];
			    mb_io_ptr->ss_acrosstrack[i] = mb_io_ptr->new_ss_acrosstrack[i];
			    mb_io_ptr->ss_alongtrack[i] = mb_io_ptr->new_ss_alongtrack[i];
			    mb_io_ptr->ss_num[i] = 1;
			    }
			  }
			else
			  {
			  for (i=0;i<mb_io_ptr->new_beams_bath;i++)
			    {
			    if (!mb_beam_check_flag(mb_io_ptr->new_beamflag[i]))
			      {
			      mb_io_ptr->beamflag[i] = MB_FLAG_NONE;
			      mb_io_ptr->bath[i] = mb_io_ptr->bath[i] 
			                         + mb_io_ptr->new_bath[i];
			      mb_io_ptr->bath_acrosstrack[i] = mb_io_ptr->bath_acrosstrack[i] 
			                         + mb_io_ptr->new_bath_acrosstrack[i];
			      mb_io_ptr->bath_alongtrack[i] = mb_io_ptr->bath_alongtrack[i] 
			                         + mb_io_ptr->new_bath_alongtrack[i];
			      mb_io_ptr->bath_num[i]++;
			      }
			    }
			  for (i=0;i<mb_io_ptr->new_beams_amp;i++)
			    {
			    if (!mb_beam_check_flag(mb_io_ptr->new_beamflag[i]))
			      {
			      mb_io_ptr->amp[i] = mb_io_ptr->amp[i] 
						 + mb_io_ptr->new_amp[i];
			      mb_io_ptr->amp_num[i]++;
			      }
			    }
			  for (i=0;i<mb_io_ptr->new_pixels_ss;i++)
			    {
			    if (mb_io_ptr->new_ss[i] != 0.0)
			      {
			      mb_io_ptr->ss[i] = mb_io_ptr->ss[i] 
			                         + mb_io_ptr->new_ss[i];
			      mb_io_ptr->ss_acrosstrack[i] = mb_io_ptr->ss_acrosstrack[i] 
			                         + mb_io_ptr->new_ss_acrosstrack[i];
			      mb_io_ptr->ss_alongtrack[i] = mb_io_ptr->ss_alongtrack[i] 
			                         + mb_io_ptr->new_ss_alongtrack[i];
			      mb_io_ptr->ss_num[i]++;
			      }
			    }
			  }
			}

		/* print debug statements */
		if (verbose >= 4 
			&& mb_io_ptr->new_kind == MB_DATA_DATA 
			&& (status == MB_SUCCESS
			|| (*error < MB_ERROR_NO_ERROR 
			&& *error > MB_ERROR_COMMENT
			&& mb_io_ptr->pings_read == 1)))
			{
			fprintf(stderr,"\ndbg4  New ping binned by MBIO function <%s>\n",
				function_name);
			fprintf(stderr,"dbg4  Current binned ping values:\n");
			fprintf(stderr,"dbg4       pings_binned: %d\n",
				mb_io_ptr->pings_binned);
			fprintf(stderr,"dbg4       time_d:       %f\n",
				mb_io_ptr->time_d);
			fprintf(stderr,"dbg4       longitude:    %f\n",
				mb_io_ptr->lon);
			fprintf(stderr,"dbg4       latitude:     %f\n",
				mb_io_ptr->lat);
			fprintf(stderr,"dbg4       speed:        %f\n",
				mb_io_ptr->speed);
			fprintf(stderr,"dbg4       heading:      %f\n",
				mb_io_ptr->heading);
			fprintf(stderr,"dbg4       beams_bath:    %d\n",
				mb_io_ptr->beams_bath_max);
			if (mb_io_ptr->beams_bath_max > 0)
			  {
			  fprintf(stderr,"dbg4       beam   nbath bath  crosstrack alongtrack\n");
			  for (i=0;i<mb_io_ptr->beams_bath_max;i++)
			    fprintf(stderr,"dbg4       %4d   %4d  %f    %f     %f\n",
				i,mb_io_ptr->bath_num[i],mb_io_ptr->bath[i],
				mb_io_ptr->bath_acrosstrack[i],
				mb_io_ptr->bath_alongtrack[i]);
			  }
			fprintf(stderr,"dbg4       beams_amp:    %d\n",
				mb_io_ptr->beams_amp_max);
			if (mb_io_ptr->beams_amp_max > 0)
			  {
			  fprintf(stderr,"dbg4       beam    namp  amp  crosstrack alongtrack\n");
			  for (i=0;i<mb_io_ptr->beams_amp_max;i++)
			    fprintf(stderr,"dbg4       %4d   %4d  %f    %f     %f\n",
				i,mb_io_ptr->amp_num[i],mb_io_ptr->amp[i],
				mb_io_ptr->bath_acrosstrack[i],
				mb_io_ptr->bath_alongtrack[i]);
			  }
			fprintf(stderr,"dbg4       pixels_ss:     %d\n",
				mb_io_ptr->pixels_ss_max);
			if (mb_io_ptr->pixels_ss_max > 0)
			  {
			  fprintf(stderr,"dbg4       pixel nss  sidescan crosstrack alongtrack\n");
			  for (i=0;i<mb_io_ptr->pixels_ss_max;i++)
			    fprintf(stderr,"dbg4       %4d   %4d   %f    %f     %f\n",
				i,mb_io_ptr->ss_num[i],mb_io_ptr->ss[i],
				mb_io_ptr->ss_acrosstrack[i],
				mb_io_ptr->ss_alongtrack[i]);
			  }
			}

		/* if data is ok but more pings needed keep reading */
		if (status == MB_SUCCESS 
			&& mb_io_ptr->new_kind == MB_DATA_DATA 
			&& mb_io_ptr->pings_binned < mb_io_ptr->pings_avg)
			{
			done = MB_NO;
			mb_io_ptr->need_new_ping = MB_YES;
			reset_last = MB_YES;
			}

		/* if data is ok and enough pings binned then done */
		else if (status == MB_SUCCESS 
			&& mb_io_ptr->new_kind == MB_DATA_DATA 
			&& mb_io_ptr->pings_binned >= mb_io_ptr->pings_avg)
			{
			done = MB_YES;
			mb_io_ptr->need_new_ping = MB_YES;
			reset_last = MB_YES;
			}

		/* if data gap and only one ping read and more
			pings needed set error save flag and keep reading */
		else if (*error == MB_ERROR_TIME_GAP
			&& mb_io_ptr->new_kind == MB_DATA_DATA 
			&& mb_io_ptr->pings_read == 1
			&& mb_io_ptr->pings_avg > 1)
			{
			done = MB_NO;
			mb_io_ptr->need_new_ping = MB_YES;
			mb_io_ptr->error_save = *error;
			*error = MB_ERROR_NO_ERROR;
			status = MB_SUCCESS;
			reset_last = MB_YES;
			}

		/* if other kind of data and need more pings
			then keep reading */
		else if ((*error == MB_ERROR_OTHER
			|| *error == MB_ERROR_UNINTELLIGIBLE)
			&& mb_io_ptr->pings_binned < mb_io_ptr->pings_avg)
			{
			done = MB_NO;
			mb_io_ptr->need_new_ping = MB_YES;
			*error = MB_ERROR_NO_ERROR;
			status = MB_SUCCESS;
			reset_last = MB_NO;
			}

		/* if error and only one ping read then done */
		else if (*error != MB_ERROR_NO_ERROR
			&& mb_io_ptr->pings_read <= 1)
			{
			done = MB_YES;
			mb_io_ptr->need_new_ping = MB_YES;
			if (*error == MB_ERROR_TIME_GAP
				|| *error == MB_ERROR_OUT_BOUNDS)
				reset_last = MB_YES;
			else
				reset_last = MB_NO;
			}

		/* if error and more than one ping read, 
			then done but save the ping */
		else if (*error != MB_ERROR_NO_ERROR)
			{
			done = MB_YES;
			mb_io_ptr->need_new_ping = MB_NO;
			*error = MB_ERROR_NO_ERROR;
			status = MB_SUCCESS;
			reset_last = MB_NO;
			}

		/* if needed reset "last" pings */
		if (reset_last == MB_YES)
			{
			mb_io_ptr->last_time_d = mb_io_ptr->new_time_d;
			mb_io_ptr->last_lon = mb_io_ptr->new_lon;
			mb_io_ptr->last_lat = mb_io_ptr->new_lat;
			}

		/* print debug statements */
		if (verbose >= 4)
			{
			fprintf(stderr,"\ndbg4  End of reading loop in MBIO function <%s>\n",
				function_name);
			fprintf(stderr,"dbg4  Current status values:\n");
			fprintf(stderr,"dbg4       done:          %d\n",done);
			fprintf(stderr,"dbg4       need_new_ping: %d\n",
					mb_io_ptr->need_new_ping);
			fprintf(stderr,"dbg4       pings_binned:  %d\n",
					mb_io_ptr->pings_binned);
			fprintf(stderr,"dbg4       error:         %d\n",*error);			fprintf(stderr,"dbg4       status:        %d\n",status);
			}
		}

	/* set output number of pings */
	*pings = mb_io_ptr->pings_binned;

	/* set data kind */
	if (mb_io_ptr->pings_binned > 0)
		*kind = MB_DATA_DATA;
	else if (*error == MB_ERROR_COMMENT)
		*kind = MB_DATA_COMMENT;
	else
		*kind = mb_io_ptr->new_kind;

	/* get output time */
	if (*error <= MB_ERROR_NO_ERROR 
		&& *error > MB_ERROR_COMMENT)
		{
		if (mb_io_ptr->pings_binned == 1)
			{
			for (i=0;i<7;i++)
				time_i[i] = mb_io_ptr->new_time_i[i];
			*time_d = mb_io_ptr->new_time_d;
			}
		else if (mb_io_ptr->pings_binned > 1)
			{
			*time_d = mb_io_ptr->time_d/mb_io_ptr->pings_binned;
			mb_get_date(verbose,*time_d,time_i);
			}
		else
			{
			*error = MB_ERROR_NO_PINGS_BINNED;
			mb_notice_log_error(verbose, mbio_ptr, *error);
			}
		}

	/* get other output values */
	if (*error <= MB_ERROR_NO_ERROR 
		&& *error > MB_ERROR_COMMENT)
		{
		/* get navigation values */
		*navlon = mb_io_ptr->lon/mb_io_ptr->pings_binned;
		*navlat = mb_io_ptr->lat/mb_io_ptr->pings_binned;
		headingx = headingx/mb_io_ptr->pings_binned;
		headingy = headingy/mb_io_ptr->pings_binned;
		denom = sqrt(headingx*headingx + headingy*headingy);
		if (denom > 0.0)
			{
			headingx = headingx/denom;
			headingy = headingy/denom;
			*heading = RTD*atan2(headingx,headingy);
			}
		else
			*heading = mb_io_ptr->heading/mb_io_ptr->pings_binned;
		if (*heading < 0.0)
			*heading = *heading + 360.0;

		/* get coordinate scaling */
		mb_coor_scale(verbose,*navlat,&mtodeglon,&mtodeglat);

		/* get distance value */
		if (mb_io_ptr->old_time_d > 0.0)
			{
			dx = (*navlon - mb_io_ptr->old_lon)/mtodeglon;
			dy = (*navlat - mb_io_ptr->old_lat)/mtodeglat;
			*distance = 0.001*sqrt(dx*dx + dy*dy); /* km */
			}
		else
			*distance = 0.0;

		/* get speed value */
		if (mb_io_ptr->speed > 0.0)
			{
			*speed = mb_io_ptr->speed/mb_io_ptr->pings_binned;
			delta_time = 0.0;
			}
		else if (mb_io_ptr->old_time_d > 0.0)
			{
			delta_time = 0.000277778*
				(*time_d - mb_io_ptr->old_time_d); /* hours */
			if (delta_time > 0.0)
				*speed = *distance/delta_time; /* km/hr */
			else
				*speed = 0.0;
			}
		else
			*speed = 0.0;

		/* check for less than minimum speed */
		if (*error == MB_ERROR_NO_ERROR 
			|| *error == MB_ERROR_TIME_GAP) 
		{
		if (mb_io_ptr->ping_count > 1 
			&& *time_d > MB_TIME_D_UNKNOWN 
			&& *speed < mb_io_ptr->speedmin)
			{
			status = MB_FAILURE;
			*error = MB_ERROR_SPEED_TOO_SMALL;
			mb_notice_log_error(verbose, mbio_ptr, *error);
			}
		}

		/* print debug statements */
		if (verbose >= 4)
			{
			fprintf(stderr,"\ndbg4  Distance and Speed Calculated in MBIO function <%s>\n",
				function_name);
			fprintf(stderr,"dbg4  Speed and Distance Related Values:\n");
			fprintf(stderr,"dbg4       binned speed: %f\n",
					mb_io_ptr->speed);
			fprintf(stderr,"dbg4       pings_binned: %d\n",
					mb_io_ptr->pings_binned);
			fprintf(stderr,"dbg4       ping_count:   %d\n",
					mb_io_ptr->ping_count);
			fprintf(stderr,"dbg4       time:         %f\n",
					*time_d);
			fprintf(stderr,"dbg4       lon:          %f\n",
					*navlon);
			fprintf(stderr,"dbg4       lat:          %f\n",
					*navlat);
			fprintf(stderr,"dbg4       old time:     %f\n",
					mb_io_ptr->old_time_d);
			fprintf(stderr,"dbg4       old lon:      %f\n",
					mb_io_ptr->old_lon);
			fprintf(stderr,"dbg4       old lat:      %f\n",
					mb_io_ptr->old_lat);
			fprintf(stderr,"dbg4       distance:     %f\n",
					*distance);
			fprintf(stderr,"dbg4       altitude:     %f\n",
					*altitude);
			fprintf(stderr,"dbg4       sonardepth:   %f\n",
					*sonardepth);
			fprintf(stderr,"dbg4       delta_time:   %f\n",
					delta_time);
			fprintf(stderr,"dbg4       speed:        %f\n",
					*speed);
			fprintf(stderr,"dbg4       error:        %d\n",*error);
			fprintf(stderr,"dbg4       status:       %d\n",status);
			}

		/* get swath data */
		*nbath = 0;
		*namp = 0;
		*nss = 0;
		for (i=0;i<mb_io_ptr->beams_bath_max;i++)
			{
			beamflag[i] = mb_io_ptr->beamflag[i];
			if (mb_io_ptr->bath_num[i] > 0)
				{
				bath[i] = (mb_io_ptr->bath[i])
					/(mb_io_ptr->bath_num[i]);
				bathacrosstrack[i] = (mb_io_ptr->bath_acrosstrack[i])
					/(mb_io_ptr->bath_num[i]);
				bathalongtrack[i] = (mb_io_ptr->bath_alongtrack[i])
					/(mb_io_ptr->bath_num[i]);
				*nbath = i + 1;
				}
			else
				{
				beamflag[i] = MB_FLAG_NULL;
				bath[i] = 0.0;
				bathacrosstrack[i] = 0.0;
				bathalongtrack[i] = 0.0;
				}
			}
		for (i=0;i<mb_io_ptr->beams_amp_max;i++)
			{
			if (mb_io_ptr->amp_num[i] > 0)
				{
				amp[i] = (mb_io_ptr->amp[i])
					/(mb_io_ptr->amp_num[i]);
				*namp = i + 1;
				}
			else
				{
				amp[i] = 0.0;
				}
			}
		for (i=0;i<mb_io_ptr->pixels_ss_max;i++)
			{
			if (mb_io_ptr->ss_num[i] > 0)
				{
				ss[i] = mb_io_ptr->ss[i]
					/mb_io_ptr->ss_num[i];
				ssacrosstrack[i] = mb_io_ptr->ss_acrosstrack[i]
					/mb_io_ptr->ss_num[i];
				ssalongtrack[i] = mb_io_ptr->ss_alongtrack[i]
					/mb_io_ptr->ss_num[i];
				*nss = i + 1;
				}
			else
				{
				ss[i] = 0.0;
				ssacrosstrack[i] = 0.0;
				ssalongtrack[i] = 0.0;
				}
			}
		if (mb_io_ptr->variable_beams == MB_NO)
			{
			*nbath = mb_io_ptr->beams_bath_max;
			*namp = mb_io_ptr->beams_amp_max;
			*nss = mb_io_ptr->pixels_ss_max;
			}
		}

	/* get output comment */
	if (*error == MB_ERROR_COMMENT)
		{
		strcpy(comment,mb_io_ptr->new_comment);
		}

	/* reset "old" navigation values */
	if (*error <= MB_ERROR_NO_ERROR 
		&& *error > MB_ERROR_COMMENT)
		{
		mb_io_ptr->old_time_d = *time_d;
		mb_io_ptr->old_lon = *navlon;
		mb_io_ptr->old_lat = *navlat;
		}

	/* get saved error flag if needed */
	if (*error == MB_ERROR_NO_ERROR 
		&& mb_io_ptr->error_save != MB_ERROR_NO_ERROR)
		{
		*error = mb_io_ptr->error_save;
		status = MB_FAILURE;
		mb_io_ptr->error_save = MB_ERROR_NO_ERROR;
		}

	/* print output debug statements */
	if (verbose >= 2)
		{
		fprintf(stderr,"\ndbg2  MBIO function <%s> completed\n",function_name);
		fprintf(stderr,"dbg2  Return values:\n");
		fprintf(stderr,"dbg2       kind:       %d\n",*kind);
		}
	if (verbose >= 2 && *kind == MB_DATA_DATA)
		{
		fprintf(stderr,"dbg2       pings:      %d\n",*pings);
		fprintf(stderr,"dbg2       time_i[0]:  %d\n",time_i[0]);
		fprintf(stderr,"dbg2       time_i[1]:  %d\n",time_i[1]);
		fprintf(stderr,"dbg2       time_i[2]:  %d\n",time_i[2]);
		fprintf(stderr,"dbg2       time_i[3]:  %d\n",time_i[3]);
		fprintf(stderr,"dbg2       time_i[4]:  %d\n",time_i[4]);
		fprintf(stderr,"dbg2       time_i[5]:  %d\n",time_i[5]);
		fprintf(stderr,"dbg2       time_i[6]:  %d\n",time_i[6]);
		fprintf(stderr,"dbg2       navlon:     %f\n",*navlon);
		fprintf(stderr,"dbg2       navlat:     %f\n",*navlat);
		fprintf(stderr,"dbg2       speed:      %f\n",*speed);
		fprintf(stderr,"dbg2       heading:    %f\n",*heading);
		fprintf(stderr,"dbg2       distance:   %f\n",*distance);
		fprintf(stderr,"dbg2       altitude:   %f\n",*altitude);
		fprintf(stderr,"dbg2       sonardepth: %f\n",*sonardepth);
		fprintf(stderr,"dbg2       nbath:      %d\n",*nbath);
		if (verbose >= 3 && *nbath > 0)
		  {
		  fprintf(stderr,"dbg3       beam   nbath flag bath  crosstrack alongtrack\n");
		  for (i=0;i<*nbath;i++)
		    fprintf(stderr,"dbg3       %4d   %4d  %3d  %f    %f     %f\n",
			i,mb_io_ptr->bath_num[i],beamflag[i],bath[i],
			bathacrosstrack[i],bathalongtrack[i]);
		  }
		fprintf(stderr,"dbg2       namp:       %d\n",*namp);
		if (verbose >= 3 && *namp > 0)
		  {
		  fprintf(stderr,"dbg3       beam    namp  amp  crosstrack alongtrack\n");
		  for (i=0;i<*namp;i++)
		    fprintf(stderr,"dbg3       %4d   %4d  %f    %f     %f\n",
			i,mb_io_ptr->amp_num[i],amp[i],
			bathacrosstrack[i],bathalongtrack[i]);
		  }
		fprintf(stderr,"dbg2       nss:      %d\n",*nss);
		if (verbose >= 3 && *nss > 0)
		  {
		  fprintf(stderr,"dbg3       pixel nss  sidescan crosstrack alongtrack\n");
		  for (i=0;i<*nss;i++)
		    fprintf(stderr,"dbg3       %4d   %4d   %f    %f     %f\n",
			i,mb_io_ptr->ss_num[i],ss[i],
			ssacrosstrack[i],ssalongtrack[i]);
		  }
		}
	else if (verbose >= 2 && *kind == MB_DATA_COMMENT)
		{
		fprintf(stderr,"dbg2       comment:    %s\n",comment);
		}
	if (verbose >= 2)
		{
		fprintf(stderr,"dbg2       error:      %d\n",*error);
		fprintf(stderr,"dbg2  Return status:\n");
		fprintf(stderr,"dbg2       status:     %d\n",status);
		}

	/* return status */
	return(status);
}
Exemplo n.º 3
0
/*--------------------------------------------------------------------*/
int mbsys_hsmd_insert(int verbose, void *mbio_ptr, void *store_ptr,
		int kind, int time_i[7], double time_d,
		double navlon, double navlat,
		double speed, double heading,
		int nbath, int namp, int nss,
		char *beamflag, double *bath, double *amp,
		double *bathacrosstrack, double *bathalongtrack,
		double *ss, double *ssacrosstrack, double *ssalongtrack,
		char *comment, int *error)
{
	char	*function_name = "mbsys_hsmd_insert";
	int	status = MB_SUCCESS;
	struct mb_io_struct *mb_io_ptr;
	struct mbsys_hsmd_struct *store;
	int	first;
	int	i, j;

	/* print input debug statements */
	if (verbose >= 2)
		{
		fprintf(stderr,"\ndbg2  MBIO function <%s> called\n",function_name);
		fprintf(stderr,"dbg2  Revision id: %s\n",rcs_id);
		fprintf(stderr,"dbg2  Input arguments:\n");
		fprintf(stderr,"dbg2       verbose:    %d\n",verbose);
		fprintf(stderr,"dbg2       mbio_ptr:   %p\n",(void *)mbio_ptr);
		fprintf(stderr,"dbg2       store_ptr:  %p\n",(void *)store_ptr);
		fprintf(stderr,"dbg2       kind:       %d\n",kind);
		}
	if (verbose >= 2 && (kind == MB_DATA_DATA || kind == MB_DATA_NAV))
		{
		fprintf(stderr,"dbg2       time_i[0]:  %d\n",time_i[0]);
		fprintf(stderr,"dbg2       time_i[1]:  %d\n",time_i[1]);
		fprintf(stderr,"dbg2       time_i[2]:  %d\n",time_i[2]);
		fprintf(stderr,"dbg2       time_i[3]:  %d\n",time_i[3]);
		fprintf(stderr,"dbg2       time_i[4]:  %d\n",time_i[4]);
		fprintf(stderr,"dbg2       time_i[5]:  %d\n",time_i[5]);
		fprintf(stderr,"dbg2       time_i[6]:  %d\n",time_i[6]);
		fprintf(stderr,"dbg2       time_d:     %f\n",time_d);
		fprintf(stderr,"dbg2       navlon:     %f\n",navlon);
		fprintf(stderr,"dbg2       navlat:     %f\n",navlat);
		fprintf(stderr,"dbg2       speed:      %f\n",speed);
		fprintf(stderr,"dbg2       heading:    %f\n",heading);
		}
	if (verbose >= 2 && kind == MB_DATA_DATA)
		{
		fprintf(stderr,"dbg2       nbath:      %d\n",nbath);
		if (verbose >= 3)
		 for (i=0;i<nbath;i++)
		  fprintf(stderr,"dbg3       beam:%d  flag:%3d  bath:%f  acrosstrack:%f  alongtrack:%f\n",
			i,beamflag[i],bath[i],
			bathacrosstrack[i],bathalongtrack[i]);
		fprintf(stderr,"dbg2       namp:       %d\n",namp);
		if (verbose >= 3)
		 for (i=0;i<namp;i++)
		  fprintf(stderr,"dbg3        amp[%d]: %f\n",
			i,amp[i]);
		fprintf(stderr,"dbg2        nss:       %d\n",nss);
		if (verbose >= 3)
		 for (i=0;i<nss;i++)
		  fprintf(stderr,"dbg3        ss[%d]: %f    ssdist[%d]: %f\n",
			i,ss[i],i,ssacrosstrack[i]);
		}
	if (verbose >= 2 && kind == MB_DATA_COMMENT)
		{
		fprintf(stderr,"dbg2       comment:     \ndbg2       %s\n",
			comment);
		}

	/* get mbio descriptor */
	mb_io_ptr = (struct mb_io_struct *) mbio_ptr;

	/* get data structure pointer */
	store = (struct mbsys_hsmd_struct *) store_ptr;

	/* set data kind */
	store->kind = kind;

	/* insert data in structure */
	if (store->kind == MB_DATA_DATA)
    		{
		/* get time */
		store->year = time_i[0];
		store->month = time_i[1];
		store->day = time_i[2];
		store->hour = time_i[3];
		store->minute = time_i[4];
		store->second = time_i[5];

		/* get navigation */
		if (navlon < 0.0) navlon = navlon + 360.0;
		store->lon = navlon;
		store->lat = navlat;

		/* get heading */
		store->heading_tx = heading;

		/* figure out if port or starboard ping */
		first = -1;
		for (i=0;i<nbath;i++)
			{
			if (first == -1 && bath[i] != 0.0)
				first = i;
			}
		if (first >= MBSYS_HSMD_BEAMS_PING - 1)
			store->Port = 1;
		else
			store->Port = -1;

		/* get bathymetry */

		/* deal with a ping to port */
		if (store->Port == -1)
			{
			for (i=0;i<MBSYS_HSMD_BEAMS_PING;i++)
				{
				j = MBSYS_HSMD_BEAMS_PING - i - 1;
				if (mb_beam_check_flag_null(beamflag[j]))
				    store->depth[i] = 0.0;
				else if (mb_beam_check_flag(beamflag[j]))
				    store->depth[i] = -bath[j];
				else
				    store->depth[i] = bath[j];
	 			store->distance[i] =
	    					bathacrosstrack[j];
     	 			}
    			}

		/* deal with a ping to starboard */
		else
			{
			for (i=0;i<MBSYS_HSMD_BEAMS_PING;i++)
				{
				j = i + MBSYS_HSMD_BEAMS_PING - 1;
				if (mb_beam_check_flag_null(beamflag[j]))
				    store->depth[i] = 0.0;
				else if (mb_beam_check_flag(beamflag[j]))
				    store->depth[i] = -bath[j];
				else
				    store->depth[i] = bath[j];
	 			store->distance[i] =
	    					bathacrosstrack[j];
      				}
    			}

		/* Deal with the sidescan */

		/* deal with a ping to port */
		if (store->Port == -1)
			{
			store->ss_range = fabs(ssacrosstrack[0]);
			for (i=0;i<MBSYS_HSMD_PIXELS_PING;i++)
				{
				j = MBSYS_HSMD_PIXELS_PING - i - 1;
				store->ss[i] = ss[j];
      				}
    			}

		/* deal with a ping to starboard */
		else
			{
			store->ss_range =
				ssacrosstrack[MBSYS_HSMD_PIXELS_PING - 1];
			for (i=0;i<MBSYS_HSMD_PIXELS_PING;i++)
				{
				j = i + MBSYS_HSMD_PIXELS_PING - 1;
				store->ss[i] = ss[j];
      				}
    			}
		}

	/* insert comment in structure */
	else if (store->kind == MB_DATA_COMMENT)
		{
		strcpy(store->comment,comment);
		}

	/* print output debug statements */
	if (verbose >= 2)
		{
		fprintf(stderr,"\ndbg2  MBIO function <%s> completed\n",
			function_name);
		fprintf(stderr,"dbg2  Return value:\n");
		fprintf(stderr,"dbg2       error:      %d\n",*error);
		fprintf(stderr,"dbg2  Return status:\n");
		fprintf(stderr,"dbg2       status:  %d\n",status);
		}

	/* return status */
	return(status);
}
Exemplo n.º 4
0
/*--------------------------------------------------------------------*/
int mbsys_mr1_insert(int verbose, void *mbio_ptr, void *store_ptr,
		int kind, int time_i[7], double time_d,
		double navlon, double navlat,
		double speed, double heading,
		int nbath, int namp, int nss,
		char *beamflag, double *bath, double *amp,
		double *bathacrosstrack, double *bathalongtrack,
		double *ss, double *ssacrosstrack, double *ssalongtrack,
		char *comment, int *error)
{
	char	*function_name = "mbsys_mr1_insert";
	int	status = MB_SUCCESS;
	struct mb_io_struct *mb_io_ptr;
	struct mbsys_mr1_struct *store;
	int	beam_center, pixel_center;
	int	i, j;

	/* print input debug statements */
	if (verbose >= 2)
		{
		fprintf(stderr,"\ndbg2  MBIO function <%s> called\n",function_name);
		fprintf(stderr,"dbg2  Revision id: %s\n",rcs_id);
		fprintf(stderr,"dbg2  Input arguments:\n");
		fprintf(stderr,"dbg2       verbose:    %d\n",verbose);
		fprintf(stderr,"dbg2       mbio_ptr:   %p\n",(void *)mbio_ptr);
		fprintf(stderr,"dbg2       store_ptr:  %p\n",(void *)store_ptr);
		fprintf(stderr,"dbg2       kind:       %d\n",kind);
		}
	if (verbose >= 2 && (kind == MB_DATA_DATA || kind == MB_DATA_NAV))
		{
		fprintf(stderr,"dbg2       time_i[0]:  %d\n",time_i[0]);
		fprintf(stderr,"dbg2       time_i[1]:  %d\n",time_i[1]);
		fprintf(stderr,"dbg2       time_i[2]:  %d\n",time_i[2]);
		fprintf(stderr,"dbg2       time_i[3]:  %d\n",time_i[3]);
		fprintf(stderr,"dbg2       time_i[4]:  %d\n",time_i[4]);
		fprintf(stderr,"dbg2       time_i[5]:  %d\n",time_i[5]);
		fprintf(stderr,"dbg2       time_i[6]:  %d\n",time_i[6]);
		fprintf(stderr,"dbg2       time_d:     %f\n",time_d);
		fprintf(stderr,"dbg2       navlon:     %f\n",navlon);
		fprintf(stderr,"dbg2       navlat:     %f\n",navlat);
		fprintf(stderr,"dbg2       speed:      %f\n",speed);
		fprintf(stderr,"dbg2       heading:    %f\n",heading);
		}
	if (verbose >= 2 && kind == MB_DATA_DATA)
		{
		fprintf(stderr,"dbg2       nbath:      %d\n",nbath);
		if (verbose >= 3)
		 for (i=0;i<nbath;i++)
		  fprintf(stderr,"dbg3       beam:%d  flag:%3d bath:%f  acrosstrack:%f  alongtrack:%f\n",
			i,beamflag[i],bath[i],
			bathacrosstrack[i],bathalongtrack[i]);
		fprintf(stderr,"dbg2       namp:       %d\n",namp);
		if (verbose >= 3)
		 for (i=0;i<namp;i++)
		  fprintf(stderr,"dbg3        beam:%d   amp:%f  acrosstrack:%f  alongtrack:%f\n",
			i,amp[i],bathacrosstrack[i],bathalongtrack[i]);
		fprintf(stderr,"dbg2        nss:       %d\n",nss);
		if (verbose >= 3)
		 for (i=0;i<nss;i++)
		  fprintf(stderr,"dbg3        pixel:%d   ss:%f  acrosstrack:%f  alongtrack:%f\n",
			i,ss[i],ssacrosstrack[i],ssalongtrack[i]);
		}
	if (verbose >= 2 && kind == MB_DATA_COMMENT)
		{
		fprintf(stderr,"dbg2       comment:     \ndbg2       %s\n",
			comment);
		}

	/* get mbio descriptor */
	mb_io_ptr = (struct mb_io_struct *) mbio_ptr;

	/* get data structure pointer */
	store = (struct mbsys_mr1_struct *) store_ptr;

	/* set data kind */
	store->kind = kind;

	/* insert data in structure */
	if (store->kind == MB_DATA_DATA)
		{
		/* get time */
		store->sec = (int) time_d;
		store->usec = (int) 1000000.0*(time_d - store->sec);

		/* get navigation */
		if (navlon < 0.0) navlon = navlon + 360.0;
		store->png_lon = navlon;
		store->png_lat = navlat;

		/* get heading */
		store->png_compass = heading;
		/*store->png_course = heading;*/

		/* get speed */

		/* get port bathymetry */
		beam_center = nbath/2;
		for (i=0;i<store->port_btycount;i++)
			{
			j = beam_center - 2 - i;
			if (beamflag[j] != MB_FLAG_NULL)
				{
				if (mb_beam_check_flag(beamflag[j]))
				    store->bath_port[i]
					= -bath[j];
				else
				    store->bath_port[i]
					= bath[j];
				store->bath_acrosstrack_port[i]
					= -bathacrosstrack[j];
				}
			else
				{
				store->bath_port[i] = 0.0;
				store->bath_acrosstrack_port[i] = 0.0;
				}
			}

		/* get center beam bathymetry */
		if (beamflag[beam_center] == MB_FLAG_NULL)
			{
			store->png_alt = 0.0;
			}
		else if (mb_beam_check_flag(beamflag[beam_center]))
			{
			store->png_alt = -bath[beam_center]
				+ store->png_prdepth;
			}
		else
			{
			store->png_alt = bath[beam_center]
				- store->png_prdepth;
			}

		/* get starboard bathymetry */
		for (i=0;i<store->stbd_btycount;i++)
			{
			j = beam_center + 2 + i;
			if (beamflag[j] != MB_FLAG_NULL)
				{
				if (mb_beam_check_flag(beamflag[j]))
				    store->bath_stbd[i]
					= -bath[j];
				else
				    store->bath_stbd[i]
					= bath[j];
				store->bath_acrosstrack_stbd[i]
					= bathacrosstrack[j];
				}
			else
				{
				store->bath_stbd[i] = 0.0;
				store->bath_acrosstrack_stbd[i] = 0.0;
				}
			}

		/* get port sidescan */
		pixel_center = nss/2;
		for (i=0;i<store->port_sscount;i++)
			{
			j = pixel_center - 2 - i;
			store->ss_port[i]
				= ss[j];
			}

		/* get starboard sidescan */
		for (i=0;i<store->stbd_sscount;i++)
			{
			j = pixel_center + 2 + i;
			store->ss_stbd[i]
				= ss[j];
			}
		}

	/* insert comment in structure */
	else if (store->kind == MB_DATA_COMMENT)
		{
		strcpy(store->comment,comment);
		}

	/* print output debug statements */
	if (verbose >= 2)
		{
		fprintf(stderr,"\ndbg2  MBIO function <%s> completed\n",function_name);
		fprintf(stderr,"dbg2  Return value:\n");
		fprintf(stderr,"dbg2       error:      %d\n",*error);
		fprintf(stderr,"dbg2  Return status:\n");
		fprintf(stderr,"dbg2       status:  %d\n",status);
		}

	/* return status */
	return(status);
}
Exemplo n.º 5
0
/*--------------------------------------------------------------------*/
int mbsys_hs10_insert(int verbose, void *mbio_ptr, void *store_ptr, 
		int kind, int time_i[7], double time_d,
		double navlon, double navlat,
		double speed, double heading,
		int nbath, int namp, int nss,
		char *beamflag, double *bath, double *amp, 
		double *bathacrosstrack, double *bathalongtrack,
		double *ss, double *ssacrosstrack, double *ssalongtrack,
		char *comment, int *error)
{
	char	*function_name = "mbsys_hs10_insert";
	int	status = MB_SUCCESS;
	struct mb_io_struct *mb_io_ptr;
	struct mbsys_hs10_struct *store;
	int	i;

	/* print input debug statements */
	if (verbose >= 2)
		{
		fprintf(stderr,"\ndbg2  MBIO function <%s> called\n",function_name);
		fprintf(stderr,"dbg2  Input arguments:\n");
		fprintf(stderr,"dbg2       verbose:    %d\n",verbose);
		fprintf(stderr,"dbg2       mbio_ptr:   %lu\n",(size_t)mbio_ptr);
		fprintf(stderr,"dbg2       store_ptr:  %lu\n",(size_t)store_ptr);
		fprintf(stderr,"dbg2       kind:       %d\n",kind);
		}
	if (verbose >= 2 && (kind == MB_DATA_DATA || kind == MB_DATA_NAV))
		{
		fprintf(stderr,"dbg2       time_i[0]:  %d\n",time_i[0]);
		fprintf(stderr,"dbg2       time_i[1]:  %d\n",time_i[1]);
		fprintf(stderr,"dbg2       time_i[2]:  %d\n",time_i[2]);
		fprintf(stderr,"dbg2       time_i[3]:  %d\n",time_i[3]);
		fprintf(stderr,"dbg2       time_i[4]:  %d\n",time_i[4]);
		fprintf(stderr,"dbg2       time_i[5]:  %d\n",time_i[5]);
		fprintf(stderr,"dbg2       time_i[6]:  %d\n",time_i[6]);
		fprintf(stderr,"dbg2       time_d:     %f\n",time_d);
		fprintf(stderr,"dbg2       navlon:     %f\n",navlon);
		fprintf(stderr,"dbg2       navlat:     %f\n",navlat);
		fprintf(stderr,"dbg2       speed:      %f\n",speed);
		fprintf(stderr,"dbg2       heading:    %f\n",heading);
		}
	if (verbose >= 2 && kind == MB_DATA_DATA)
		{
		fprintf(stderr,"dbg2       nbath:      %d\n",nbath);
		if (verbose >= 3) 
		 for (i=0;i<nbath;i++)
		  fprintf(stderr,"dbg3       beam:%d  flag:%3d  bath:%f  acrosstrack:%f  alongtrack:%f\n",
			i,beamflag[i],bath[i],
			bathacrosstrack[i],bathalongtrack[i]);
		fprintf(stderr,"dbg2       namp:       %d\n",namp);
		if (verbose >= 3) 
		 for (i=0;i<namp;i++)
		  fprintf(stderr,"dbg3        beam:%d   amp:%f  acrosstrack:%f  alongtrack:%f\n",
			i,amp[i],bathacrosstrack[i],bathalongtrack[i]);
		fprintf(stderr,"dbg2        nss:       %d\n",nss);
		if (verbose >= 3) 
		 for (i=0;i<nss;i++)
		  fprintf(stderr,"dbg3        pixel:%d   ss:%f  acrosstrack:%f  alongtrack:%f\n",
			i,ss[i],ssacrosstrack[i],ssalongtrack[i]);
		}
	if (verbose >= 2 && kind == MB_DATA_COMMENT)
		{
		fprintf(stderr,"dbg2       comment:     \ndbg2       %s\n",
			comment);
		}

	/* get mbio descriptor */
	mb_io_ptr = (struct mb_io_struct *) mbio_ptr;

	/* get data structure pointer */
	store = (struct mbsys_hs10_struct *) store_ptr;

	/* set data kind */
	store->kind = kind;

	/* insert data in structure */
	if (store->kind == MB_DATA_DATA)
		{
		/* get time */
		mb_unfix_y2k(verbose, time_i[0], &store->year);
		store->month = time_i[1];
		store->day = time_i[2];
		store->hour = time_i[3];
		store->minute = time_i[4];
		store->tenth_second = (10 * time_i[5]) + (time_i[6] / 100000);

		/* get navigation */
		if (navlon < -180.0) 
		    navlon = navlon + 360.0;
		if (navlon > 180.0)
		    navlon = navlon - 360.0;
		if (navlon < 0.0) 
		    store->EorW = 'W';
		else
		    store->EorW = 'E';
		store->londeg = (int) fabs(navlon);
		store->lonmin = (int) (60000.0 * (fabs(navlon) - store->londeg));
		if (navlat < 0.0) 
		    store->NorS = 'S';
		else
		    store->NorS = 'N';
		store->latdeg = (int) fabs(navlat);
		store->latmin = (int) (60000.0 * (fabs(navlat) - store->latdeg));

		/* get heading */
		store->heading = (int) (10 * heading);

		/* get speed */

		/* put distance and depth values 
			into data structure */
		for (i=0;i<nbath;i++)
			{
			if (mb_beam_check_flag_null(beamflag[i]))
			    {
			    store->depth[i] = 29999;
			    store->acrosstrack[i] = 99999;
			    }
			else if (mb_beam_check_flag(beamflag[i]))
			    {
			    store->depth[i] = (int) -bath[i];
			    store->acrosstrack[i] = (int) bathacrosstrack[i];
			    }
			else
			    {
			    store->depth[i] = (int) bath[i];
			    store->acrosstrack[i] = (int) bathacrosstrack[i];
			    }
			store->amplitude[i] = (int) amp[i];
			}
		}

	/* insert comment in structure */
	else if (store->kind == MB_DATA_COMMENT)
		{
		strncpy(store->comment,comment, MBSYS_HS10_COMMENT);
		}

	/* print output debug statements */
	if (verbose >= 2)
		{
		fprintf(stderr,"\ndbg2  MBIO function <%s> completed\n",function_name);
		fprintf(stderr,"dbg2  Return value:\n");
		fprintf(stderr,"dbg2       error:      %d\n",*error);
		fprintf(stderr,"dbg2  Return status:\n");
		fprintf(stderr,"dbg2       status:  %d\n",status);
		}

	/* return status */
	return(status);
}
Exemplo n.º 6
0
/*--------------------------------------------------------------------*/
int mbsys_sb2100_insert(int verbose, void *mbio_ptr, void *store_ptr,
		int kind, int time_i[7], double time_d,
		double navlon, double navlat,
		double speed, double heading,
		int nbath, int namp, int nss,
		char *beamflag, double *bath, double *amp,
		double *bathacrosstrack, double *bathalongtrack,
		double *ss, double *ssacrosstrack, double *ssalongtrack,
		char *comment, int *error)
{
	char	*function_name = "mbsys_sb2100_insert";
	int	status = MB_SUCCESS;
	struct mb_io_struct *mb_io_ptr;
	struct mbsys_sb2100_struct *store;
	int	time_j[5];
	int	set_pixel_size;
	double	gain_db;
	double	gain_factor;
	int	center_pixel;
	int	i;

	/* print input debug statements */
	if (verbose >= 2)
		{
		fprintf(stderr,"\ndbg2  MBIO function <%s> called\n",function_name);
		fprintf(stderr,"dbg2  Revision id: %s\n",rcs_id);
		fprintf(stderr,"dbg2  Input arguments:\n");
		fprintf(stderr,"dbg2       verbose:    %d\n",verbose);
		fprintf(stderr,"dbg2       mbio_ptr:   %p\n",(void *)mbio_ptr);
		fprintf(stderr,"dbg2       store_ptr:  %p\n",(void *)store_ptr);
		fprintf(stderr,"dbg2       kind:       %d\n",kind);
		}
	if (verbose >= 2 && (kind == MB_DATA_DATA || kind == MB_DATA_NAV))
		{
		fprintf(stderr,"dbg2       time_i[0]:  %d\n",time_i[0]);
		fprintf(stderr,"dbg2       time_i[1]:  %d\n",time_i[1]);
		fprintf(stderr,"dbg2       time_i[2]:  %d\n",time_i[2]);
		fprintf(stderr,"dbg2       time_i[3]:  %d\n",time_i[3]);
		fprintf(stderr,"dbg2       time_i[4]:  %d\n",time_i[4]);
		fprintf(stderr,"dbg2       time_i[5]:  %d\n",time_i[5]);
		fprintf(stderr,"dbg2       time_i[6]:  %d\n",time_i[6]);
		fprintf(stderr,"dbg2       time_d:     %f\n",time_d);
		fprintf(stderr,"dbg2       navlon:     %f\n",navlon);
		fprintf(stderr,"dbg2       navlat:     %f\n",navlat);
		fprintf(stderr,"dbg2       speed:      %f\n",speed);
		fprintf(stderr,"dbg2       heading:    %f\n",heading);
		}
	if (verbose >= 2 && kind == MB_DATA_DATA)
		{
		fprintf(stderr,"dbg2       nbath:      %d\n",nbath);
		if (verbose >= 3)
		 for (i=0;i<nbath;i++)
		  fprintf(stderr,"dbg3       beam:%d  flag:%3d  bath:%f  acrosstrack:%f  alongtrack:%f\n",
			i,beamflag[i],bath[i],
			bathacrosstrack[i],bathalongtrack[i]);
		fprintf(stderr,"dbg2       namp:       %d\n",namp);
		if (verbose >= 3)
		 for (i=0;i<namp;i++)
		  fprintf(stderr,"dbg3        beam:%d   amp:%f  acrosstrack:%f  alongtrack:%f\n",
			i,amp[i],bathacrosstrack[i],bathalongtrack[i]);
		fprintf(stderr,"dbg2        nss:       %d\n",nss);
		if (verbose >= 3)
		 for (i=0;i<nss;i++)
		  fprintf(stderr,"dbg3        pixel:%d   ss:%f  acrosstrack:%f  alongtrack:%f\n",
			i,ss[i],ssacrosstrack[i],ssalongtrack[i]);
		}
	if (verbose >= 2 && kind == MB_DATA_COMMENT)
		{
		fprintf(stderr,"dbg2       comment:     \ndbg2       %s\n",
			comment);
		}

	/* get mbio descriptor */
	mb_io_ptr = (struct mb_io_struct *) mbio_ptr;

	/* get data structure pointer */
	store = (struct mbsys_sb2100_struct *) store_ptr;

	/* set data kind */
	store->kind = kind;

	/* insert data in structure */
	if (store->kind == MB_DATA_DATA)
		{
		/* get time */
		mb_get_jtime(verbose,time_i,time_j);
		store->year = time_j[0];
		store->jday = time_j[1];
		store->hour = time_j[2]/60;
		store->minute = time_j[2] - 60*store->hour;
		store->sec = time_j[3];
		store->msec = (int) (0.001 * time_j[4]);

		/* get number of beams and pixels */
		store->nbeams = nbath;
		store->npixels = nss;
		center_pixel = store->npixels / 2;

		/* get navigation */
		if (navlon < 0.0) navlon = navlon + 360.0;
		store->longitude = navlon;
		store->latitude = navlat;

		/* get heading */
		store->heading = heading;

		/* get speed */
		store->speed = 5.3899155 * speed;

		/* put beam and pixel values
			into data structure */
		gain_db = store->ping_gain
			- store->transmitter_attenuation
			+ 10.0 * log10( store->ping_pulse_width / 5.0)
			- 30.0;
		gain_factor = pow(10.0, (gain_db / 20.0));
		for (i=0;i<nbath;i++)
			{
			if (mb_beam_check_flag(beamflag[i]))
			    {
			    if (mb_beam_check_flag_null(beamflag[i]))
				store->beams[i].quality = '0';
			    else if (mb_beam_check_flag_manual(beamflag[i]))
				store->beams[i].quality = 'E';
			    else if (mb_beam_check_flag_filter(beamflag[i]))
				store->beams[i].quality = 'F';
			    else if (mb_beam_check_flag_sonar(beamflag[i]))
				store->beams[i].quality = 'Q';
			    }
			else
			    store->beams[i].quality = ' ';
			store->beams[i].depth = bath[i];
			store->beams[i].acrosstrack = bathacrosstrack[i];
			store->beams[i].alongtrack = bathalongtrack[i];
			}
		for (i=0;i<namp;i++)
			store->beams[i].amplitude = 4.0 * (amp[i] + gain_db);
		if (store->pixel_size <= 0.0)
			set_pixel_size = MB_YES;
		else
			set_pixel_size = MB_NO;
		for (i=0;i<nss;i++)
			{
			if (ss[i] > MB_SIDESCAN_NULL)
				store->pixels[i].amplitude = gain_factor * ss[i];
			else
				store->pixels[i].amplitude = 0;
			store->pixels[i].alongtrack = ssalongtrack[i];
			if (set_pixel_size == MB_YES
				&& ssacrosstrack[i] > 0)
				{
				store->pixel_size = ssacrosstrack[i]/
					(i - center_pixel);
				set_pixel_size = MB_NO;
				}
			}
		}

	/* insert comment in structure */
	else if (store->kind == MB_DATA_COMMENT)
		{
		strcpy(store->comment,comment);
		}

	/* print output debug statements */
	if (verbose >= 2)
		{
		fprintf(stderr,"\ndbg2  MBIO function <%s> completed\n",
			function_name);
		fprintf(stderr,"dbg2  Return value:\n");
		fprintf(stderr,"dbg2       error:      %d\n",*error);
		fprintf(stderr,"dbg2  Return status:\n");
		fprintf(stderr,"dbg2       status:  %d\n",status);
		}

	/* return status */
	return(status);
}