[output] Maintenance
This commit is contained in:
parent
275d5cc4f6
commit
b83c79f6b0
2 changed files with 52 additions and 48 deletions
|
@ -24,7 +24,6 @@
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -33,86 +32,90 @@
|
||||||
#include <simgear/bucket/newbucket.hxx>
|
#include <simgear/bucket/newbucket.hxx>
|
||||||
#include <simgear/misc/sg_path.hxx>
|
#include <simgear/misc/sg_path.hxx>
|
||||||
|
|
||||||
using std::string;
|
|
||||||
|
|
||||||
// update index file (list of objects to be included in final scenery build)
|
// update index file (list of objects to be included in final scenery build)
|
||||||
void write_index_object( const string& base, const SGBucket& b, const string& name )
|
void write_index_object(const std::string& base, const SGBucket& b, const std::string& name)
|
||||||
{
|
{
|
||||||
string dir = base + "/" + b.gen_base_path();
|
using namespace std::string_literals;
|
||||||
SGPath sgp( dir );
|
|
||||||
sgp.append( "dummy" );
|
|
||||||
sgp.create_dir( 0755 );
|
|
||||||
|
|
||||||
string file = dir + "/" + b.gen_index_str() + ".ind";
|
std::string dir = base + "/"s + b.gen_base_path();
|
||||||
SG_LOG( SG_GENERAL, SG_DEBUG, "Writing object to " << file );
|
SGPath sgp(dir);
|
||||||
|
sgp.append("dummy"s);
|
||||||
|
sgp.create_dir(0755);
|
||||||
|
|
||||||
FILE *fp;
|
std::string file = dir + "/"s + b.gen_index_str() + ".ind"s;
|
||||||
if ( (fp = fopen( file.c_str(), "a" )) == NULL ) {
|
SG_LOG(SG_GENERAL, SG_DEBUG, "Writing object to " << file);
|
||||||
SG_LOG( SG_GENERAL, SG_ALERT, "ERROR: opening " << file << " for writing!" );
|
|
||||||
|
FILE* fp;
|
||||||
|
if ((fp = fopen(file.c_str(), "a")) == NULL) {
|
||||||
|
SG_LOG(SG_GENERAL, SG_ALERT, "ERROR: opening " << file << " for writing!");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf( fp, "OBJECT %s\n", name.c_str() );
|
fprintf(fp, "OBJECT %s\n", name.c_str());
|
||||||
fclose( fp );
|
fclose(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// update index file (list of shared objects to be included in final scenery build)
|
// update index file (list of shared objects to be included in final scenery build)
|
||||||
void write_index_object_shared( const string &base, const SGBucket &b,
|
void write_index_object_shared(const std::string& base, const SGBucket& b,
|
||||||
const SGGeod &p, const string& name,
|
const SGGeod& p, const std::string& name,
|
||||||
const double &heading )
|
const double& heading)
|
||||||
{
|
{
|
||||||
string dir = base + "/" + b.gen_base_path();
|
using namespace std::string_literals;
|
||||||
SGPath sgp( dir );
|
|
||||||
sgp.append( "dummy" );
|
|
||||||
sgp.create_dir( 0755 );
|
|
||||||
|
|
||||||
string file = dir + "/" + b.gen_index_str() + ".ind";
|
std::string dir = base + "/"s + b.gen_base_path();
|
||||||
SG_LOG( SG_GENERAL, SG_DEBUG, "Writing shared object to " << file );
|
SGPath sgp(dir);
|
||||||
|
sgp.append("dummy"s);
|
||||||
|
sgp.create_dir(0755);
|
||||||
|
|
||||||
FILE *fp;
|
std::string file = dir + "/"s + b.gen_index_str() + ".ind"s;
|
||||||
if ( (fp = fopen( file.c_str(), "a" )) == NULL ) {
|
SG_LOG(SG_GENERAL, SG_DEBUG, "Writing shared object to " << file);
|
||||||
SG_LOG( SG_GENERAL, SG_ALERT, "ERROR: opening " << file << " for writing!" );
|
|
||||||
|
FILE* fp;
|
||||||
|
if ((fp = fopen(file.c_str(), "a")) == NULL) {
|
||||||
|
SG_LOG(SG_GENERAL, SG_ALERT, "ERROR: opening " << file << " for writing!");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf( fp, "OBJECT_SHARED %s %.6f %.6f %.1f %.2f\n", name.c_str(),
|
fprintf(fp, "OBJECT_SHARED %s %.6f %.6f %.1f %.2f\n", name.c_str(),
|
||||||
p.getLongitudeDeg(), p.getLatitudeDeg(), p.getElevationM(), heading );
|
p.getLongitudeDeg(), p.getLatitudeDeg(), p.getElevationM(), heading);
|
||||||
fclose( fp );
|
fclose(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// update index file (list of shared objects to be included in final scenery build)
|
// update index file (list of shared objects to be included in final scenery build)
|
||||||
void write_index_object_sign( const string &base, const SGBucket &b,
|
void write_index_object_sign(const std::string& base, const SGBucket& b,
|
||||||
const SGGeod &p, const string& sign,
|
const SGGeod& p, const std::string& sign,
|
||||||
const double &heading, const int &size)
|
const double& heading, const int& size)
|
||||||
{
|
{
|
||||||
string dir = base + "/" + b.gen_base_path();
|
using namespace std::string_literals;
|
||||||
SGPath sgp( dir );
|
|
||||||
sgp.append( "dummy" );
|
|
||||||
sgp.create_dir( 0755 );
|
|
||||||
|
|
||||||
string file = dir + "/" + b.gen_index_str() + ".ind";
|
std::string dir = base + "/"s + b.gen_base_path();
|
||||||
SG_LOG( SG_GENERAL, SG_DEBUG, "Writing sign to " << file );
|
SGPath sgp(dir);
|
||||||
|
sgp.append("dummy"s);
|
||||||
|
sgp.create_dir(0755);
|
||||||
|
|
||||||
FILE *fp;
|
std::string file = dir + "/"s + b.gen_index_str() + ".ind"s;
|
||||||
if ( (fp = fopen( file.c_str(), "a" )) == NULL ) {
|
SG_LOG(SG_GENERAL, SG_DEBUG, "Writing sign to " << file);
|
||||||
SG_LOG( SG_GENERAL, SG_ALERT, "ERROR: opening " << file << " for writing!" );
|
|
||||||
|
FILE* fp;
|
||||||
|
if ((fp = fopen(file.c_str(), "a")) == NULL) {
|
||||||
|
SG_LOG(SG_GENERAL, SG_ALERT, "ERROR: opening " << file << " for writing!");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf( fp, "OBJECT_SIGN %s %.6f %.6f %.1f %.2f %d\n", sign.c_str(),
|
fprintf(fp, "OBJECT_SIGN %s %.6f %.6f %.1f %.2f %d\n", sign.c_str(),
|
||||||
p.getLongitudeDeg(), p.getLatitudeDeg(), p.getElevationM(), heading, size );
|
p.getLongitudeDeg(), p.getLatitudeDeg(), p.getElevationM(), heading, size);
|
||||||
fclose( fp );
|
fclose(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// purge the existing index file when it already exists
|
// purge the existing index file when it already exists
|
||||||
void truncate_index_file( const std::string& fileName )
|
void truncate_index_file(const std::string& fileName)
|
||||||
{
|
{
|
||||||
if (static_cast<bool>(std::ifstream(fileName)))
|
if (static_cast<bool>(std::ifstream(fileName))) {
|
||||||
{
|
SG_LOG(SG_GENERAL, SG_DEBUG, "Truncating file " << fileName);
|
||||||
SG_LOG( SG_GENERAL, SG_DEBUG, "Truncating file " << fileName );
|
|
||||||
|
|
||||||
std::ofstream fsIndex;
|
std::ofstream fsIndex;
|
||||||
fsIndex.open(fileName, std::ofstream::out | std::ofstream::trunc);
|
fsIndex.open(fileName, std::ofstream::out | std::ofstream::trunc);
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// update index file (list of objects to be included in final scenery build)
|
// update index file (list of objects to be included in final scenery build)
|
||||||
void write_index_object(const std::string& base, const SGBucket& b, const std::string& name);
|
void write_index_object(const std::string& base, const SGBucket& b, const std::string& name);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue