/*--------------------------------------------------------------------*/ int mbr_wt_swplssxp(int verbose, void *mbio_ptr, void *store_ptr, int *error) { char *function_name = "mbr_wt_swplssxp"; int status = MB_SUCCESS; struct mb_io_struct *mb_io_ptr; struct mbsys_swathplus_struct *store; int *header_rec_written; int *projection_rec_written; /* 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 pointer to mbio descriptor */ mb_io_ptr = (struct mb_io_struct *)mbio_ptr; /* get pointer to raw data structure */ store = (struct mbsys_swathplus_struct *)store_ptr; /* get pointers to saved data */ header_rec_written = &(mb_io_ptr->save1); projection_rec_written = &(mb_io_ptr->save2); /* write header record if needed (just once, here at top of file) */ if ((store->sxp_header_set == MB_YES) && (*header_rec_written == MB_NO)) { int origkind = store->kind; int origtype = store->type; store->kind = MB_DATA_HEADER; store->type = SWPLS_ID_SXP_HEADER_DATA; status = swpls_wr_data(verbose, mbio_ptr, store_ptr, error); if (status == MB_SUCCESS) { *header_rec_written = MB_YES; } store->kind = origkind; store->type = origtype; } /* write projection record if needed (just once, here at top of file) */ if ((store->projection_set == MB_YES) && (*projection_rec_written == MB_NO)) { int origkind = store->kind; int origtype = store->type; store->kind = MB_DATA_PARAMETER; store->type = SWPLS_ID_PROJECTION; status = swpls_wr_data(verbose, mbio_ptr, store_ptr, error); if (status == MB_SUCCESS) { *projection_rec_written = MB_YES; } store->kind = origkind; store->type = origtype; } /* write the record to file EXCEPT headers and projections */ if ((store->type != SWPLS_ID_SXP_HEADER_DATA) && (store->type != SWPLS_ID_PROJECTION)) { status = swpls_wr_data(verbose, mbio_ptr, store_ptr, 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 error: %d\n", *error); fprintf(stderr, "dbg2 Return status:\n"); fprintf(stderr, "dbg2 status: %d\n", status); } /* return status */ return (status); } /* mbr_wt_swplssxp */
/*--------------------------------------------------------------------*/ int mbr_wt_swplssxi(int verbose, void *mbio_ptr, void *store_ptr, int *error) { char *function_name = "mbr_wt_swplssxi"; int status = MB_SUCCESS; struct mb_io_struct *mb_io_ptr; struct mbsys_swathplus_struct *store; int *header_rec_written; int *projection_rec_written; /* 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 */ store = (struct mbsys_swathplus_struct *)store_ptr; /* get pointers to saved data */ header_rec_written = &(mb_io_ptr->save1); projection_rec_written = &(mb_io_ptr->save2); /* write header record if needed */ if ((store->sxi_header_set == MB_YES) && (*header_rec_written == MB_NO)) { int origkind = store->kind; int origtype = store->type; store->kind = MB_DATA_HEADER; store->type = SWPLS_ID_SXI_HEADER_DATA; status = swpls_wr_data(verbose, mbio_ptr, store_ptr, error); if (status == MB_SUCCESS) { *header_rec_written = MB_YES; } store->kind = origkind; store->type = origtype; } /* write projection record if needed */ if ((store->projection_set == MB_YES) && (*projection_rec_written == MB_NO)) { int origkind = store->kind; int origtype = store->type; store->kind = MB_DATA_PARAMETER; store->type = SWPLS_ID_PROJECTION; status = swpls_wr_data(verbose, mbio_ptr, store_ptr, error); if (status == MB_SUCCESS) { *projection_rec_written = MB_YES; } store->kind = origkind; store->type = origtype; } /* write projection file if needed */ // if ((*projection_file_created == MB_NO) && // (store->projection_set == MB_YES)) // { // sprintf(projection_file, "%s.prj", mb_io_ptr->file); // if ((pfp = fopen(projection_file, "w")) != NULL) // { // fprintf(pfp, "%s\n", store->projection_id); // *projection_file_created = MB_YES; // } // fclose(pfp); // } /* write next data to file */ status = swpls_wr_data(verbose, mbio_ptr, store_ptr, 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 error: %d\n", *error); fprintf(stderr, "dbg2 Return status:\n"); fprintf(stderr, "dbg2 status: %d\n", status); } return (status); } /* mbr_wt_swplssxi */