Minor improvements for resource management
This commit is contained in:
parent
4d0a32044d
commit
a8677d4f16
4 changed files with 9 additions and 3 deletions
|
@ -165,15 +165,17 @@ long int tgChopper::GenerateIndex( std::string path )
|
||||||
if ( fread( (void*)&index, sizeof(long int), 1, fp ) != 1 )
|
if ( fread( (void*)&index, sizeof(long int), 1, fp ) != 1 )
|
||||||
{
|
{
|
||||||
SG_LOG(SG_GENERAL, SG_ALERT, "Error reading Index file " << index_file << " abort");
|
SG_LOG(SG_GENERAL, SG_ALERT, "Error reading Index file " << index_file << " abort");
|
||||||
|
fclose( fp );
|
||||||
boost::interprocess::named_mutex::remove("tgChopper_index2");
|
boost::interprocess::named_mutex::remove("tgChopper_index2");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rewind( fp );
|
||||||
}
|
}
|
||||||
|
|
||||||
index++;
|
index++;
|
||||||
|
|
||||||
rewind( fp );
|
|
||||||
fwrite( (void*)&index, sizeof(long int), 1, fp );
|
fwrite( (void*)&index, sizeof(long int), 1, fp );
|
||||||
|
|
||||||
fclose( fp );
|
fclose( fp );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -185,7 +185,7 @@ void processLayer(OGRLayer* poLayer, tgChopper& results )
|
||||||
char* srsWkt;
|
char* srsWkt;
|
||||||
oSourceSRS->exportToWkt(&srsWkt);
|
oSourceSRS->exportToWkt(&srsWkt);
|
||||||
SG_LOG( SG_GENERAL, SG_DEBUG, "Source spatial reference system: " << srsWkt );
|
SG_LOG( SG_GENERAL, SG_DEBUG, "Source spatial reference system: " << srsWkt );
|
||||||
OGRFree(srsWkt);
|
CPLFree(srsWkt);
|
||||||
|
|
||||||
oTargetSRS.SetWellKnownGeogCS( "WGS84" );
|
oTargetSRS.SetWellKnownGeogCS( "WGS84" );
|
||||||
|
|
||||||
|
@ -417,6 +417,7 @@ int main( int argc, char **argv ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
GDALClose(poDS);
|
GDALClose(poDS);
|
||||||
|
GDALDestroyDriverManager();
|
||||||
|
|
||||||
SG_LOG(SG_GENERAL, SG_ALERT, "Saving to buckets");
|
SG_LOG(SG_GENERAL, SG_ALERT, "Saving to buckets");
|
||||||
results.Add_Extension("cliffs");
|
results.Add_Extension("cliffs");
|
||||||
|
|
|
@ -532,6 +532,8 @@ int main(int argc, const char **argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GDALDestroyDriverManager();
|
||||||
|
|
||||||
auto finish_time = std::chrono::high_resolution_clock::now();
|
auto finish_time = std::chrono::high_resolution_clock::now();
|
||||||
std::chrono::duration<double> elapsed = finish_time - start_time;
|
std::chrono::duration<double> elapsed = finish_time - start_time;
|
||||||
std::cout << std::endl << "Elapsed time: " << elapsed.count() << " seconds" << std::endl << std::endl;
|
std::cout << std::endl << "Elapsed time: " << elapsed.count() << " seconds" << std::endl << std::endl;
|
||||||
|
|
|
@ -459,6 +459,7 @@ void processLayer(OGRLayer* poLayer, tgChopper& results )
|
||||||
SG_LOG( SG_GENERAL, SG_ALERT, "Error in query expression '" << attribute_query << "'" );
|
SG_LOG( SG_GENERAL, SG_ALERT, "Error in query expression '" << attribute_query << "'" );
|
||||||
if (!continue_on_errors) {
|
if (!continue_on_errors) {
|
||||||
SG_LOG( SG_GENERAL, SG_ALERT, "Aborting!" );
|
SG_LOG( SG_GENERAL, SG_ALERT, "Aborting!" );
|
||||||
|
OCTDestroyCoordinateTransformation ( poCT );
|
||||||
exit( 1 );
|
exit( 1 );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue