Beispiel #1
0
/*--------------------------------------------------------------------*/
int mbsys_hs10_insert_nav(int verbose, void *mbio_ptr, void *store_ptr,
		int time_i[7], double time_d,
		double navlon, double navlat,
		double speed, double heading, double draft, 
		double roll, double pitch, double heave,
		int *error)
{
	char	*function_name = "mbsys_hs10_insert_nav";
	int	status = MB_SUCCESS;
	struct mb_io_struct *mb_io_ptr;
	struct mbsys_hs10_struct *store;

	/* 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       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       draft:      %f\n",draft);
		fprintf(stderr,"dbg2       roll:       %f\n",roll);
		fprintf(stderr,"dbg2       pitch:      %f\n",pitch);
		fprintf(stderr,"dbg2       heave:      %f\n",heave);
		}

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

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

	/* 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 */

		/* get draft */

		/* get roll pitch and heave */
		}

	/* 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);
}
Beispiel #2
0
/*--------------------------------------------------------------------*/
int mbr_wt_em12darw(int verbose, void *mbio_ptr, void *store_ptr, int *error) {
	char *function_name = "mbr_wt_em12darw";
	int status = MB_SUCCESS;
	struct mb_io_struct *mb_io_ptr;
	struct mbf_em12darw_struct *data;
	struct mbsys_simrad_struct *store;
	struct mbsys_simrad_survey_struct *ping;
	char line[MBF_EM12DARW_RECORD_LENGTH];
	int index;
	char *datacomment;
	int time_i[7];
	int time_j[5];
	int year;
	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:   %p\n", (void *)mbio_ptr);
		fprintf(stderr, "dbg2       store_ptr:  %p\n", (void *)store_ptr);
	}

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

	/* get pointer to raw data structure */
	data = (struct mbf_em12darw_struct *)mb_io_ptr->raw_data;
	datacomment = (char *)&line[80];
	store = (struct mbsys_simrad_struct *)store_ptr;

	/* print debug statements */
	if (verbose >= 5) {
		fprintf(stderr, "\ndbg5  Status at beginning of MBIO function <%s>\n", function_name);
		fprintf(stderr, "dbg5       store->kind:    %d\n", store->kind);
		fprintf(stderr, "dbg5       error:          %d\n", *error);
		fprintf(stderr, "dbg5       status:         %d\n", status);
	}

	/*  translate values from em12 data storage structure */
	if (store->kind == MB_DATA_DATA) {
		/* record type */
		data->func = 150;

		/* time */
		time_i[0] = store->year;
		time_i[1] = store->month;
		time_i[2] = store->day;
		time_i[3] = store->hour;
		time_i[4] = store->minute;
		time_i[5] = store->second;
		time_i[6] = store->centisecond;
		mb_get_jtime(verbose, time_i, time_j);
		mb_unfix_y2k(verbose, time_j[0], &year);
		data->year = (short)year;
		data->jday = time_j[1];
		data->minute = time_j[2];
		data->secs = 100 * time_j[3] + 0.0001 * time_j[4];

		/* navigation */
		data->utm_zone = store->utm_zone;
		data->utm_merd = store->utm_zone_lon;
		data->corflag = store->utm_system;
		data->posq = store->pos_quality;
		data->speed = store->speed;
		if (data->corflag == 0) {
			data->latitude = store->pos_latitude;
			data->longitude = store->pos_longitude;
		}
		else {
			data->latitude = store->utm_northing;
			data->longitude = store->utm_easting;
		}

		/* deal with survey data
		    in secondary data structure */
		if (store->ping != NULL) {
			/* get data structure pointer */
			ping = (struct mbsys_simrad_survey_struct *)store->ping;

			/* copy survey data */
			data->latitude = ping->latitude;
			data->longitude = ping->longitude;
			data->pingno = ping->ping_number;
			data->mode = ping->bath_res;
			data->depthl = ping->keel_depth;
			data->gyro = 0.1 * ping->heading;
			data->roll = 0.01 * ping->roll;
			data->pitch = 0.01 * ping->pitch;
			data->heave = 0.01 * ping->ping_heave;
			data->sndval = 0.1 * ping->sound_vel;
			for (i = 0; i < ping->beams_bath; i++) {
				if (ping->beamflag[i] == MB_FLAG_NULL)
					data->depth[i] = 0;
				else if (!mb_beam_ok(ping->beamflag[i]))
					data->depth[i] = -ping->bath[i];
				else
					data->depth[i] = ping->bath[i];
				data->distacr[i] = ping->bath_acrosstrack[i];
				data->distalo[i] = ping->bath_alongtrack[i];
				data->range[i] = ping->tt[i];
				data->refl[i] = (short int)ping->amp[i];
				data->beamq[i] = (short int)ping->quality[i];
			}
		}
	}

	/* comment */
	else if (store->kind == MB_DATA_COMMENT) {
		data->func = 100;
		strncpy(datacomment, store->comment, MBSYS_SIMRAD_COMMENT_LENGTH);
	}

	/* print debug statements */
	if (verbose >= 5) {
		fprintf(stderr, "\ndbg5  Ready to write data in MBIO function <%s>\n", function_name);
		fprintf(stderr, "dbg5       store->kind:       %d\n", store->kind);
		fprintf(stderr, "dbg5       error:             %d\n", *error);
		fprintf(stderr, "dbg5       status:            %d\n", status);
	}

	/* print debug statements */
	if (verbose >= 4 && status == MB_SUCCESS) {
		fprintf(stderr, "\ndbg4  Data to be written by MBIO function <%s>\n", function_name);
		fprintf(stderr, "dbg4  Status values:\n");
		fprintf(stderr, "dbg4       store->kind:%d\n", store->kind);
		fprintf(stderr, "dbg4       error:      %d\n", *error);
		fprintf(stderr, "dbg4       status:     %d\n", status);
		if (store->kind == MB_DATA_DATA) {
			fprintf(stderr, "dbg4  Survey values:\n");
			fprintf(stderr, "dbg4       year:       %d\n", data->year);
			fprintf(stderr, "dbg4       jday:       %d\n", data->jday);
			fprintf(stderr, "dbg4       minute:     %d\n", data->minute);
			fprintf(stderr, "dbg4       secs:       %d\n", data->secs);
			fprintf(stderr, "dbg4       latitude:   %f\n", data->latitude);
			fprintf(stderr, "dbg4       longitude:  %f\n", data->longitude);
			fprintf(stderr, "dbg4       corflag:    %d\n", data->corflag);
			fprintf(stderr, "dbg4       utm_merd:   %f\n", data->utm_merd);
			fprintf(stderr, "dbg4       utm_zone:   %d\n", data->utm_zone);
			fprintf(stderr, "dbg4       posq:       %d\n", data->posq);
			fprintf(stderr, "dbg4       pingno:     %d\n", data->pingno);
			fprintf(stderr, "dbg4       mode:       %d\n", data->mode);
			fprintf(stderr, "dbg4       depthl:     %f\n", data->depthl);
			fprintf(stderr, "dbg4       speed:      %f\n", data->speed);
			fprintf(stderr, "dbg4       gyro:       %f\n", data->gyro);
			fprintf(stderr, "dbg4       roll:       %f\n", data->roll);
			fprintf(stderr, "dbg4       pitch:      %f\n", data->pitch);
			fprintf(stderr, "dbg4       heave:      %f\n", data->heave);
			fprintf(stderr, "dbg4       sndval:     %f\n", data->sndval);
			for (i = 0; i < MBF_EM12DARW_BEAMS; i++)
				fprintf(stderr, "dbg4       beam:%d  depth:%d  distacr:%d  distalo:%d  range:%d refl:%d beamq:%d\n", i,
				        data->depth[i], data->distacr[i], data->distalo[i], data->range[i], data->refl[i], data->beamq[i]);
		}
		else if (store->kind == MB_DATA_COMMENT) {
			fprintf(stderr, "dbg4  Comment:\n");
			fprintf(stderr, "dbg4       comment:    %s\n", datacomment);
		}
	}

	/* deal with comment */
	if (status == MB_SUCCESS && store->kind == MB_DATA_COMMENT) {
		index = 0;
		for (i = 0; i < MBF_EM12DARW_RECORD_LENGTH; i++)
			line[i] = 0;
		mb_put_binary_short(MB_NO, data->func, &line[0]);
		index += 2;
		strncpy(datacomment, store->comment, MBSYS_SIMRAD_COMMENT_LENGTH);
	}

	/* deal with data */
	else if (status == MB_SUCCESS && store->kind == MB_DATA_DATA) {
		index = 0;
		mb_put_binary_short(MB_NO, data->func, &line[0]);
		index += 2;
		mb_put_binary_short(MB_NO, data->year, &line[index]);
		index += 2;
		mb_put_binary_short(MB_NO, data->jday, &line[index]);
		index += 2;
		mb_put_binary_short(MB_NO, data->minute, &line[index]);
		index += 2;
		mb_put_binary_short(MB_NO, data->secs, &line[index]);
		index += 8;
		mb_put_binary_double(MB_NO, data->latitude, &line[index]);
		index += 8;
		mb_put_binary_double(MB_NO, data->longitude, &line[index]);
		index += 8;
		mb_put_binary_short(MB_NO, data->corflag, &line[index]);
		index += 4;
		mb_put_binary_float(MB_NO, data->utm_merd, &line[index]);
		index += 4;
		mb_put_binary_short(MB_NO, data->utm_zone, &line[index]);
		index += 2;
		mb_put_binary_short(MB_NO, data->posq, &line[index]);
		index += 2;
		mb_put_binary_int(MB_NO, data->pingno, &line[index]);
		index += 4;
		mb_put_binary_short(MB_NO, data->mode, &line[index]);
		index += 4;
		mb_put_binary_float(MB_NO, data->depthl, &line[index]);
		index += 4;
		mb_put_binary_float(MB_NO, data->speed, &line[index]);
		index += 4;
		mb_put_binary_float(MB_NO, data->gyro, &line[index]);
		index += 4;
		mb_put_binary_float(MB_NO, data->roll, &line[index]);
		index += 4;
		mb_put_binary_float(MB_NO, data->pitch, &line[index]);
		index += 4;
		mb_put_binary_float(MB_NO, data->heave, &line[index]);
		index += 4;
		mb_put_binary_float(MB_NO, data->sndval, &line[index]);
		index += 4;
		for (i = 0; i < MBF_EM12DARW_BEAMS; i++) {
			mb_put_binary_short(MB_NO, data->depth[i], &line[index]);
			index += 2;
		}
		for (i = 0; i < MBF_EM12DARW_BEAMS; i++) {
			mb_put_binary_short(MB_NO, data->distacr[i], &line[index]);
			index += 2;
		}
		for (i = 0; i < MBF_EM12DARW_BEAMS; i++) {
			mb_put_binary_short(MB_NO, data->distalo[i], &line[index]);
			index += 2;
		}
		for (i = 0; i < MBF_EM12DARW_BEAMS; i++) {
			mb_put_binary_short(MB_NO, data->range[i], &line[index]);
			index += 2;
		}
		for (i = 0; i < MBF_EM12DARW_BEAMS; i++) {
			mb_put_binary_short(MB_NO, data->refl[i], &line[index]);
			index += 2;
		}
		for (i = 0; i < MBF_EM12DARW_BEAMS; i++) {
			mb_put_binary_short(MB_NO, data->beamq[i], &line[index]);
			index += 2;
		}
	}

	/* write next record to file */
	if (store->kind == MB_DATA_DATA || store->kind == MB_DATA_COMMENT) {
		if ((status = fwrite(line, 1, MBF_EM12DARW_RECORD_LENGTH, mb_io_ptr->mbfp)) == MBF_EM12DARW_RECORD_LENGTH) {
			status = MB_SUCCESS;
			*error = MB_ERROR_NO_ERROR;
		}
		else {
			status = MB_FAILURE;
			*error = MB_ERROR_WRITE_FAIL;
		}
	}
	else {
		status = MB_SUCCESS;
		*error = MB_ERROR_NO_ERROR;
		if (verbose >= 5)
			fprintf(stderr, "\ndbg5  No data written in MBIO function <%s>\n", function_name);
	}

	/* 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       error:      %d\n", *error);
		fprintf(stderr, "dbg2  Return status:\n");
		fprintf(stderr, "dbg2       status:  %d\n", status);
	}

	return (status);
}
Beispiel #3
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);
}