Skip to content

Commit 7b62f9e

Browse files
authored
Merge pull request #21 from avalentino/feature/ASA-WV
Fix support for ASA_WVI_1P
2 parents 4ee3479 + ea99f51 commit 7b62f9e

6 files changed

Lines changed: 24 additions & 19 deletions

File tree

src/epr_band.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ uint epr_get_num_bands(EPR_SProductId* product_id) {
218218
"epr_get_num_bands: product_id must not be NULL");
219219
return (uint) -1;
220220
}
221+
if (product_id->band_ids == NULL)
222+
return 0;
221223
return product_id->band_ids->length;
222224
}
223225

@@ -231,7 +233,7 @@ EPR_SBandId* epr_get_band_id_at(EPR_SProductId* product_id, uint index) {
231233
"epr_get_band_id_at: product_id must not be NULL");
232234
return NULL;
233235
}
234-
if (index >= product_id->band_ids->length) {
236+
if (index >= epr_get_num_bands(product_id)) {
235237
epr_set_err(e_err_index_out_of_range,
236238
"epr_get_band_id_at: band index out of range");
237239
return NULL;

src/epr_dddb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2150,7 +2150,7 @@ static const struct RecordDescriptor ASAR_Wave_Geolocation_ADSR_asar_rec_data[]
21502150
{"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)"},
21512151
{"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"},
21522152
{"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"},
2153-
{"spare_1", e_tid_spare, NULL, 4, "1", "Spare"}
2153+
{"heading", e_tid_float, "deg", 4, "1", "Subsatellite Track Heading. Relative to North of centre point."}
21542154
};
21552155

21562156
static const struct RecordDescriptor ASAR_Wave_Param_ADSR_asar_rec_data[] = {
@@ -3727,7 +3727,7 @@ static const struct DatasetDescriptor ASA_WVI_1P_dataset_data[] = {
37273727
{"GEOLOCATION_ADS", "GEOLOCATION ADS", ASAR_Wave_Geolocation_ADSR_asar_rec_data, "Wave Mode Geolocation ADS"},
37283728
{"PROCESSING_PARAMS_ADS", "PROCESSING PARAMS ADS", ASAR_Wave_Param_ADSR_asar_rec_data, "Wave Mode processing parameters"},
37293729
{"CROSS_SPECTRA_MDS", "CROSS SPECTRA MDS", ASAR_Spectra_MDSR_asar_rec_data, "Measurement Data Set containing spectra. 1 MDSR per spectra."},
3730-
{"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)"},
3730+
{"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)"},
37313731
{"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)"},
37323732
{"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)"},
37333733
{"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)"},

src/epr_msph.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -534,8 +534,8 @@ void epr_set_header_field_values(EPR_SRecord* record, EPR_SPtrArray* header_valu
534534

535535
uint epr_compare_param(EPR_SProductId* product_id)
536536
{
537-
EPR_SDSD* dsd;
538-
uint of;
537+
EPR_SDSD* dsd = NULL;
538+
uint dsd_index = 0;
539539

540540
epr_clear_err();
541541

@@ -544,10 +544,14 @@ uint epr_compare_param(EPR_SProductId* product_id)
544544
return 0UL;
545545
}
546546

547-
of = epr_api.epr_head_size;
548-
dsd = (EPR_SDSD*)epr_get_ptr_array_elem_at(product_id->dsd_array, 0);
547+
for (dsd_index = 0; dsd_index < product_id->dsd_array->length; dsd_index++) {
548+
dsd = (EPR_SDSD*)epr_get_ptr_array_elem_at(product_id->dsd_array, dsd_index);
549+
if (dsd->ds_offset > 0)
550+
break;
551+
}
552+
549553
if (dsd->ds_offset == epr_api.epr_head_size)
550-
return of;
554+
return epr_api.epr_head_size;
551555

552556
return 0UL;
553557
}

src/epr_param.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,9 @@ int epr_set_dyn_dddb_params(EPR_SProductId* product_id)
192192
/* AATSR does NOT have any dynamic parameters in DDDB */
193193

194194
/* ASAR */
195-
else if ((strcmp(EPR_ENVISAT_PRODUCT_ASAR, epr_sub_string((char*)product_field->elems, 0, 3)) == 0) ||
196-
(strcmp(EPR_ENVISAT_PRODUCT_SAR, epr_sub_string((char*)product_field->elems, 0, 3)) == 0)) {
195+
else if (((strcmp(EPR_ENVISAT_PRODUCT_ASAR, epr_sub_string((char*)product_field->elems, 0, 3)) == 0) ||
196+
(strcmp(EPR_ENVISAT_PRODUCT_SAR, epr_sub_string((char*)product_field->elems, 0, 3)) == 0)) &&
197+
(strncmp(product_id->id_string, "ASA_WVI_1P", 10) != 0)) {
197198

198199
field = epr_get_field(product_id->sph_record, "LINE_LENGTH");
199200
if (field == NULL) {

src/epr_product.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -217,16 +217,14 @@ EPR_SProductId* epr_open_product(const char* product_file_path) {
217217

218218
epr_log(e_log_info, "creating band identifiers");
219219
product_id->band_ids = epr_create_band_ids(product_id);
220-
if (product_id->band_ids == NULL) {
221-
epr_close_product(product_id);
222-
return NULL;
223-
}
224220

225221
/* Get scene size */
226-
product_id->scene_width = epr_compute_scene_width(product_id);
227-
product_id->scene_height = epr_compute_scene_height(product_id);
228-
sprintf(message_buffer, "product scene raster size: %u x %u", product_id->scene_width, product_id->scene_height);
229-
epr_log(e_log_debug, message_buffer);
222+
if (product_id->band_ids != NULL) {
223+
product_id->scene_width = epr_compute_scene_width(product_id);
224+
product_id->scene_height = epr_compute_scene_height(product_id);
225+
sprintf(message_buffer, "product scene raster size: %u x %u", product_id->scene_width, product_id->scene_height);
226+
epr_log(e_log_debug, message_buffer);
227+
}
230228

231229
return product_id;
232230
}

src/test/api_unit_tests.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ void evaluate_product_assert(STestLine* test_line) {
255255
if (equal_str(value_ref, _pas_band_ids_length)) {
256256
if (!evaluate_equal_types(test_line, e_tid_uint))
257257
goto failure;
258-
detail->actual.ui = product_id->band_ids->length;
258+
detail->actual.ui = product_id->band_ids == NULL ? 0 : product_id->band_ids->length;
259259
} else if (equal_str(value_ref, _pas_dataset_ids_length)) {
260260
if (!evaluate_equal_types(test_line, e_tid_uint))
261261
goto failure;

0 commit comments

Comments
 (0)