diff --git a/src/epr_band.c b/src/epr_band.c index 06f1325..6a68982 100644 --- a/src/epr_band.c +++ b/src/epr_band.c @@ -218,6 +218,8 @@ uint epr_get_num_bands(EPR_SProductId* product_id) { "epr_get_num_bands: product_id must not be NULL"); return (uint) -1; } + if (product_id->band_ids == NULL) + return 0; return product_id->band_ids->length; } @@ -231,7 +233,7 @@ EPR_SBandId* epr_get_band_id_at(EPR_SProductId* product_id, uint index) { "epr_get_band_id_at: product_id must not be NULL"); return NULL; } - if (index >= product_id->band_ids->length) { + if (index >= epr_get_num_bands(product_id)) { epr_set_err(e_err_index_out_of_range, "epr_get_band_id_at: band index out of range"); return NULL; diff --git a/src/epr_dddb.c b/src/epr_dddb.c index 4103375..3d8b1ac 100644 --- a/src/epr_dddb.c +++ b/src/epr_dddb.c @@ -2150,7 +2150,7 @@ static const struct RecordDescriptor ASAR_Wave_Geolocation_ADSR_asar_rec_data[] {"attach_flag", e_tid_uchar, "flag", 1, "1", "Attachment Flag (set to 1 if unable to compute the cross spectra for a given SLC imagette (i.e. no Cross Spectra MDSR corresponding to this ADSR), set to 0 otherwise)"}, {"center_lat", e_tid_int, "(1e-6) degrees", 4, "1", "Geodetic latitude of center point (positive north) This is the center point of the wave cell. It is calculated after the cross spectra processing, and thus may differ from the center sample latitude of the SLC imagette if slant range to ground range conve"}, {"center_long", e_tid_int, "(1e-6) degrees", 4, "1", "Geodetic longitude of center point (positive east)This is the center point of the wave cell. It is calculated after the cross spectra processing, and thus may differ from the center sample latitude of the SLC imagette if slant range to ground range conver"}, - {"spare_1", e_tid_spare, NULL, 4, "1", "Spare"} + {"heading", e_tid_float, "deg", 4, "1", "Subsatellite Track Heading. Relative to North of centre point."} }; static const struct RecordDescriptor ASAR_Wave_Param_ADSR_asar_rec_data[] = { @@ -3727,7 +3727,7 @@ static const struct DatasetDescriptor ASA_WVI_1P_dataset_data[] = { {"GEOLOCATION_ADS", "GEOLOCATION ADS", ASAR_Wave_Geolocation_ADSR_asar_rec_data, "Wave Mode Geolocation ADS"}, {"PROCESSING_PARAMS_ADS", "PROCESSING PARAMS ADS", ASAR_Wave_Param_ADSR_asar_rec_data, "Wave Mode processing parameters"}, {"CROSS_SPECTRA_MDS", "CROSS SPECTRA MDS", ASAR_Spectra_MDSR_asar_rec_data, "Measurement Data Set containing spectra. 1 MDSR per spectra."}, - {"SLC_IMAGETTE_MDS", "SLC IMAGETTE MDS", ASAR_Image_MDSR_SLC_asar_rec_data, "Measurement Data Set for a single imagette (corresponds to one spectrum MDSR)"}, + {"SLC_IMAGETTE_MDS_000", "SLC IMAGETTE MDS 000", ASAR_Image_MDSR_SLC_asar_rec_data, "Measurement Data Set for a single imagette (corresponds to one spectrum MDSR)"}, {"SLC_IMAGETTE_MDS_001", "SLC IMAGETTE MDS 001", ASAR_Image_MDSR_SLC_asar_rec_data, "Measurement Data Set for a single imagette (corresponds to one spectrum MDSR)"}, {"SLC_IMAGETTE_MDS_002", "SLC IMAGETTE MDS 002", ASAR_Image_MDSR_SLC_asar_rec_data, "Measurement Data Set for a single imagette (corresponds to one spectrum MDSR)"}, {"SLC_IMAGETTE_MDS_003", "SLC IMAGETTE MDS 003", ASAR_Image_MDSR_SLC_asar_rec_data, "Measurement Data Set for a single imagette (corresponds to one spectrum MDSR)"}, diff --git a/src/epr_msph.c b/src/epr_msph.c index 9b728bb..cea3780 100644 --- a/src/epr_msph.c +++ b/src/epr_msph.c @@ -534,8 +534,8 @@ void epr_set_header_field_values(EPR_SRecord* record, EPR_SPtrArray* header_valu uint epr_compare_param(EPR_SProductId* product_id) { - EPR_SDSD* dsd; - uint of; + EPR_SDSD* dsd = NULL; + uint dsd_index = 0; epr_clear_err(); @@ -544,10 +544,14 @@ uint epr_compare_param(EPR_SProductId* product_id) return 0UL; } - of = epr_api.epr_head_size; - dsd = (EPR_SDSD*)epr_get_ptr_array_elem_at(product_id->dsd_array, 0); + for (dsd_index = 0; dsd_index < product_id->dsd_array->length; dsd_index++) { + dsd = (EPR_SDSD*)epr_get_ptr_array_elem_at(product_id->dsd_array, dsd_index); + if (dsd->ds_offset > 0) + break; + } + if (dsd->ds_offset == epr_api.epr_head_size) - return of; + return epr_api.epr_head_size; return 0UL; } diff --git a/src/epr_param.c b/src/epr_param.c index 5720890..b15442f 100644 --- a/src/epr_param.c +++ b/src/epr_param.c @@ -192,8 +192,9 @@ int epr_set_dyn_dddb_params(EPR_SProductId* product_id) /* AATSR does NOT have any dynamic parameters in DDDB */ /* ASAR */ - else if ((strcmp(EPR_ENVISAT_PRODUCT_ASAR, epr_sub_string((char*)product_field->elems, 0, 3)) == 0) || - (strcmp(EPR_ENVISAT_PRODUCT_SAR, epr_sub_string((char*)product_field->elems, 0, 3)) == 0)) { + else if (((strcmp(EPR_ENVISAT_PRODUCT_ASAR, epr_sub_string((char*)product_field->elems, 0, 3)) == 0) || + (strcmp(EPR_ENVISAT_PRODUCT_SAR, epr_sub_string((char*)product_field->elems, 0, 3)) == 0)) && + (strncmp(product_id->id_string, "ASA_WVI_1P", 10) != 0)) { field = epr_get_field(product_id->sph_record, "LINE_LENGTH"); if (field == NULL) { diff --git a/src/epr_product.c b/src/epr_product.c index b93c38f..d7c7f88 100644 --- a/src/epr_product.c +++ b/src/epr_product.c @@ -217,16 +217,14 @@ EPR_SProductId* epr_open_product(const char* product_file_path) { epr_log(e_log_info, "creating band identifiers"); product_id->band_ids = epr_create_band_ids(product_id); - if (product_id->band_ids == NULL) { - epr_close_product(product_id); - return NULL; - } /* Get scene size */ - product_id->scene_width = epr_compute_scene_width(product_id); - product_id->scene_height = epr_compute_scene_height(product_id); - sprintf(message_buffer, "product scene raster size: %u x %u", product_id->scene_width, product_id->scene_height); - epr_log(e_log_debug, message_buffer); + if (product_id->band_ids != NULL) { + product_id->scene_width = epr_compute_scene_width(product_id); + product_id->scene_height = epr_compute_scene_height(product_id); + sprintf(message_buffer, "product scene raster size: %u x %u", product_id->scene_width, product_id->scene_height); + epr_log(e_log_debug, message_buffer); + } return product_id; } diff --git a/src/test/api_unit_tests.c b/src/test/api_unit_tests.c index 22f219d..0a5a639 100644 --- a/src/test/api_unit_tests.c +++ b/src/test/api_unit_tests.c @@ -255,7 +255,7 @@ void evaluate_product_assert(STestLine* test_line) { if (equal_str(value_ref, _pas_band_ids_length)) { if (!evaluate_equal_types(test_line, e_tid_uint)) goto failure; - detail->actual.ui = product_id->band_ids->length; + detail->actual.ui = product_id->band_ids == NULL ? 0 : product_id->band_ids->length; } else if (equal_str(value_ref, _pas_dataset_ids_length)) { if (!evaluate_equal_types(test_line, e_tid_uint)) goto failure;