This illustrates how to use a file-based stream to load an EDB file's data. It also illustrates how to make use of the fields found in the eaarlio_edb structure.
If you're primarily interested in reading raster data, you'll probably want to use eaarlio_file_flight instead. See example_flight_read_rasters.c.
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[])
{
if(argc < 2 || 0 == strncmp(argv[1], "-h", 3) || 0 == strncmp(argv[1], "--help", 7)) {
printf("Usage: example_edb_read [-h] <edb file> [<raster number> ...]\n");
printf("Example of reading using an EDB\n");
printf("\n");
printf(" -h, --help display this help and exit\n");
printf(" <edb file> EDB file for dataset\n");
printf(" <raster number> raster numbers to read\n");
return 1;
}
char const *edb_file = argv[1];
int i;
int failed;
uint32_t record_number;
char const *tld_file = NULL;
int include_records = 1;
int include_files = 1;
if(failed)
return 1;
if(failed)
return 1;
err = stream.
close(&stream);
if(failed)
return 1;
printf(
"file_count: %" PRIu32
"\n", edb.
file_count);
for(i = 2; i < argc; i++) {
record_number = (uint32_t)atoi(argv[i]);
printf("\nRecord %" PRIu32 "\n", record_number);
printf("Out of bounds, skipping\n");
continue;
}
record = edb.
records[record_number - 1];
printf(
"file_index: %" PRIi16
"\n", record.
file_index);
printf(
"pulse_count: %" PRIu8
"\n", record.
pulse_count);
printf(
"digitizer: %" PRIu8
"\n", record.
digitizer);
printf("file_index is out of bounds\n");
continue;
}
printf("tld file: %s\n", tld_file);
}
failed =
if(failed)
return 1;
return 0;
}