1
0
Fork 0

remove using std::

clean up
This commit is contained in:
scttgs0 2023-05-07 20:33:15 -05:00
parent 4d777cc802
commit a263afd93b

View file

@ -21,59 +21,47 @@
// $Id: master.cxx,v 1.9 2004-11-19 22:25:49 curt Exp $
#ifdef HAVE_CONFIG_H
# include <config.h>
#include <config.h>
#endif
#include <simgear/compiler.h>
#include <stdlib.h> // for system()
#include <sys/stat.h> // for stat()
#include <stdlib.h> // for system()
#include <sys/stat.h> // for stat()
#ifndef _MSC_VER
# include <unistd.h> // for stat()
#include <unistd.h> // for stat()
#endif
#include <string>
#include <iostream>
#include <string>
#include <simgear/bucket/newbucket.hxx>
// #include <Include/fg_constants.h>
// #include <Debug/logstream.hxx>
// #include <Array/array.hxx>
// #include <Clipper/clipper.hxx>
// #include <GenOutput/genobj.hxx>
// #include <Match/match.hxx>
// #include <Triangulate/triangle.hxx>
using std::string;
using std::cout;
using std::endl;
// return true if file exists
static bool file_exists( const string& file ) {
static bool file_exists(const std::string& file)
{
struct stat buf;
if ( stat( file.c_str(), &buf ) == 0 ) {
return true;
if (stat(file.c_str(), &buf) == 0) {
return true;
} else {
return false;
return false;
}
}
// check if the specified tile has data defined for it
static bool has_data( const string& path, const SGBucket& b ) {
string array_file = path + "DEM-3/" + b.gen_base_path()
+ "/" + b.gen_index_str() + ".arr";
if ( file_exists( array_file ) ) {
return true;
static bool has_data(const std::string& path, const SGBucket& b)
{
std::string array_file = path + "DEM-3/" + b.gen_base_path() + "/" + b.gen_index_str() + ".arr";
if (file_exists(array_file)) {
return true;
}
array_file += ".gz";
if ( file_exists( array_file ) ) {
return true;
if (file_exists(array_file)) {
return true;
}
return false;
@ -81,26 +69,26 @@ static bool has_data( const string& path, const SGBucket& b ) {
// build the tile and check for success
bool build_tile( const string& work_base, const string& output_base,
const SGBucket& b ) {
string result_file = "result";
bool build_tile(const std::string& work_base, const std::string& output_base,
const SGBucket& b)
{
std::string result_file = "result";
string command = "./construct " + work_base + " " + output_base + " "
+ b.gen_index_str() + " > " + result_file + " 2>&1";
cout << command << endl;
std::string command = "./construct " + work_base + " " + output_base + " " + b.gen_index_str() + " > " + result_file + " 2>&1";
std::cout << command << std::endl;
system( command.c_str() );
system(command.c_str());
FILE *fp = fopen( result_file.c_str(), "r" );
FILE* fp = fopen(result_file.c_str(), "r");
char line[256];
while ( fgets( line, 256, fp ) != NULL ) {
string line_str = line;
line_str = line_str.substr(0, line_str.length() - 1);
cout << line_str << endl;
if ( line_str == "[Finished successfully]" ) {
fclose(fp);
return true;
}
while (fgets(line, 256, fp) != NULL) {
std::string line_str = line;
line_str = line_str.substr(0, line_str.length() - 1);
std::cout << line_str << std::endl;
if (line_str == "[Finished successfully]") {
fclose(fp);
return true;
}
}
fclose(fp);
@ -109,23 +97,25 @@ bool build_tile( const string& work_base, const string& output_base,
// display usage and exit
void usage( const string name ) {
cout << "Usage: " << name << " <work_base> <output_base>" << endl;
void usage(const std::string name)
{
std::cout << "Usage: " << name << " <work_base> <output_base>" << std::endl;
exit(-1);
}
int main(int argc, char **argv) {
int main(int argc, char** argv)
{
double lon, lat;
if ( argc < 3 ) {
usage( argv[0] );
if (argc < 3) {
usage(argv[0]);
}
string work_base = argv[1];
string output_base = argv[2];
std::string work_base = argv[1];
std::string output_base = argv[2];
SGBucket tmp1( 0.0, 0.0 );
SGBucket tmp1(0.0, 0.0);
double dy = tmp1.get_height();
lat = 68.75 + dy * 0.5;
@ -133,34 +123,32 @@ int main(int argc, char **argv) {
bool start_lon = true;
lon = -152.9 /* + (1.0/16.0) */;
while ( lat <= 90.0 ) {
SGBucket tmp2( 0.0, lat );
double dx = tmp2.get_width();
while (lat <= 90.0) {
SGBucket tmp2(0.0, lat);
double dx = tmp2.get_width();
if ( ! start_lon ) {
lon = -180 + dx * 0.5;
} else {
start_lon = false;
}
while ( lon <= 180.0 ) {
SGBucket b( lon, lat );
cout << "Bucket = " << b << endl;
if (!start_lon) {
lon = -180 + dx * 0.5;
} else {
start_lon = false;
}
while (lon <= 180.0) {
SGBucket b(lon, lat);
std::cout << "Bucket = " << b << std::endl;
if ( has_data( work_base, b ) ) {
if ( ! build_tile( work_base, output_base, b ) ) {
cout << "error building last tile" << endl;
exit(-1);
}
}
if (has_data(work_base, b)) {
if (!build_tile(work_base, output_base, b)) {
std::cout << "error building last tile" << std::endl;
exit(-1);
}
}
lon += dx;
}
lon += dx;
}
lat += dy;
lat += dy;
}
return 0;
}