1
0
Fork 0

Last set of technical debt items

This commit is contained in:
Scott Giese 2019-01-31 17:49:43 -06:00
parent 640c91b369
commit 791314a909
20 changed files with 136 additions and 134 deletions

View file

@ -60,13 +60,13 @@ public:
@param A rectangular (m>=n) matrix.
*/
QR(const TNT::Array2D<Real> &A) /* constructor */
explicit QR(const TNT::Array2D<Real> &A) : /* constructor */
QR_(A.copy())
{
QR_ = A.copy();
m = A.dim1();
n = A.dim2();
Rdiag = TNT::Array1D<Real>(n);
int i=0, j=0, k=0;
int i, j, k;
// Main loop.
for (k = 0; k < n; k++) {
@ -182,7 +182,7 @@ public:
TNT::Array2D<Real> getQ() const
{
int i=0, j=0, k=0;
int i, j, k;
TNT::Array2D<Real> Q(m,n);
for (k = n-1; k >= 0; k--) {
@ -277,7 +277,7 @@ public:
int nx = B.dim2();
TNT::Array2D<Real> X = B.copy();
int i=0, j=0, k=0;
int i, j, k;
// Compute Y = transpose(Q)*B
for (k = 0; k < n; k++) {

View file

@ -553,8 +553,8 @@ bool SlopesEqual(const TEdge &e1, const TEdge &e2, bool UseFullInt64Range)
}
//------------------------------------------------------------------------------
bool SlopesEqual(const IntPoint pt1, const IntPoint pt2,
const IntPoint pt3, bool UseFullInt64Range)
bool SlopesEqual(const IntPoint& pt1, const IntPoint& pt2,
const IntPoint& pt3, bool UseFullInt64Range)
{
#ifndef use_int32
if (UseFullInt64Range)
@ -565,8 +565,8 @@ bool SlopesEqual(const IntPoint pt1, const IntPoint pt2,
}
//------------------------------------------------------------------------------
bool SlopesEqual(const IntPoint pt1, const IntPoint pt2,
const IntPoint pt3, const IntPoint pt4, bool UseFullInt64Range)
bool SlopesEqual(const IntPoint& pt1, const IntPoint& pt2,
const IntPoint& pt3, const IntPoint& pt4, bool UseFullInt64Range)
{
#ifndef use_int32
if (UseFullInt64Range)
@ -583,7 +583,7 @@ inline bool IsHorizontal(TEdge &e)
}
//------------------------------------------------------------------------------
inline double GetDx(const IntPoint pt1, const IntPoint pt2)
inline double GetDx(const IntPoint& pt1, const IntPoint& pt2)
{
return (pt1.Y == pt2.Y) ?
HORIZONTAL : (double)(pt2.X - pt1.X) / (pt2.Y - pt1.Y);
@ -862,8 +862,8 @@ OutPt* GetBottomPt(OutPt *pp)
}
//------------------------------------------------------------------------------
bool Pt2IsBetweenPt1AndPt3(const IntPoint pt1,
const IntPoint pt2, const IntPoint pt3)
bool Pt2IsBetweenPt1AndPt3(const IntPoint& pt1,
const IntPoint& pt2, const IntPoint& pt3)
{
if ((pt1 == pt3) || (pt1 == pt2) || (pt3 == pt2))
return false;
@ -1480,6 +1480,11 @@ bool ClipperBase::LocalMinimaPending()
Clipper::Clipper(int initOptions) : ClipperBase() //constructor
{
m_ClipType = ClipType::Intersection;
m_SortedEdges = 0;
m_ClipFillType = PolyFillType::EvenOdd;
m_SubjFillType = PolyFillType::EvenOdd;
m_UsingPolyTree = false;
m_ExecuteLocked = false;
m_UseFullRange = false;
m_ReverseOutput = ((initOptions & static_cast<int>(InitOptions::ReverseSolution)) != 0);
@ -1946,7 +1951,7 @@ void Clipper::CopyAELToSEL()
}
//------------------------------------------------------------------------------
void Clipper::AddJoin(OutPt *op1, OutPt *op2, const IntPoint OffPt)
void Clipper::AddJoin(OutPt *op1, OutPt *op2, const IntPoint& OffPt)
{
Join* j = new Join;
j->OutPt1 = op1;
@ -1972,7 +1977,7 @@ void Clipper::ClearGhostJoins()
}
//------------------------------------------------------------------------------
void Clipper::AddGhostJoin(OutPt *op, const IntPoint OffPt)
void Clipper::AddGhostJoin(OutPt *op, const IntPoint& OffPt)
{
Join* j = new Join;
j->OutPt1 = op;
@ -3383,7 +3388,7 @@ OutPt* DupOutPt(OutPt* outPt, bool InsertAfter)
//------------------------------------------------------------------------------
bool JoinHorz(OutPt* op1, OutPt* op1b, OutPt* op2, OutPt* op2b,
const IntPoint Pt, bool DiscardLeft)
const IntPoint& Pt, bool DiscardLeft)
{
Direction Dir1 = (op1->Pt.X > op1b->Pt.X ? Direction::RightToLeft : Direction::LeftToRight);
Direction Dir2 = (op2->Pt.X > op2b->Pt.X ? Direction::RightToLeft : Direction::LeftToRight);
@ -3802,6 +3807,8 @@ ClipperOffset::ClipperOffset(double miterLimit, double arcTolerance)
this->MiterLimit = miterLimit;
this->ArcTolerance = arcTolerance;
m_lowest.X = -1;
m_delta = m_sinA = m_sin = m_cos = 0.0;
m_miterLim = m_StepsPerRad = 0.0;
}
//------------------------------------------------------------------------------
@ -4534,7 +4541,7 @@ void MinkowskiSum(const Path& pattern, const Path& path, Paths& solution, bool p
}
//------------------------------------------------------------------------------
void TranslatePath(const Path& input, Path& output, const IntPoint delta)
void TranslatePath(const Path& input, Path& output, const IntPoint& delta)
{
//precondition: input != output
output.resize(input.size());

View file

@ -341,10 +341,10 @@ private:
bool IsHole(TEdge *e);
bool FindOwnerFromSplitRecs(OutRec &outRec, OutRec *&currOrfl);
void FixHoleLinkage(OutRec &outrec);
void AddJoin(OutPt *op1, OutPt *op2, const IntPoint offPt);
void AddJoin(OutPt *op1, OutPt *op2, const IntPoint& offPt);
void ClearJoins();
void ClearGhostJoins();
void AddGhostJoin(OutPt *op, const IntPoint offPt);
void AddGhostJoin(OutPt *op, const IntPoint& offPt);
bool JoinPoints(Join *j, OutRec* outRec1, OutRec* outRec2);
void JoinCommonEdges();
void DoSimplePolygons();

View file

@ -56,7 +56,7 @@ tgPolygon tgAccumulator::Diff( const tgContour& subject )
max_hits = num_hits-1;
FILE* fp = fopen( "./accumulator_fail.log", "a" );
fprintf( fp, "%s : reduce from %d to %d\n", debugstr.c_str(), num_hits, max_hits );
fprintf( fp, "%s : reduce from %u to %u\n", debugstr.c_str(), num_hits, max_hits );
fclose(fp);
} else {
result = tgPolygon::FromClipper( clipper_result );
@ -119,7 +119,7 @@ tgPolygon tgAccumulator::Diff( const tgPolygon& subject )
max_hits = num_hits-1;
FILE* fp = fopen( "./accumulator_fail.log", "a" );
fprintf( fp, "%s : reduce from %d to %d\n", debugstr.c_str(), num_hits, max_hits );
fprintf( fp, "%s : reduce from %u to %u\n", debugstr.c_str(), num_hits, max_hits );
fclose(fp);
} else {
result = tgPolygon::FromClipper( clipper_result );
@ -173,14 +173,14 @@ void tgAccumulator::Add( const tgPolygon& subject )
void tgAccumulator::ToShapefiles( const std::string& path, const std::string& layer_prefix, bool individual )
{
char shapefile[32];
char layer[32];
if ( accum.size() ) {
if ( individual ) {
for (unsigned int i=0; i < accum.size(); i++) {
sprintf( layer, "%s_%d", layer_prefix.c_str(), i );
sprintf( shapefile, "accum_%d", i );
char layer[32];
sprintf( layer, "%s_%u", layer_prefix.c_str(), i );
char shapefile[32];
sprintf( shapefile, "accum_%u", i );
tgShapefile::FromClipper( accum[i], path, layer, std::string(shapefile) );
}
} else {
@ -204,12 +204,12 @@ void tgAccumulator::ToShapefiles( const std::string& path, const std::string& la
void tgAccumulator::ToClipperfiles( const std::string& path, const std::string& layer_prefix, bool individual )
{
std::ofstream file;
char filename[256];
if ( accum.size() ) {
if ( individual ) {
char filename[256];
for (unsigned int i=0; i < accum.size(); i++) {
sprintf( filename, "%s/%s_%d", path.c_str(), layer_prefix.c_str(), i );
sprintf( filename, "%s/%s_%u", path.c_str(), layer_prefix.c_str(), i );
file.open (filename);
file << accum[i];
@ -225,6 +225,7 @@ void tgAccumulator::ToClipperfiles( const std::string& path, const std::string&
}
if ( c.Execute( ClipperLib::ClipType::Union, clipper_result, ClipperLib::PolyFillType::NonZero, ClipperLib::PolyFillType::NonZero) ) {
char filename[256];
sprintf( filename, "%s/%s", path.c_str(), layer_prefix.c_str() );
file.open (filename);

View file

@ -8,7 +8,7 @@
class tgAccumulator
{
public:
tgAccumulator( const std::string& d ) : debugstr(d) {}
explicit tgAccumulator( const std::string& d ) : debugstr(d) {}
tgPolygon Diff( const tgContour& subject );
tgPolygon Diff( const tgPolygon& subject );

View file

@ -141,7 +141,7 @@ void tgChopper::Add( const tgPolygon& subject, const std::string& type )
}
}
long int tgChopper::GenerateIndex( std::string path )
long int tgChopper::GenerateIndex( const std::string& path )
{
std::string index_file = path + "/chop.idx";
long int index = 0;
@ -194,7 +194,7 @@ void tgChopper::Save( bool DebugShapefiles )
char layer[32];
char ds_name[64];
for (it=bp_map.begin(); it != bp_map.end(); it++) {
for (it=bp_map.begin(); it != bp_map.end(); ++it) {
SGBucket b( (*it).first );
tgpolygon_list const& polys = (*it).second;
@ -226,7 +226,7 @@ void tgChopper::Save( bool DebugShapefiles )
if ( DebugShapefiles )
{
sprintf(layer, "poly_%s-%d", b.gen_index_str().c_str(), i );
sprintf(layer, "poly_%s-%u", b.gen_index_str().c_str(), i );
tgShapefile::FromPolygon( polys[i], ds_name, layer, "poly" );
}
}

View file

@ -9,9 +9,10 @@ typedef bucket_polys_map::iterator bucket_polys_map_interator;
class tgChopper
{
public:
tgChopper( const std::string& path ) {
root_path = path;
extra_extension = "";
explicit tgChopper( const std::string& path ) :
root_path(path),
extra_extension("")
{
}
void Add( const tgPolygon& poly, const std::string& type );
@ -21,7 +22,7 @@ public:
}
private:
long int GenerateIndex( std::string path );
long int GenerateIndex( const std::string& path );
void ClipRow( const tgPolygon& subject, const double& center_lat, const std::string& type );
tgPolygon Clip( const tgPolygon& subject, const std::string& type, SGBucket& b );
void Chop( const tgPolygon& subject, const std::string& type );

View file

@ -25,8 +25,8 @@ tgContour tgContour::Snap( const tgContour& subject, double snap )
double tgContour::GetMinimumAngle( void ) const
{
unsigned int p1_index, p2_index, p3_index;
double angle, min_angle = 2.0 * SGD_PI;
unsigned int p1_index, p3_index;
double min_angle = 2.0 * SGD_PI;
unsigned int size = node_list.size();
SG_LOG(SG_GENERAL, SG_DEBUG, " tgContour::GetMinimumAngle() : contour size is " << size );
@ -38,7 +38,7 @@ double tgContour::GetMinimumAngle( void ) const
p1_index = i - 1;
}
p2_index = i;
unsigned p2_index = i;
if ( i == size - 1 ) {
p3_index = 0;
@ -46,7 +46,7 @@ double tgContour::GetMinimumAngle( void ) const
p3_index = i + 1;
}
angle = SGGeod_CalculateTheta( node_list[p1_index], node_list[p2_index], node_list[p3_index] );
double angle = SGGeod_CalculateTheta( node_list[p1_index], node_list[p2_index], node_list[p3_index] );
if ( angle < min_angle ) {
min_angle = angle;
}
@ -58,16 +58,14 @@ double tgContour::GetMinimumAngle( void ) const
double tgContour::GetArea( void ) const
{
double area = 0.0;
SGVec2d a, b;
unsigned int i, j;
if ( node_list.size() ) {
j = node_list.size() - 1;
for (i=0; i<node_list.size(); i++) {
a = SGGeod_ToSGVec2d( node_list[i] );
b = SGGeod_ToSGVec2d( node_list[j] );
unsigned j = node_list.size() - 1;
for (unsigned i = 0; i < node_list.size(); ++i) {
SGVec2d a = SGGeod_ToSGVec2d( node_list[i] );
SGVec2d b = SGGeod_ToSGVec2d( node_list[j] );
area += (b.x() + a.x()) * (b.y() - a.y());
j=i;
j = i;
}
}
@ -139,20 +137,18 @@ bool tgContour::AreSameSide( const SGGeod& firstpt, const SGGeod& secondpt) cons
double tgContour::MinDist(const SGGeod& probe) const {
SGVec3d probexyz;
SGGeodesy::SGGeodToCart( probe,probexyz );
SGGeodesy::SGGeodToCart( probe, probexyz );
double mindist = 100000.0;
double dist;
if ( node_list.size() ) {
int j = node_list.size() - 1;
for (int i=0;i<j;i++) {
for (int i = 0; i < j; ++i) {
SGVec3d start,end;
SGGeodesy::SGGeodToCart( node_list[i],start );
SGGeodesy::SGGeodToCart( node_list[i+1],end );
SGLineSegment<double> piece = SGLineSegment<double>(start,end);
dist = distSqr( piece,probexyz );
double dist = distSqr( piece,probexyz );
if (dist < mindist) mindist = dist;
}
}
@ -633,7 +629,6 @@ static bool FindIntermediateNode( const SGGeod& start, const SGGeod& end,
double bbEpsilon, double errEpsilon )
{
bool found_node = false;
double m, m1, b, b1, y_err, x_err, y_err_min, x_err_min;
SGGeod p0 = start;
SGGeod p1 = end;
@ -641,8 +636,8 @@ static bool FindIntermediateNode( const SGGeod& start, const SGGeod& end,
double xdist = fabs(p0.getLongitudeDeg() - p1.getLongitudeDeg());
double ydist = fabs(p0.getLatitudeDeg() - p1.getLatitudeDeg());
x_err_min = xdist + 1.0;
y_err_min = ydist + 1.0;
double x_err_min = xdist + 1.0;
double y_err_min = ydist + 1.0;
if ( xdist > ydist ) {
// sort these in a sensible order
@ -655,15 +650,15 @@ static bool FindIntermediateNode( const SGGeod& start, const SGGeod& end,
p_max = p0;
}
m = (p_min.getLatitudeDeg() - p_max.getLatitudeDeg()) / (p_min.getLongitudeDeg() - p_max.getLongitudeDeg());
b = p_max.getLatitudeDeg() - m * p_max.getLongitudeDeg();
double m = (p_min.getLatitudeDeg() - p_max.getLatitudeDeg()) / (p_min.getLongitudeDeg() - p_max.getLongitudeDeg());
double b = p_max.getLatitudeDeg() - m * p_max.getLongitudeDeg();
for ( int i = 0; i < (int)nodes.size(); ++i ) {
// cout << i << endl;
SGGeod current = nodes[i];
if ( (current.getLongitudeDeg() > (p_min.getLongitudeDeg() + (bbEpsilon))) && (current.getLongitudeDeg() < (p_max.getLongitudeDeg() - (bbEpsilon))) ) {
y_err = fabs(current.getLatitudeDeg() - (m * current.getLongitudeDeg() + b));
double y_err = fabs(current.getLatitudeDeg() - (m * current.getLongitudeDeg() + b));
if ( y_err < errEpsilon ) {
found_node = true;
@ -685,15 +680,15 @@ static bool FindIntermediateNode( const SGGeod& start, const SGGeod& end,
p_max = p0;
}
m1 = (p_min.getLongitudeDeg() - p_max.getLongitudeDeg()) / (p_min.getLatitudeDeg() - p_max.getLatitudeDeg());
b1 = p_max.getLongitudeDeg() - m1 * p_max.getLatitudeDeg();
double m1 = (p_min.getLongitudeDeg() - p_max.getLongitudeDeg()) / (p_min.getLatitudeDeg() - p_max.getLatitudeDeg());
double b1 = p_max.getLongitudeDeg() - m1 * p_max.getLatitudeDeg();
for ( int i = 0; i < (int)nodes.size(); ++i ) {
SGGeod current = nodes[i];
if ( (current.getLatitudeDeg() > (p_min.getLatitudeDeg() + (bbEpsilon))) && (current.getLatitudeDeg() < (p_max.getLatitudeDeg() - (bbEpsilon))) ) {
x_err = fabs(current.getLongitudeDeg() - (m1 * current.getLatitudeDeg() + b1));
double x_err = fabs(current.getLongitudeDeg() - (m1 * current.getLatitudeDeg() + b1));
if ( x_err < errEpsilon ) {
found_node = true;
@ -714,7 +709,6 @@ static bool FindIntermediateNode( const SGGeod& start, const SGGeod& end,
double bbEpsilon, double errEpsilon )
{
bool found_node = false;
double m, m1, b, b1, y_err, x_err, y_err_min, x_err_min;
SGGeod p0 = start;
SGGeod p1 = end;
@ -722,8 +716,8 @@ static bool FindIntermediateNode( const SGGeod& start, const SGGeod& end,
double xdist = fabs(p0.getLongitudeDeg() - p1.getLongitudeDeg());
double ydist = fabs(p0.getLatitudeDeg() - p1.getLatitudeDeg());
x_err_min = xdist + 1.0;
y_err_min = ydist + 1.0;
double x_err_min = xdist + 1.0;
double y_err_min = ydist + 1.0;
if ( xdist > ydist ) {
// sort these in a sensible order
@ -736,15 +730,15 @@ static bool FindIntermediateNode( const SGGeod& start, const SGGeod& end,
p_max = p0;
}
m = (p_min.getLatitudeDeg() - p_max.getLatitudeDeg()) / (p_min.getLongitudeDeg() - p_max.getLongitudeDeg());
b = p_max.getLatitudeDeg() - m * p_max.getLongitudeDeg();
double m = (p_min.getLatitudeDeg() - p_max.getLatitudeDeg()) / (p_min.getLongitudeDeg() - p_max.getLongitudeDeg());
double b = p_max.getLatitudeDeg() - m * p_max.getLongitudeDeg();
for ( int i = 0; i < (int)nodes.size(); ++i ) {
// cout << i << endl;
SGGeod current = nodes[i]->GetPosition();
if ( (current.getLongitudeDeg() > (p_min.getLongitudeDeg() + (bbEpsilon))) && (current.getLongitudeDeg() < (p_max.getLongitudeDeg() - (bbEpsilon))) ) {
y_err = fabs(current.getLatitudeDeg() - (m * current.getLongitudeDeg() + b));
double y_err = fabs(current.getLatitudeDeg() - (m * current.getLongitudeDeg() + b));
if ( y_err < errEpsilon ) {
found_node = true;
@ -766,15 +760,15 @@ static bool FindIntermediateNode( const SGGeod& start, const SGGeod& end,
p_max = p0;
}
m1 = (p_min.getLongitudeDeg() - p_max.getLongitudeDeg()) / (p_min.getLatitudeDeg() - p_max.getLatitudeDeg());
b1 = p_max.getLongitudeDeg() - m1 * p_max.getLatitudeDeg();
double m1 = (p_min.getLongitudeDeg() - p_max.getLongitudeDeg()) / (p_min.getLatitudeDeg() - p_max.getLatitudeDeg());
double b1 = p_max.getLongitudeDeg() - m1 * p_max.getLatitudeDeg();
for ( int i = 0; i < (int)nodes.size(); ++i ) {
SGGeod current = nodes[i]->GetPosition();
if ( (current.getLatitudeDeg() > (p_min.getLatitudeDeg() + (bbEpsilon))) && (current.getLatitudeDeg() < (p_max.getLatitudeDeg() - (bbEpsilon))) ) {
x_err = fabs(current.getLongitudeDeg() - (m1 * current.getLatitudeDeg() + b1));
double x_err = fabs(current.getLongitudeDeg() - (m1 * current.getLatitudeDeg() + b1));
if ( x_err < errEpsilon ) {
found_node = true;
@ -1002,8 +996,6 @@ tgContour tgContour::Expand( const tgContour& subject, double offset )
tgpolygon_list tgContour::ExpandToPolygons( const tgContour& subject, double width )
{
int turn_dir;
SGGeod cur_inner;
SGGeod cur_outer;
SGGeod prev_inner;
@ -1011,8 +1003,6 @@ tgpolygon_list tgContour::ExpandToPolygons( const tgContour& subject, double wid
SGGeod calc_inner;
SGGeod calc_outer;
double last_end_v = 0.0f;
tgContour expanded;
tgPolygon segment;
tgAccumulator accum("ExpandToPolygons");
@ -1021,8 +1011,7 @@ tgpolygon_list tgContour::ExpandToPolygons( const tgContour& subject, double wid
// generate poly and texparam lists for each line segment
for (unsigned int i = 0; i < subject.GetSize(); i++)
{
last_end_v = 0.0f;
turn_dir = 0;
int turn_dir = 0;
sglog().setLogLevels( SG_ALL, SG_INFO );
@ -1033,8 +1022,8 @@ tgpolygon_list tgContour::ExpandToPolygons( const tgContour& subject, double wid
if (i == 0)
{
// first point on the list - offset heading is 90deg
cur_outer = OffsetPointFirst( subject.GetNode(i), subject.GetNode(i+1), -width/2.0f );
cur_inner = OffsetPointFirst( subject.GetNode(i), subject.GetNode(i+1), width/2.0f );
cur_outer = OffsetPointFirst( subject.GetNode(i), subject.GetNode(1), -width/2.0f );
cur_inner = OffsetPointFirst( subject.GetNode(i), subject.GetNode(1), width/2.0f );
}
else if (i == subject.GetSize()-1)
{
@ -1098,6 +1087,8 @@ tgpolygon_list tgContour::ExpandToPolygons( const tgContour& subject, double wid
}
}
double last_end_v = 0.0;
expanded.SetHole(false);
segment.AddContour(expanded);
segment.SetTexParams( prev_inner, width, 20.0f, heading );
@ -1105,6 +1096,7 @@ tgpolygon_list tgContour::ExpandToPolygons( const tgContour& subject, double wid
segment.SetTexMethod( TG_TEX_BY_TPS_CLIPU, -1.0, 0.0, 1.0, 0.0 );
result.push_back( segment );
// BUG??: value will never be utilized
last_end_v = 1.0f - (fmod( (double)(dist - last_end_v), (double)1.0f ));
}

View file

@ -148,7 +148,7 @@ bool TGNodes::get_geod_inside( const SGGeod& min, const SGGeod& max, std::vector
tg_kd_tree.search(std::back_inserter( result ), exact_bb);
// and convert the tuples back into SGGeod
for ( it = result.begin(); it != result.end(); it++ ) {
for ( it = result.begin(); it != result.end(); ++it ) {
points.push_back( SGGeod::fromDegM( boost::get<0>(*it).x(), boost::get<0>(*it).y(), boost::get<1>(*it) ) );
}
@ -178,7 +178,7 @@ bool TGNodes::get_nodes_inside( const SGGeod& min, const SGGeod& max, std::vecto
tg_kd_tree.search(std::back_inserter( result ), exact_bb);
// and convert the tuples back into SGGeod
for ( it = result.begin(); it != result.end(); it++ ) {
for ( it = result.begin(); it != result.end(); ++it ) {
points.push_back( boost::get<2>(*it) );
}
@ -217,7 +217,7 @@ bool TGNodes::get_geod_edge( const SGBucket& b, std::vector<SGGeod>& north, std:
exact_bb = Fuzzy_bb(ll, ur);
result.clear();
tg_kd_tree.search(std::back_inserter( result ), exact_bb);
for ( it = result.begin(); it != result.end(); it++ ) {
for ( it = result.begin(); it != result.end(); ++it ) {
north.push_back( SGGeod::fromDegM( boost::get<0>(*it).x(), boost::get<0>(*it).y(), boost::get<1>(*it) ) );
}
@ -228,7 +228,7 @@ bool TGNodes::get_geod_edge( const SGBucket& b, std::vector<SGGeod>& north, std:
result.clear();
tg_kd_tree.search(std::back_inserter( result ), exact_bb);
for ( it = result.begin(); it != result.end(); it++ ) {
for ( it = result.begin(); it != result.end(); ++it ) {
south.push_back( SGGeod::fromDegM( boost::get<0>(*it).x(), boost::get<0>(*it).y(), boost::get<1>(*it) ) );
}
@ -239,7 +239,7 @@ bool TGNodes::get_geod_edge( const SGBucket& b, std::vector<SGGeod>& north, std:
result.clear();
tg_kd_tree.search(std::back_inserter( result ), exact_bb);
for ( it = result.begin(); it != result.end(); it++ ) {
for ( it = result.begin(); it != result.end(); ++it ) {
east.push_back( SGGeod::fromDegM( boost::get<0>(*it).x(), boost::get<0>(*it).y(), boost::get<1>(*it) ) );
}
@ -250,7 +250,7 @@ bool TGNodes::get_geod_edge( const SGBucket& b, std::vector<SGGeod>& north, std:
result.clear();
tg_kd_tree.search(std::back_inserter( result ), exact_bb);
for ( it = result.begin(); it != result.end(); it++ ) {
for ( it = result.begin(); it != result.end(); ++it ) {
west.push_back( SGGeod::fromDegM( boost::get<0>(*it).x(), boost::get<0>(*it).y(), boost::get<1>(*it) ) );
}

View file

@ -211,8 +211,6 @@ void tgPolygon::Texture( void )
{
SGGeod p;
SGVec2f t;
double x, y;
float tx, ty;
SG_LOG(SG_GENERAL, SG_DEBUG, "Texture Poly with material " << material << " method " << tp.method << " tpref " << tp.ref << " heading " << tp.heading );
@ -272,8 +270,8 @@ void tgPolygon::Texture( void )
// 3. Convert from polar to cartesian coordinates
//
x = sin( course * SGD_DEGREES_TO_RADIANS ) * dist;
y = cos( course * SGD_DEGREES_TO_RADIANS ) * dist;
double x = sin( course * SGD_DEGREES_TO_RADIANS ) * dist;
double y = cos( course * SGD_DEGREES_TO_RADIANS ) * dist;
SG_LOG(SG_GENERAL, SG_DEBUG, " x = " << x << " y = " << y);
//
@ -282,7 +280,7 @@ void tgPolygon::Texture( void )
float tmp;
tmp = (float)x / (float)tp.width;
tx = tmp * (float)(tp.maxu - tp.minu) + (float)tp.minu;
float tx = tmp * (float)(tp.maxu - tp.minu) + (float)tp.minu;
SG_LOG(SG_GENERAL, SG_DEBUG, " (" << tx << ")");
// clip u?
@ -292,7 +290,7 @@ void tgPolygon::Texture( void )
}
tmp = (float)y / (float)tp.length;
ty = tmp * (float)(tp.maxv - tp.minv) + (float)tp.minv;
float ty = tmp * (float)(tp.maxv - tp.minv) + (float)tp.minv;
SG_LOG(SG_GENERAL, SG_DEBUG, " (" << ty << ")");
// clip v?

View file

@ -244,7 +244,9 @@ public:
tgPolygon() {
preserve3d = false;
closed = true;
id = 0;
}
~tgPolygon() {
contours.clear();
triangles.clear();

View file

@ -213,8 +213,6 @@ void tgPolygon::RemoveSlivers( tgPolygon& subject, tgcontour_list& slivers )
double angle_cutoff = 10.0 * SGD_DEGREES_TO_RADIANS;
double area_cutoff = 0.000000001;
double min_angle;
double area;
// process contours in reverse order so deleting a contour doesn't
// foul up our sequence
@ -224,10 +222,10 @@ void tgPolygon::RemoveSlivers( tgPolygon& subject, tgcontour_list& slivers )
contour = subject.GetContour(i);
SG_LOG(SG_GENERAL, SG_DEBUG, " calc min angle for contour " << i);
min_angle = contour.GetMinimumAngle();
double min_angle = contour.GetMinimumAngle();
SG_LOG(SG_GENERAL, SG_DEBUG, " min_angle (rad) = " << min_angle );
area = contour.GetArea();
double area = contour.GetArea();
SG_LOG(SG_GENERAL, SG_DEBUG, " area = " << area );
if ( ((min_angle < angle_cutoff) && (area < area_cutoff)) ||
@ -262,7 +260,6 @@ tgcontour_list tgPolygon::MergeSlivers( tgpolygon_list& polys, tgcontour_list& s
tgContour contour;
tgcontour_list unmerged;
unsigned int original_contours, result_contours;
bool done;
for ( unsigned int i = 0; i < sliver_list.size(); i++ ) {
sliver = sliver_list[i];
@ -270,7 +267,7 @@ tgcontour_list tgPolygon::MergeSlivers( tgpolygon_list& polys, tgcontour_list& s
sliver.SetHole( false );
done = false;
bool done = false;
// try to merge the slivers with the list of clipped polys
for ( unsigned int j = 0; j < polys.size() && !done; j++ ) {

View file

@ -13,14 +13,17 @@
#include "tg_polygon.hxx"
#include "tg_misc.hxx"
/* determining if a face is within the reulting poly */
/* determining if a face is within the resulting poly */
struct FaceInfo2
{
FaceInfo2() {}
FaceInfo2() {
nesting_level = 0;
}
int nesting_level;
bool in_domain(){
return nesting_level%2 == 1;
bool in_domain() {
return nesting_level % 2 == 1;
}
};

View file

@ -116,7 +116,7 @@ void tgShapefile::FromClipper( const ClipperLib::Paths& subject, const std::stri
OGRPolygon* polygon = new OGRPolygon();
SG_LOG(SG_GENERAL, SG_DEBUG, "subject has " << subject.size() << " contours ");
for ( unsigned int i = 0; i < subject.size(); i++ ) {
for ( unsigned int i = 0; i < subject.size(); ++i ) {
ClipperLib::Path const& contour = subject[i];
if (contour.size() < 3) {
@ -146,7 +146,8 @@ void tgShapefile::FromClipper( const ClipperLib::Paths& subject, const std::stri
feature->SetField("ID", description.c_str());
feature->SetGeometry(polygon);
if( l_id->CreateFeature( feature ) != OGRERR_NONE )
if ( l_id->CreateFeature( feature ) != OGRERR_NONE )
{
SG_LOG(SG_GENERAL, SG_ALERT, "Failed to create feature in shapefile");
}
@ -155,9 +156,7 @@ void tgShapefile::FromClipper( const ClipperLib::Paths& subject, const std::stri
}
// close after each write
if ( ds_id >= 0 ) {
ds_id = tgShapefile::CloseDatasource( ds_id );
}
tgShapefile::CloseDatasource( ds_id );
}
void tgShapefile::FromContour( const tgContour& subject, const std::string& datasource, const std::string& layer, const std::string& description )
@ -201,7 +200,7 @@ void tgShapefile::FromContour( const tgContour& subject, const std::string& data
}
// close after each write
ds_id = tgShapefile::CloseDatasource( ds_id );
tgShapefile::CloseDatasource( ds_id );
}
void tgShapefile::FromTriangles( const tgPolygon& subject, const std::string& datasource, const std::string& layer, const std::string& description )
@ -241,7 +240,7 @@ void tgShapefile::FromTriangles( const tgPolygon& subject, const std::string& da
}
// close after each write
ds_id = tgShapefile::CloseDatasource( ds_id );
tgShapefile::CloseDatasource( ds_id );
}
void tgShapefile::FromPolygon( const tgPolygon& subject, const std::string& datasource, const std::string& layer, const std::string& description )
@ -295,7 +294,7 @@ void tgShapefile::FromPolygon( const tgPolygon& subject, const std::string& data
}
// close after each write
ds_id = tgShapefile::CloseDatasource( ds_id );
tgShapefile::CloseDatasource( ds_id );
}
tgPolygon tgShapefile::ToPolygon( const void* subject )

View file

@ -226,10 +226,10 @@ tgSurface::tgSurface( const std::string& path,
double average_elev_m,
double slope_max,
double slope_eps
)
) :
_aptBounds(aptBounds)
{
// Calculate desired size of grid
_aptBounds = aptBounds;
_min_deg = _aptBounds.getMin();
_max_deg = _aptBounds.getMax();
_average_elev_m = average_elev_m;

View file

@ -27,9 +27,9 @@
class SGGeodIndex {
public:
explicit SGGeodIndex( SGGeod g ) {
geod = g;
explicit SGGeodIndex( SGGeod g ) :
geod(g)
{
std::size_t FNV_prime;
std::size_t offset_basis;

View file

@ -39,8 +39,9 @@ public:
// constructor for serialization only
}
TGNode( SGGeod p ) {
position = p;
explicit TGNode( SGGeod p ) :
position(p)
{
CalcWgs84();
fixed_position = false; // no matter what - don't move x, y, or z (likely a hole around an airport generated ny genapts)
@ -131,9 +132,9 @@ private:
class TGNodeIndex {
public:
TGNodeIndex( SGGeod g ) {
geod = g;
explicit TGNodeIndex( SGGeod g ) :
geod(g)
{
std::size_t FNV_prime;
std::size_t offset_basis;

View file

@ -135,7 +135,7 @@ void Decoder::processLineString(OGRLineString* poGeometry, const string& area_ty
SGGeod p0, p1;
double heading, dist, az2;
int i, j, numPoints, numSegs;
int j, numPoints, numSegs;
double max_dist;
numPoints = poGeometry->getNumPoints();
@ -154,7 +154,7 @@ void Decoder::processLineString(OGRLineString* poGeometry, const string& area_ty
line.AddNode( SGGeodesy::direct( p0, heading, EP_STRETCH ) );
// now add the middle points : if they are too far apart, add intermediate nodes
for ( i=1;i<numPoints-1;i++) {
for ( int i = 1; i < numPoints - 1; ++i) {
p0 = SGGeod::fromDeg( poGeometry->getX(i-1), poGeometry->getY(i-1) );
p1 = SGGeod::fromDeg( poGeometry->getX(i ), poGeometry->getY(i ) );
SGGeodesy::inverse( p0, p1, heading, az2, dist );
@ -185,7 +185,7 @@ void Decoder::processLineString(OGRLineString* poGeometry, const string& area_ty
// make a plygons from the line segments
segments = tgContour::ExpandToPolygons( line, width );
for ( unsigned int i=0; i<segments.size(); i++ ) {
for ( unsigned int i = 0; i < segments.size(); ++i ) {
segments[i].SetPreserve3D( false );
if (with_texture) {
segments[i].SetTexMethod( TG_TEX_BY_TPS_CLIPU );
@ -296,7 +296,7 @@ void Decoder::run()
}
}
OGRMultiPoint* multipt=(OGRMultiPoint*)poGeometry;
for (int i=0;i<multipt->getNumGeometries();i++) {
for (int i = 0; i < multipt->getNumGeometries(); ++i) {
processPoint((OGRPoint*)(multipt->getGeometryRef(i)), area_type_name, width);
}
break;
@ -325,7 +325,7 @@ void Decoder::run()
}
OGRMultiLineString* multilines=(OGRMultiLineString*)poGeometry;
for (int i=0;i<multilines->getNumGeometries();i++) {
for (int i = 0; i < multilines->getNumGeometries(); ++i) {
processLineString((OGRLineString*)(multilines->getGeometryRef(i)), area_type_name, width, texture_lines);
}
break;
@ -338,7 +338,7 @@ void Decoder::run()
case wkbMultiPolygon: {
SG_LOG( SG_GENERAL, SG_DEBUG, "MultiPolygon feature" );
OGRMultiPolygon* multipoly=(OGRMultiPolygon*)poGeometry;
for (int i=0;i<multipoly->getNumGeometries();i++) {
for (int i = 0; i < multipoly->getNumGeometries(); ++i) {
processPolygon((OGRPolygon*)(multipoly->getGeometryRef(i)), area_type_name);
}
break;
@ -478,7 +478,7 @@ void processLayer(OGRLayer* poLayer, tgChopper& results )
// Now process the workqueue with threads
// this just generates all the tgPolygons
std::vector<std::shared_ptr<Decoder>> decoders;
for (int i=0; i<num_threads; i++) {
for (int i = 0; i < num_threads; ++i) {
auto decoder = std::make_shared<Decoder>( poCT, area_type_field, point_width_field, line_width_field, results );
decoder->start();
decoders.push_back( decoder );
@ -738,7 +738,7 @@ int main( int argc, char **argv ) {
processLayer(poLayer, results );
}
} else {
for (int i=0;i<poDS->GetLayerCount();i++) {
for (int i = 0; i < poDS->GetLayerCount(); ++i) {
poLayer = poDS->GetLayer(i);
assert(poLayer != NULL);

View file

@ -91,9 +91,10 @@ public:
}
depth=32;
}
virtual ~ArrayMap() {}
virtual Terra::real eval(int i, int j) {
virtual Terra::real eval(int i, int j) override {
return (Terra::real)array.get_array_elev(i,j);
}

View file

@ -53,7 +53,7 @@ typedef std::map<std::string,OGRLayer*> LayerMap;
const char* format_name="ESRI Shapefile";
bool do_split=false;
OGRDataSource *datasource;
GDALDataset *datasource;
OGRLayer *defaultLayer;
OGRLayer *pointsLayer=NULL;
LayerMap layerMap;
@ -530,7 +530,7 @@ int main(int argc, char** argv) {
}
const char* dst_datasource = argv[optind++];
auto datasource = gdalDriver->Create(dst_datasource, 0, 0, 0, GDALDataType::GDT_Unknown, NULL);
datasource = gdalDriver->Create(dst_datasource, 0, 0, 0, GDALDataType::GDT_Unknown, NULL);
if (!datasource) {
usage(argv[0],std::string("Unable to create datasource:") + dst_datasource);
exit(1);