Skip to content
Permalink
Browse files

Fix (harmless) Coverity warnings

  • Loading branch information
nyalldawson committed Feb 12, 2016
1 parent 3567191 commit 9e2890dad4912c3714a0cc9fbf7ac0f12d2db189
@@ -157,13 +157,14 @@ double QgsUnitTypes::fromUnitToUnitFactor( QGis::UnitType fromUnit, QGis::UnitTy
#define NMILE_TO_METER 1852.0

// Unify degree units
// remove for QGIS 3.0, as extra degree types will be removed
if ( fromUnit == QGis::DecimalDegrees || fromUnit == QGis::DegreesMinutesSeconds || fromUnit == QGis::DegreesDecimalMinutes )
fromUnit = QGis::Degrees;
if ( toUnit == QGis::DecimalDegrees || toUnit == QGis::DegreesMinutesSeconds || toUnit == QGis::DegreesDecimalMinutes )
toUnit = QGis::Degrees;

// Calculate the conversion factor between the specified units
if ( fromUnit != toUnit && fromUnit != QGis::UnknownUnit && toUnit != QGis::UnknownUnit )
if ( fromUnit != toUnit )
{
switch ( fromUnit )
{
@@ -217,8 +218,6 @@ QString QgsUnitTypes::encodeUnit( QgsSymbolV2::OutputUnit unit )
default:
return "MM";
}
//avoid warning
return QString();
}

QgsSymbolV2::OutputUnit QgsUnitTypes::decodeSymbolUnit( const QString& string, bool* ok )
@@ -108,34 +108,34 @@ void TestQgsMapToPixelGeometrySimplifier::cleanup()

void TestQgsMapToPixelGeometrySimplifier::testDefaultGeometry()
{
QgsGeometry *g = new QgsGeometry();
QScopedPointer< QgsGeometry > g( new QgsGeometry() );
int fl = QgsMapToPixelSimplifier::SimplifyGeometry;
bool ret = QgsMapToPixelSimplifier::simplifyGeometry( g, fl, 10.0 );
bool ret = QgsMapToPixelSimplifier::simplifyGeometry( g.data(), fl, 10.0 );
QVERIFY( ! ret ); // not simplifiable
}

void TestQgsMapToPixelGeometrySimplifier::testLine1()
{
// NOTE: we need more than 4 vertices, or the line will not be
// reduced at all by the algorithm
QgsGeometry *g = QgsGeometry::fromWkt( "LINESTRING(0 0,1 1,2 0,3 1,4 0,20 1,20 0,10 0,5 0)" );
QScopedPointer< QgsGeometry > g( QgsGeometry::fromWkt( "LINESTRING(0 0,1 1,2 0,3 1,4 0,20 1,20 0,10 0,5 0)" ) );
int fl;
bool ret;
QString wkt;

fl = QgsMapToPixelSimplifier::SimplifyGeometry;
ret = QgsMapToPixelSimplifier::simplifyGeometry( g, fl, 10.0 );
ret = QgsMapToPixelSimplifier::simplifyGeometry( g.data(), fl, 10.0 );
QVERIFY( ret );
wkt = g->exportToWkt();
// NOTE: I don't think vertex 1,1 should be in this result,
// but that's what we get now
QCOMPARE( wkt, QString( "LineString (0 0, 1 1, 20 1, 10 0, 5 0)" ) );

fl = QgsMapToPixelSimplifier::SimplifyEnvelope;
ret = QgsMapToPixelSimplifier::simplifyGeometry( g, fl, 20.0 );
ret = QgsMapToPixelSimplifier::simplifyGeometry( g.data(), fl, 20.0 );
QVERIFY( ! ret );

ret = QgsMapToPixelSimplifier::simplifyGeometry( g, fl, 30.0 );
ret = QgsMapToPixelSimplifier::simplifyGeometry( g.data(), fl, 30.0 );
QVERIFY( ret );
wkt = g->exportToWkt();
// NOTE: I don't understand this result either
@@ -36,7 +36,8 @@ class TestQgsFieldExpressionWidget : public QObject

public:
TestQgsFieldExpressionWidget()
: mLayerA( nullptr )
: mWidget( nullptr )
, mLayerA( nullptr )
, mLayerB( nullptr )
{}

0 comments on commit 9e2890d

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