remove using std::
clean up
This commit is contained in:
parent
4d777cc802
commit
a263afd93b
1 changed files with 63 additions and 75 deletions
|
@ -21,59 +21,47 @@
|
||||||
// $Id: master.cxx,v 1.9 2004-11-19 22:25:49 curt Exp $
|
// $Id: master.cxx,v 1.9 2004-11-19 22:25:49 curt Exp $
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
# include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <simgear/compiler.h>
|
#include <simgear/compiler.h>
|
||||||
|
|
||||||
#include <stdlib.h> // for system()
|
#include <stdlib.h> // for system()
|
||||||
#include <sys/stat.h> // for stat()
|
#include <sys/stat.h> // for stat()
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
# include <unistd.h> // for stat()
|
#include <unistd.h> // for stat()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include <simgear/bucket/newbucket.hxx>
|
#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
|
// return true if file exists
|
||||||
static bool file_exists( const string& file ) {
|
static bool file_exists(const std::string& file)
|
||||||
|
{
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
|
|
||||||
if ( stat( file.c_str(), &buf ) == 0 ) {
|
if (stat(file.c_str(), &buf) == 0) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// check if the specified tile has data defined for it
|
// check if the specified tile has data defined for it
|
||||||
static bool has_data( const string& path, const SGBucket& b ) {
|
static bool has_data(const std::string& path, const SGBucket& b)
|
||||||
string array_file = path + "DEM-3/" + b.gen_base_path()
|
{
|
||||||
+ "/" + b.gen_index_str() + ".arr";
|
std::string array_file = path + "DEM-3/" + b.gen_base_path() + "/" + b.gen_index_str() + ".arr";
|
||||||
if ( file_exists( array_file ) ) {
|
if (file_exists(array_file)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
array_file += ".gz";
|
array_file += ".gz";
|
||||||
if ( file_exists( array_file ) ) {
|
if (file_exists(array_file)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -81,26 +69,26 @@ static bool has_data( const string& path, const SGBucket& b ) {
|
||||||
|
|
||||||
|
|
||||||
// build the tile and check for success
|
// build the tile and check for success
|
||||||
bool build_tile( const string& work_base, const string& output_base,
|
bool build_tile(const std::string& work_base, const std::string& output_base,
|
||||||
const SGBucket& b ) {
|
const SGBucket& b)
|
||||||
string result_file = "result";
|
{
|
||||||
|
std::string result_file = "result";
|
||||||
|
|
||||||
string command = "./construct " + work_base + " " + output_base + " "
|
std::string command = "./construct " + work_base + " " + output_base + " " + b.gen_index_str() + " > " + result_file + " 2>&1";
|
||||||
+ b.gen_index_str() + " > " + result_file + " 2>&1";
|
std::cout << command << std::endl;
|
||||||
cout << command << 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];
|
char line[256];
|
||||||
while ( fgets( line, 256, fp ) != NULL ) {
|
while (fgets(line, 256, fp) != NULL) {
|
||||||
string line_str = line;
|
std::string line_str = line;
|
||||||
line_str = line_str.substr(0, line_str.length() - 1);
|
line_str = line_str.substr(0, line_str.length() - 1);
|
||||||
cout << line_str << endl;
|
std::cout << line_str << std::endl;
|
||||||
if ( line_str == "[Finished successfully]" ) {
|
if (line_str == "[Finished successfully]") {
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
@ -109,23 +97,25 @@ bool build_tile( const string& work_base, const string& output_base,
|
||||||
|
|
||||||
|
|
||||||
// display usage and exit
|
// display usage and exit
|
||||||
void usage( const string name ) {
|
void usage(const std::string name)
|
||||||
cout << "Usage: " << name << " <work_base> <output_base>" << endl;
|
{
|
||||||
|
std::cout << "Usage: " << name << " <work_base> <output_base>" << std::endl;
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char** argv)
|
||||||
|
{
|
||||||
double lon, lat;
|
double lon, lat;
|
||||||
|
|
||||||
if ( argc < 3 ) {
|
if (argc < 3) {
|
||||||
usage( argv[0] );
|
usage(argv[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
string work_base = argv[1];
|
std::string work_base = argv[1];
|
||||||
string output_base = argv[2];
|
std::string output_base = argv[2];
|
||||||
|
|
||||||
SGBucket tmp1( 0.0, 0.0 );
|
SGBucket tmp1(0.0, 0.0);
|
||||||
|
|
||||||
double dy = tmp1.get_height();
|
double dy = tmp1.get_height();
|
||||||
lat = 68.75 + dy * 0.5;
|
lat = 68.75 + dy * 0.5;
|
||||||
|
@ -133,34 +123,32 @@ int main(int argc, char **argv) {
|
||||||
bool start_lon = true;
|
bool start_lon = true;
|
||||||
lon = -152.9 /* + (1.0/16.0) */;
|
lon = -152.9 /* + (1.0/16.0) */;
|
||||||
|
|
||||||
while ( lat <= 90.0 ) {
|
while (lat <= 90.0) {
|
||||||
SGBucket tmp2( 0.0, lat );
|
SGBucket tmp2(0.0, lat);
|
||||||
double dx = tmp2.get_width();
|
double dx = tmp2.get_width();
|
||||||
|
|
||||||
if ( ! start_lon ) {
|
if (!start_lon) {
|
||||||
lon = -180 + dx * 0.5;
|
lon = -180 + dx * 0.5;
|
||||||
} else {
|
} else {
|
||||||
start_lon = false;
|
start_lon = false;
|
||||||
}
|
}
|
||||||
while ( lon <= 180.0 ) {
|
while (lon <= 180.0) {
|
||||||
SGBucket b( lon, lat );
|
SGBucket b(lon, lat);
|
||||||
cout << "Bucket = " << b << endl;
|
std::cout << "Bucket = " << b << std::endl;
|
||||||
|
|
||||||
if ( has_data( work_base, b ) ) {
|
if (has_data(work_base, b)) {
|
||||||
if ( ! build_tile( work_base, output_base, b ) ) {
|
if (!build_tile(work_base, output_base, b)) {
|
||||||
cout << "error building last tile" << endl;
|
std::cout << "error building last tile" << std::endl;
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lon += dx;
|
lon += dx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
lat += dy;
|
lat += dy;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue