Skip to content
Permalink
Browse files

Fix some more old style cast and float comparison warnings

  • Loading branch information
nyalldawson committed Dec 30, 2015
1 parent 566dd4b commit 766bfa1a7f5dc160e20e01e6acbb346a033670b7
@@ -165,7 +165,7 @@ class QgsCoordinateTransform : QObject
/** See if the transform short circuits because src and dest are equivalent
* @return bool True if it short circuits
*/
bool isShortCircuited();
bool isShortCircuited() const;

/** Change the destination coordinate system by passing it a qgis srsid
* A QGIS srsid is a unique key value to an entry on the tbl_srs in the
@@ -211,7 +211,7 @@ static void dumpBacktrace( unsigned int depth )
}

close( fd[1] ); // close writing end
execl( "/usr/bin/c++filt", "c++filt", ( char * ) nullptr );
execl( "/usr/bin/c++filt", "c++filt", static_cast< char * >( nullptr ) );
perror( "could not start c++filt" );
exit( 1 );
}
@@ -73,7 +73,7 @@ void QgsLabelingWidget::labelModeChanged( int index )
if ( QgsLabelingGui* widgetSimple = qobject_cast<QgsLabelingGui*>( mWidget ) )
{
// lighter variant - just change the mode of existing widget
widgetSimple->setLabelMode(( QgsLabelingGui::LabelMode ) index );
widgetSimple->setLabelMode( static_cast< QgsLabelingGui::LabelMode >( index ) );
return;
}
}
@@ -93,7 +93,7 @@ void QgsLabelingWidget::labelModeChanged( int index )
else
{
QgsLabelingGui* w = new QgsLabelingGui( mLayer, mCanvas, nullptr, this );
w->setLabelMode(( QgsLabelingGui::LabelMode ) index );
w->setLabelMode( static_cast< QgsLabelingGui::LabelMode >( index ) );
w->init();
mWidget = w;
}
@@ -872,7 +872,7 @@ void QgsVectorLayerProperties::saveStyleAsMenuTriggered( QAction *action )
if ( index < 0 )
return;

saveStyleAs(( StyleType ) index );
saveStyleAs( static_cast< StyleType >( index ) );
}

void QgsVectorLayerProperties::saveStyleAs( StyleType styleType )
@@ -420,7 +420,7 @@ void QgsDxfExport::writeGroup( const QColor& color, int exactMatchCode, int rgbC
int minDistAt = -1;
int minDist = INT_MAX;

for ( int i = 1; i < ( int )( sizeof( mDxfColors ) / sizeof( *mDxfColors ) ) && minDist > 0; ++i )
for ( int i = 1; i < static_cast< int >( sizeof( mDxfColors ) / sizeof( *mDxfColors ) ) && minDist > 0; ++i )
{
int dist = color_distance( color.rgba(), i );
if ( dist >= minDist )
@@ -3801,7 +3801,7 @@ int QgsDxfExport::closestColorMatch( QRgb pixel )
{
int idx = 0;
int current_distance = INT_MAX;
for ( int i = 1; i < ( int )( sizeof( mDxfColors ) / sizeof( *mDxfColors ) ); ++i )
for ( int i = 1; i < static_cast< int >( sizeof( mDxfColors ) / sizeof( *mDxfColors ) ); ++i )
{
int dist = color_distance( pixel, i );
if ( dist < current_distance )
@@ -4136,10 +4136,10 @@ QString QgsDxfExport::dxfEncoding( const QString &name )
continue;

int i;
for ( i = 0; i < ( int )( sizeof( mDxfEncodings ) / sizeof( *mDxfEncodings ) ) && name != mDxfEncodings[i][1]; ++i )
for ( i = 0; i < static_cast< int >( sizeof( mDxfEncodings ) / sizeof( *mDxfEncodings ) ) && name != mDxfEncodings[i][1]; ++i )
;

if ( i == ( int )( sizeof( mDxfEncodings ) / sizeof( *mDxfEncodings ) ) )
if ( i == static_cast< int >( sizeof( mDxfEncodings ) / sizeof( *mDxfEncodings ) ) )
continue;

return mDxfEncodings[i][0];
@@ -4154,10 +4154,10 @@ QStringList QgsDxfExport::encodings()
Q_FOREACH ( QByteArray codec, QTextCodec::availableCodecs() )
{
int i;
for ( i = 0; i < ( int )( sizeof( mDxfEncodings ) / sizeof( *mDxfEncodings ) ) && strcmp( codec.data(), mDxfEncodings[i][1] ) != 0; ++i )
for ( i = 0; i < static_cast< int >( sizeof( mDxfEncodings ) / sizeof( *mDxfEncodings ) ) && strcmp( codec.data(), mDxfEncodings[i][1] ) != 0; ++i )
;

if ( i < ( int )( sizeof( mDxfEncodings ) / sizeof( *mDxfEncodings ) ) )
if ( i < static_cast< int >( sizeof( mDxfEncodings ) / sizeof( *mDxfEncodings ) ) )
encodings << codec.data();
}
return encodings;
@@ -27,9 +27,6 @@
*
*/

