diff --git a/src/Lib/Array/array.cxx b/src/Lib/Array/array.cxx index 4eee6a13..0dc3cc9d 100644 --- a/src/Lib/Array/array.cxx +++ b/src/Lib/Array/array.cxx @@ -38,19 +38,20 @@ using std::string; -TGArray::TGArray( void ): +TGArray::TGArray() : array_in(NULL), fitted_in(NULL), + originx(0.0), originy(0.0), + cols(0), rows(0), + rectified(false), + col_step(0.0), row_step(0.0), in_data(NULL) { - } -TGArray::TGArray( const string &file ): - array_in(NULL), - fitted_in(NULL), - in_data(NULL) +TGArray::TGArray( const string &file ) : + TGArray() { TGArray::open(file); } @@ -248,7 +249,7 @@ void TGArray::parse_bin() // Write out an array. If rectified is true, the heights have been adjusted // for discontinuities. -void TGArray::write_bin(const string root_dir, bool rectified, SGBucket& b) { +void TGArray::write_bin(const string& root_dir, bool rectified, SGBucket& b) { // generate output file name string base = b.gen_base_path(); string path = root_dir + "/" + base; @@ -282,7 +283,7 @@ void TGArray::write_bin(const string root_dir, bool rectified, SGBucket& b) { } // write an Array file -bool TGArray::write( const string root_dir, SGBucket& b ) { +bool TGArray::write( const string& root_dir, SGBucket& b ) { // generate output file name string base = b.gen_base_path(); string path = root_dir + "/" + base; @@ -444,7 +445,7 @@ std::vector TGArray::collect_bad_points(const double bad_zone) { } // Check to see if the specified grid point is bad -bool TGArray::is_bad_point(const int xgrid, const int ygrid, const std::vector bad_points) const { +bool TGArray::is_bad_point(const int xgrid, const int ygrid, const std::vector& bad_points) const { int grididx; grididx = xgrid+ygrid*cols; auto result = std::find( std::begin(bad_points),std::end(bad_points),grididx ); @@ -503,7 +504,7 @@ through the three known points. TODO: Handle points on the boundaries. */ -double TGArray::rectify_point(const int xgrid, const int ygrid, const std::vector bad_points) const { +double TGArray::rectify_point(const int xgrid, const int ygrid, const std::vector& bad_points) const { //xgrid: grid units horizontally //ygrid: grid units vertically //Loop over corner points, if no points available, give up diff --git a/src/Lib/Array/array.hxx b/src/Lib/Array/array.hxx index e1e1b7e4..c737b75a 100644 --- a/src/Lib/Array/array.hxx +++ b/src/Lib/Array/array.hxx @@ -67,15 +67,15 @@ private: // Routines for height rectification std::vector collect_bad_points(const double bad_zone); - bool is_bad_point(const int xgrid, const int ygrid, const std::vector bad_points) const; - double rectify_point(const int xgrid, const int ygrid, const std::vector bad_points) const; + bool is_bad_point(const int xgrid, const int ygrid, const std::vector& bad_points) const; + double rectify_point(const int xgrid, const int ygrid, const std::vector& bad_points) const; bool is_near_cliff(const double lon1,const double lon2, const double bad_zone) const; public: // Constructor TGArray( void ); - TGArray( const std::string& file ); + explicit TGArray( const std::string& file ); // Destructor ~TGArray( void ); @@ -96,11 +96,11 @@ public: bool parse( SGBucket& b ); // write an Array file - bool write( const std::string root_dir, SGBucket& b ); + bool write( const std::string& root_dir, SGBucket& b ); // write an Array file in binary format. If ht_rect is true, // the file will have extension 'arr.rectified.gz' - void write_bin(const std::string root_dir, bool ht_rect, SGBucket& b); + void write_bin(const std::string& root_dir, bool ht_rect, SGBucket& b); // do our best to remove voids by picking data from the nearest // neighbor. diff --git a/src/Lib/Array/rectify_height.cxx b/src/Lib/Array/rectify_height.cxx index b6bf7709..6c26220c 100644 --- a/src/Lib/Array/rectify_height.cxx +++ b/src/Lib/Array/rectify_height.cxx @@ -40,7 +40,7 @@ and if they have an associated cliff file, will adjust and then output the heights. */ // display usage and exit -static void usage( const std::string name ) { +static void usage( const std::string& name ) { SG_LOG(SG_GENERAL, SG_ALERT, "Usage: " << name); SG_LOG(SG_GENERAL, SG_ALERT, " --work-dir="); SG_LOG(SG_GENERAL, SG_ALERT, " --height-dir="); @@ -69,26 +69,26 @@ int main( int argc, char **argv) { // int arg_pos; for (arg_pos = 1; arg_pos < argc; arg_pos++) { - std::string arg = argv[arg_pos]; + std::string arg = argv[arg_pos]; - if (arg.find("--work-dir=") == 0) { + if (arg.compare(0, 11, "--work-dir=") == 0) { work_dir = arg.substr(11); - } else if (arg.find("--height-dir=") == 0) { - height_dir = arg.substr(13); - } else if (arg.find("--tile-id=") == 0) { + } else if (arg.compare(0, 13, "--height-dir=") == 0) { + height_dir = arg.substr(13); + } else if (arg.compare(0, 10, "--tile-id=") == 0) { tile_id = atol(arg.substr(10).c_str()); - } else if ( arg.find("--min-lon=") == 0 ) { + } else if ( arg.compare(0, 10, "--min-lon=") == 0 ) { min.setLongitudeDeg(atof( arg.substr(10).c_str() )); - } else if ( arg.find("--max-lon=") == 0 ) { + } else if ( arg.compare(0, 10, "--max-lon=") == 0 ) { max.setLongitudeDeg(atof( arg.substr(10).c_str() )); - } else if ( arg.find("--min-lat=") == 0 ) { + } else if ( arg.compare(0, 10, "--min-lat=") == 0 ) { min.setLatitudeDeg(atof( arg.substr(10).c_str() )); - } else if ( arg.find("--max-lat=") == 0 ) { + } else if ( arg.compare(0, 10, "--max-lat=") == 0 ) { max.setLatitudeDeg(atof( arg.substr(10).c_str() )); - } else if ( arg.find("--min-dist=") == 0) { - bad_zone = atof(arg.substr(11).c_str()); - } else if (arg.find("--") == 0) { - usage(argv[0]); + } else if ( arg.compare(0, 11, "--min-dist=") == 0) { + bad_zone = atof(arg.substr(11).c_str()); + } else if (arg.compare(0, 2, "--") == 0) { + usage(argv[0]); } else { break; } diff --git a/src/Prep/DemChop/srtmchop.cxx b/src/Prep/DemChop/srtmchop.cxx index 5866951a..7fe50dad 100644 --- a/src/Prep/DemChop/srtmchop.cxx +++ b/src/Prep/DemChop/srtmchop.cxx @@ -59,7 +59,7 @@ using std::ios; #define MAX_HGT_SIZE 6001 class TGSrtmTiff : public TGSrtmBase { public: - TGSrtmTiff( const SGPath &file ); + explicit TGSrtmTiff( const SGPath &file ); ~TGSrtmTiff(); bool open( const SGPath &f ); bool close(); @@ -181,8 +181,7 @@ bool TGSrtmTiff::open( const SGPath &f ) { } bool TGSrtmTiff::load() { - int size; - cols = rows = size = 6000; + cols = rows = 6000; col_step = row_step = 3; uint32 w, h, d; diff --git a/src/Prep/GDALChop/gdalchop.cxx b/src/Prep/GDALChop/gdalchop.cxx index 7bdc26ae..daffa97e 100644 --- a/src/Prep/GDALChop/gdalchop.cxx +++ b/src/Prep/GDALChop/gdalchop.cxx @@ -76,7 +76,7 @@ int SimpleRasterTransformer(void *pTransformerArg, int bDstToSrc, int nPointCount, double *x, double *y, double *z, int *panSuccess ) { - SimpleRasterTransformerInfo* info = (SimpleRasterTransformerInfo*)pTransformerArg; + SimpleRasterTransformerInfo* info = static_cast(pTransformerArg); int success; if (bDstToSrc) { @@ -105,7 +105,7 @@ int SimpleRasterTransformer(void *pTransformerArg, class ImageInfo { public: - ImageInfo(GDALDataset *dataset); + explicit ImageInfo(GDALDataset *dataset); void GetBounds(double &n, double &s, double &e, double &w) const { n = north; diff --git a/src/Prep/TerraFit/terrafit.cc b/src/Prep/TerraFit/terrafit.cc index 7704632c..59bf89bf 100644 --- a/src/Prep/TerraFit/terrafit.cc +++ b/src/Prep/TerraFit/terrafit.cc @@ -75,7 +75,7 @@ SGLockedQueue global_workQueue; */ class ArrayMap: public Terra::Map { public: - ArrayMap(TGArray& array): array(array) { + explicit ArrayMap(TGArray& array): array(array) { width=array.get_cols(); height=array.get_rows(); min=30000; diff --git a/src/Utils/poly2ogr/poly2ogr.cxx b/src/Utils/poly2ogr/poly2ogr.cxx index 00c834ef..33c7445f 100644 --- a/src/Utils/poly2ogr/poly2ogr.cxx +++ b/src/Utils/poly2ogr/poly2ogr.cxx @@ -147,10 +147,12 @@ OGRLayer* get_layer_for_material(const std::string& material) { OGRLinearRing* make_ring_from_fan(const int_list& fan, const std::vector& nodes) { OGRLinearRing* ring = new OGRLinearRing(); int_list::const_iterator vertex = fan.begin(); + if (fan[1]==fan[fan.size()-1]) { /* The fan is closed, so the first vertex is in the interior */ - vertex++; + ++vertex; } + for (;vertex!=fan.end();++vertex) { OGRPoint *point=new OGRPoint(); const SGGeod& node = nodes[*vertex]; @@ -347,12 +349,13 @@ void process_polygon_file(const std::string& path) { for (int pt=0;pt> x >> y; point->setX(x); point->setY(y); + if (poly3d) { + double z; in >> z; point->setZ(z); } else {