/*--------------------------------------------------------------------*/ int mbr_rt_swplssxp(int verbose, void *mbio_ptr, void *store_ptr, int *error) { char *function_name = "mbr_rt_swplssxp"; int status = MB_SUCCESS; struct mb_io_struct *mb_io_ptr; struct mbsys_swathplus_struct *store; swpls_header *header; swpls_sxpping *ping; swpls_comment *comment; swpls_projection *projection; /* 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", mbio_ptr); fprintf(stderr, "dbg2 store_ptr: %p\n", store_ptr); } /* get pointers to mbio descriptor */ mb_io_ptr = (struct mb_io_struct *)mbio_ptr; /* read next data from file */ status = mbr_swplssxp_rd_data(verbose, mbio_ptr, store_ptr, error); /* get pointer to data structure */ store = (struct mbsys_swathplus_struct *)store_ptr; header = &store->sxp_header; ping = &store->sxp_ping; comment = &store->comment; projection = &store->projection; /* check if projection has been set from *.prj file, if so, copy into projection structure */ if ((store->projection_set == MB_NO) && (mb_io_ptr->projection_initialized == MB_YES)) { projection->time_d = time(NULL); projection->microsec = 0; projection->nchars = strnlen(mb_io_ptr->projection_id, MB_NAME_LENGTH); if (projection->projection_alloc < projection->nchars) { status = mb_reallocd(verbose, __FILE__, __LINE__, (size_t)projection->nchars, (void **)&(projection->projection_id), error); if (status != MB_SUCCESS) { projection->projection_alloc = 0; } else { projection->projection_alloc = projection->nchars; } } if (status == MB_SUCCESS) { strncpy(projection->projection_id, mb_io_ptr->projection_id, (size_t)projection->nchars); store->projection_set = MB_YES; } } /* check if projection has been read from *mb222 file, if so, tell mb system */ else if ((store->projection_set == MB_YES) && (mb_io_ptr->projection_initialized == MB_NO)) { mb_proj_init(verbose, projection->projection_id, &(mb_io_ptr->pjptr), error); strncpy(mb_io_ptr->projection_id, projection->projection_id, MB_NAME_LENGTH); mb_io_ptr->projection_initialized = MB_YES; } /* throw away data if the time stamp makes no sense */ if ((status == MB_SUCCESS) && (store->kind == MB_DATA_DATA) && (store->time_i[0] < 2003)) { status = MB_FAILURE; *error = MB_ERROR_UNINTELLIGIBLE; } /* save fix data, used to calculate vessel speed */ if ((status == MB_SUCCESS) && (store->kind == MB_DATA_DATA)) { /* add latest fix */ mb_navint_add(verbose, mbio_ptr, store->time_d, store->sxp_ping.txer_e, store->sxp_ping.txer_n, error); } /* set error and kind in mb_io_ptr */ mb_io_ptr->new_error = *error; mb_io_ptr->new_kind = store->kind; /* 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 */ return (status); } /* mbr_rt_swplssxp */
/*--------------------------------------------------------------------*/ int mbr_rt_swplssxi(int verbose, void *mbio_ptr, void *store_ptr, int *error) { char *function_name = "mbr_rt_swplssxi"; int status = MB_SUCCESS; struct mb_io_struct *mb_io_ptr; struct mbsys_swathplus_struct *store; swpls_projection *projection; /* 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 pointers to mbio descriptor */ mb_io_ptr = (struct mb_io_struct *)mbio_ptr; /* read next data from file */ status = mbr_swplssxi_rd_data(verbose, mbio_ptr, store_ptr, error); /* get pointers to data structures */ store = (struct mbsys_swathplus_struct *)store_ptr; projection = &store->projection; /* check if projection has been set from *.prj file, if so, copy into projection structure */ if ((store->projection_set == MB_NO) && (mb_io_ptr->projection_initialized == MB_YES)) { projection->time_d = time(NULL); projection->microsec = 0; projection->nchars = strnlen(mb_io_ptr->projection_id, MB_NAME_LENGTH); if (projection->projection_alloc < projection->nchars) { status = mb_reallocd(verbose, __FILE__, __LINE__, (size_t)projection->nchars, (void **)&(projection->projection_id), error); if (status != MB_SUCCESS) { projection->projection_alloc = 0; } else { projection->projection_alloc = projection->nchars; } } if (status == MB_SUCCESS) { strncpy(projection->projection_id, mb_io_ptr->projection_id, (size_t)projection->nchars); store->projection_set = MB_YES; } } /* check if projection has been read from *mb222 file, if so, tell mb system */ else if ((store->projection_set == MB_YES) && (mb_io_ptr->projection_initialized == MB_NO)) { mb_proj_init(verbose, projection->projection_id, &(mb_io_ptr->pjptr), error); strncpy(mb_io_ptr->projection_id, projection->projection_id, MB_NAME_LENGTH); mb_io_ptr->projection_initialized = MB_YES; } /* throw away multibeam data if the time stamp makes no sense */ if ((status == MB_SUCCESS) && (store->kind == MB_DATA_DATA) && (store->time_i[0] < 2003)) { status = MB_FAILURE; *error = MB_ERROR_UNINTELLIGIBLE; } /* save geographic position fix data */ else if ((status == MB_SUCCESS) && (store->kind == MB_DATA_NAV) && (store->projection_set == MB_NO)) { mb_navint_add(verbose, mbio_ptr, store->time_d, store->posll.longitude, store->posll.latitude, error); } /* save projected position fix data */ else if ((status == MB_SUCCESS) && (store->kind == MB_DATA_NAV1) && (store->projection_set == MB_YES)) { mb_navint_add(verbose, mbio_ptr, store->time_d, store->posen.easting, store->posen.northing, error); } /* save heading and attitude fix data */ else if ((status == MB_SUCCESS) && (store->kind == MB_DATA_ATTITUDE)) { mb_attint_add(verbose, mbio_ptr, store->time_d, store->attitude.height, store->attitude.roll, store->attitude.pitch, error); mb_hedint_add(verbose, mbio_ptr, store->time_d, store->attitude.heading, error); } /* save tide data (as altitude) */ else if ((status == MB_SUCCESS) && (store->kind == MB_DATA_TIDE)) { mb_altint_add(verbose, mbio_ptr, store->time_d, store->tide.tide, error); } /* set error and kind in mb_io_ptr */ mb_io_ptr->new_error = *error; mb_io_ptr->new_kind = store->kind; /* 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); } /* mbr_rt_swplssxi */