1
0
Fork 0

Changed exit(1) to EXIT_FAILURE; use delegation in constructors;

check for endianness only once per invocation.
This commit is contained in:
James.Hester 2019-01-12 09:29:39 +11:00
parent 5586be95f5
commit dfe81ce9fa

View file

@ -64,11 +64,8 @@ TGDted::TGDted( int _res )
} }
TGDted::TGDted( int _res, const SGPath &file ) TGDted::TGDted( int _res, const SGPath &file ):TGDted(_res)
{ {
dted_resolution = _res;
data = new short int[MAX_DTED_SIZE][MAX_DTED_SIZE];
output_data = new short int[MAX_DTED_SIZE][MAX_DTED_SIZE];
TGDted::open( file ); TGDted::open( file );
} }
@ -109,7 +106,7 @@ TGDted::open ( const SGPath &f ) {
cout << "Proceeding with " << file_name.str() << endl; cout << "Proceeding with " << file_name.str() << endl;
} else { } else {
SG_LOG(SG_GENERAL, SG_ALERT, "Failed to issue system call " << command ); SG_LOG(SG_GENERAL, SG_ALERT, "Failed to issue system call " << command );
exit(1); return EXIT_FAILURE;
} }
} }
@ -168,6 +165,7 @@ TGDted::close () {
bool bool
TGDted::load( ) { TGDted::load( ) {
int size; int size;
bool little_endian = sgIsLittleEndian();
if ( dted_resolution == 1 ) { if ( dted_resolution == 1 ) {
cols = rows = size = 3601; cols = rows = size = 3601;
col_step = row_step = 1; col_step = row_step = 1;
@ -179,7 +177,7 @@ TGDted::load( ) {
cout << " are supported!" << endl; cout << " are supported!" << endl;
return false; return false;
} }
if (sgIsLittleEndian()) { if (little_endian) {
cout << "Little Endian: swapping input values" << endl; cout << "Little Endian: swapping input values" << endl;
} }
@ -200,7 +198,7 @@ TGDted::load( ) {
gzread(fd,&dummy,3); //block count gzread(fd,&dummy,3); //block count
gzread(fd,&longct,2); //Longitude count gzread(fd,&longct,2); //Longitude count
gzread(fd,&latct,2); //Latitude count gzread(fd,&latct,2); //Latitude count
if ( sgIsLittleEndian() ) { if ( little_endian ) {
sgEndianSwap(&longct); sgEndianSwap(&longct);
} }
// cout << "Longitude count " << longct << endl; // cout << "Longitude count " << longct << endl;
@ -209,7 +207,7 @@ TGDted::load( ) {
if ( gzread ( fd, var, 2 ) != sizeof(short) ) { if ( gzread ( fd, var, 2 ) != sizeof(short) ) {
return false; return false;
} }
if ( sgIsLittleEndian() ) { if ( little_endian ) {
sgEndianSwap( (unsigned short int*)var); sgEndianSwap( (unsigned short int*)var);
} }
} }