#define _CRT_SECURE_NO_DEPRECATE


#if defined(_VERBOSE_) || defined(_DEBUG_)
#include <iostream>
#endif
@@ -250,18 +247,18 @@ namespace pal
double xdiff = -labelW / 2.0;
double ydiff = -labelH / 2.0;

if ( mLF->quadOffset().x() != 0 )
if ( !qgsDoubleNear( mLF->quadOffset().x(), 0.0 ) )
{
xdiff += labelW / 2.0 * mLF->quadOffset().x();
}
if ( mLF->quadOffset().y() != 0 )
if ( !qgsDoubleNear( mLF->quadOffset().y(), 0.0 ) )
{
ydiff += labelH / 2.0 * mLF->quadOffset().y();
}

if ( ! mLF->hasFixedPosition() )
{
if ( angle != 0 )
if ( !qgsDoubleNear( angle, 0.0 ) )
{
double xd = xdiff * cos( angle ) - ydiff * sin( angle );
double yd = xdiff * sin( angle ) + ydiff * cos( angle );
@@ -290,11 +287,11 @@ namespace pal
}
else
{
if ( mLF->positionOffset().x() != 0 )
if ( !qgsDoubleNear( mLF->positionOffset().x(), 0.0 ) )
{
xdiff += mLF->positionOffset().x();
}
if ( mLF->positionOffset().y() != 0 )
if ( !qgsDoubleNear( mLF->positionOffset().y(), 0.0 ) )
{
ydiff += mLF->positionOffset().y();
}
@@ -359,7 +356,7 @@ namespace pal
gamma2 = a90 / 3.0;


if ( gamma1 == 0 || gamma2 == 0 )
if ( qgsDoubleNear( gamma1, 0.0 ) || qgsDoubleNear( gamma2, 0.0 ) )
{
std::cout << "Oups... label size error..." << std::endl;
}
@@ -538,7 +535,7 @@ namespace pal
ad[line->nbPoints-1] = ll;


nbls = ( int )( ll / xrm ); // ratio bw line length and label width
nbls = static_cast< int >( ll / xrm ); // ratio bw line length and label width

#ifdef _DEBUG_FULL_
std::cout << "line length :" << ll << std::endl;
@@ -707,7 +704,7 @@ namespace pal
double dy = new_y - old_y;

double segment_length = path_distances[index];
if ( segment_length == 0 )
if ( qgsDoubleNear( segment_length, 0.0 ) )
{
// Not allowed to place across on 0 length segments or discontinuities
return nullptr;
@@ -732,7 +729,7 @@ namespace pal
LabelInfo::CharacterInfo& ci = ( orientation > 0 ? li->char_info[i] : li->char_info[li->char_num-i-1] );

// Coordinates this character will start at
if ( segment_length == 0 )
if ( qgsDoubleNear( segment_length, 0.0 ) )
{
// Not allowed to place across on 0 length segments or discontinuities
delete slp;
@@ -895,7 +892,7 @@ namespace pal
total_distance += path_distances[i];
}

if ( total_distance == 0 )
if ( qgsDoubleNear( total_distance, 0.0 ) )
{
delete[] path_distances;
return 0;
@@ -165,7 +165,8 @@ namespace pal
b2 = x3 - x4;
c2 = x4 * y3 - x3 * y4;

if (( denom = a1 * b2 - a2 * b1 ) == 0 )
denom = a1 * b2 - a2 * b1;
if ( qgsDoubleNear( denom, 0.0 ) )
{
return false;
}
@@ -376,7 +377,7 @@ namespace pal
// Should never happen, No real solutions.
return;

if ( det == 0 )
if ( qgsDoubleNear( det, 0.0 ) )
{
// Could potentially happen.... One solution.
double t = -B / ( 2 * A );
@@ -27,8 +27,6 @@
*
*/

#define _CRT_SECURE_NO_DEPRECATE

#include "layer.h"
#include "pal.h"
#include "costcalculator.h"
@@ -395,19 +393,9 @@ namespace pal
nextPart->setConflictsWithObstacle( conflicts );
}

bool LabelPosition::costShrink( void *l, void *r )
{
return (( LabelPosition* ) l )->mCost < (( LabelPosition* ) r )->mCost;
}

bool LabelPosition::costGrow( void *l, void *r )
{
return (( LabelPosition* ) l )->mCost > (( LabelPosition* ) r )->mCost;
}

bool LabelPosition::polygonObstacleCallback( FeaturePart *obstacle, void *ctx )
{
PolygonCostCalculator *pCost = ( PolygonCostCalculator* ) ctx;
PolygonCostCalculator *pCost = reinterpret_cast< PolygonCostCalculator* >( ctx );

LabelPosition *lp = pCost->getLabel();
if (( obstacle == lp->feature ) || ( obstacle->getHoleOf() && obstacle->getHoleOf() != lp->feature ) )
@@ -443,7 +431,7 @@ namespace pal

bool LabelPosition::pruneCallback( LabelPosition *candidatePosition, void *ctx )
{
FeaturePart *obstaclePart = (( PruneCtx* ) ctx )->obstacle;
FeaturePart *obstaclePart = ( reinterpret_cast< PruneCtx* >( ctx ) )->obstacle;

// test whether we should ignore this obstacle for the candidate. We do this if:
// 1. it's not a hole, and the obstacle belongs to the same label feature as the candidate (eg
@@ -464,7 +452,7 @@ namespace pal

bool LabelPosition::countOverlapCallback( LabelPosition *lp, void *ctx )
{
LabelPosition *lp2 = ( LabelPosition* ) ctx;
LabelPosition *lp2 = reinterpret_cast< LabelPosition* >( ctx );

//std::cerr << "checking " << lp2->getFeature()->getUID() << " x " << lp->getFeature()->getUID() << std::endl;
if ( lp2->isInConflict( lp ) )
@@ -478,11 +466,12 @@ namespace pal

bool LabelPosition::countFullOverlapCallback( LabelPosition *lp, void *ctx )
{
LabelPosition *lp2 = (( CountContext* ) ctx )->lp;
double *cost = (( CountContext* ) ctx )->cost;
CountContext* context = reinterpret_cast< CountContext* >( ctx );
LabelPosition *lp2 = context->lp;
double *cost = context->cost;
//int *feat = ((CountContext*)ctx)->feat;
int *nbOv = (( CountContext* ) ctx )->nbOv;
double *inactiveCost = (( CountContext* ) ctx )->inactiveCost;
int *nbOv = context->nbOv;
double *inactiveCost = context->inactiveCost;
if ( lp2->isInConflict( lp ) )
{
#ifdef _DEBUG_FULL_
@@ -499,7 +488,7 @@ namespace pal

bool LabelPosition::removeOverlapCallback( LabelPosition *lp, void *ctx )
{
LabelPosition *lp2 = ( LabelPosition * ) ctx;
LabelPosition *lp2 = reinterpret_cast< LabelPosition * >( ctx );

if ( lp2->isInConflict( lp ) )
{
@@ -158,7 +158,7 @@ namespace pal
*/
FeaturePart * getFeaturePart();

double getNumOverlaps() const { return nbOverlap; }
int getNumOverlaps() const { return nbOverlap; }
void resetNumOverlaps() { nbOverlap = 0; } // called from problem.cpp, pal.cpp

int getProblemFeatureId() const { return probFeat; }
@@ -243,10 +243,6 @@ namespace pal
/** Check whether the candidate in ctx overlap with obstacle feat */
static bool pruneCallback( LabelPosition *candidatePosition, void *ctx );

// for sorting
static bool costShrink( void *l, void *r );
static bool costGrow( void *l, void *r );

// for counting number of overlaps
typedef struct
{
@@ -157,7 +157,7 @@ namespace pal
GEOSContextHandle_t geosctxt = geosContext();

bool needClose = false;
if ( type == GEOS_POLYGON && ( x[0] != x[ nbPoints - 1] || y[0] != y[ nbPoints - 1 ] ) )
if ( type == GEOS_POLYGON && ( !qgsDoubleNear( x[0], x[ nbPoints - 1] ) || !qgsDoubleNear( y[0], y[ nbPoints - 1 ] ) ) )
{
needClose = true;
}

0 comments on commit 766bfa1

Please sign in to comment.
You can’t perform that action at this time.