Fixed missing return causing crash in Release mode, changed debug
messages to use standard flightgear tools, improved comments.
This commit is contained in:
parent
3f9c296bf4
commit
3192c91da6
3 changed files with 31 additions and 9 deletions
|
@ -119,7 +119,7 @@ TGArray::close() {
|
||||||
//All polys in the bucket should be contours which we load
|
//All polys in the bucket should be contours which we load
|
||||||
//into our contour list.
|
//into our contour list.
|
||||||
|
|
||||||
bool TGArray::load_cliffs(const string & height_base)
|
void TGArray::load_cliffs(const string & height_base)
|
||||||
{
|
{
|
||||||
//Get the directory so we can list the children
|
//Get the directory so we can list the children
|
||||||
tgPolygon poly; //actually a contour but whatever...
|
tgPolygon poly; //actually a contour but whatever...
|
||||||
|
@ -467,7 +467,7 @@ void TGArray::rectify_heights(const double bad_zone) {
|
||||||
set_array_elev(xgrid,ygrid,(int) new_ht);
|
set_array_elev(xgrid,ygrid,(int) new_ht);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::cout << "Rectified " << rectified.size() << " points " << std::endl;
|
SG_LOG(SG_GENERAL, SG_DEBUG, "Rectified " << rectified.size() << " points ");
|
||||||
if(rectified.size()>0) {
|
if(rectified.size()>0) {
|
||||||
for(auto r : rectified) {
|
for(auto r : rectified) {
|
||||||
bad_points.erase(std::remove(std::begin(bad_points),std::end(bad_points),r));
|
bad_points.erase(std::remove(std::begin(bad_points),std::end(bad_points),r));
|
||||||
|
@ -475,7 +475,7 @@ void TGArray::rectify_heights(const double bad_zone) {
|
||||||
rectified.clear();
|
rectified.clear();
|
||||||
} else {
|
} else {
|
||||||
if(bad_points.size() > 0) {
|
if(bad_points.size() > 0) {
|
||||||
std::cout << "Failed to rectify " << bad_points.size() << " points" << std::endl;
|
SG_LOG(SG_GENERAL, SG_DEBUG, "Failed to rectify " << bad_points.size() << " points");
|
||||||
}
|
}
|
||||||
break; // Cant do any more
|
break; // Cant do any more
|
||||||
}
|
}
|
||||||
|
@ -536,7 +536,7 @@ double TGArray::rectify_point(const int xgrid, const int ygrid, const std::vecto
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pt == pt_cnt) { // perhaps we are in a bay, just take the
|
if (pt == pt_cnt) { // perhaps we have a concave cliff, just take the
|
||||||
// average of the known points
|
// average of the known points
|
||||||
double totht = 0;
|
double totht = 0;
|
||||||
for(int pti = 0; pti <pt_cnt; pti++) {
|
for(int pti = 0; pti <pt_cnt; pti++) {
|
||||||
|
@ -555,7 +555,7 @@ double TGArray::rectify_point(const int xgrid, const int ygrid, const std::vecto
|
||||||
if (vert < -9000) vert = 0;
|
if (vert < -9000) vert = 0;
|
||||||
height = horiz + (vert - corner);
|
height = horiz + (vert - corner);
|
||||||
}
|
}
|
||||||
std::cout << xgrid << "," << ygrid << ": was " << original_height << " , now " << height << std::endl;
|
SG_LOG(SG_GENERAL, SG_DEBUG, xgrid << "," << ygrid << ": was " << original_height << " , now " << height);
|
||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ public:
|
||||||
bool open ( const std::string& file_base );
|
bool open ( const std::string& file_base );
|
||||||
|
|
||||||
// Load contours from polygon files delineating height discontinuities
|
// Load contours from polygon files delineating height discontinuities
|
||||||
bool load_cliffs(const std::string & height_base);
|
void load_cliffs(const std::string & height_base);
|
||||||
|
|
||||||
// return if array was successfully opened or not
|
// return if array was successfully opened or not
|
||||||
bool is_open() const;
|
bool is_open() const;
|
||||||
|
|
|
@ -1,4 +1,25 @@
|
||||||
//rectify_height.cxx
|
// rectify_height.cxx -- Correct height grid for incorrect heights near
|
||||||
|
// discontinuities included in cliff files
|
||||||
|
//
|
||||||
|
// Written by James Hester 2018
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018 James Hester
|
||||||
|
//
|
||||||
|
// This program is free software; you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation; either version 2 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
//
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
# include <config.h>
|
# include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -16,7 +37,7 @@
|
||||||
|
|
||||||
/* This program will find all height files in the directory provided,
|
/* This program will find all height files in the directory provided,
|
||||||
and if they have an associated cliff file, will adjust and then output
|
and if they have an associated cliff file, will adjust and then output
|
||||||
the heights. Single threaded to avoid reading/writing the same file. */
|
the heights. */
|
||||||
|
|
||||||
// display usage and exit
|
// display usage and exit
|
||||||
static void usage( const std::string name ) {
|
static void usage( const std::string name ) {
|
||||||
|
@ -38,7 +59,7 @@ int main( int argc, char **argv) {
|
||||||
std::string height_dir = "";
|
std::string height_dir = "";
|
||||||
SGGeod min,max;
|
SGGeod min,max;
|
||||||
long tile_id = -1;
|
long tile_id = -1;
|
||||||
double bad_zone = 30; //distance in m from cliff to rectify
|
double bad_zone = 100; //distance in m from cliff to rectify
|
||||||
|
|
||||||
sglog().setLogLevels(SG_ALL,SG_INFO);
|
sglog().setLogLevels(SG_ALL,SG_INFO);
|
||||||
sglog().set_log_priority(SG_DEBUG);
|
sglog().set_log_priority(SG_DEBUG);
|
||||||
|
@ -122,6 +143,7 @@ int main( int argc, char **argv) {
|
||||||
SG_LOG(SG_GENERAL,SG_DEBUG, "Failed to open array file " << array_path);
|
SG_LOG(SG_GENERAL,SG_DEBUG, "Failed to open array file " << array_path);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
SG_LOG(SG_GENERAL,SG_DEBUG, "Successfully opened array file");
|
||||||
array.parse(bucket);
|
array.parse(bucket);
|
||||||
array.close();
|
array.close();
|
||||||
array.remove_voids();
|
array.remove_voids();
|
||||||
|
|
Loading…
Add table
Reference in a new issue