Skip to content
Permalink
Browse files

raster calculator: allow unquoted raster references (fixes #11682)

  • Loading branch information
jef-n committed Feb 9, 2015
1 parent d0159e2 commit b35a596af47d1f0108eedf014c5c56e34e111b55
@@ -19,11 +19,12 @@
#include "qgsrastercalcnode.h"
#include "qgsrasterlayer.h"
#include "qgsrastermatrix.h"
#include "cpl_string.h"

#include <QProgressDialog>
#include <QFile>

#include "gdalwarper.h"
#include <cpl_string.h>
#include <gdalwarper.h>
#include <ogr_srs_api.h>

#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1800
@@ -35,8 +36,14 @@
#endif

QgsRasterCalculator::QgsRasterCalculator( const QString& formulaString, const QString& outputFile, const QString& outputFormat,
const QgsRectangle& outputExtent, int nOutputColumns, int nOutputRows, const QVector<QgsRasterCalculatorEntry>& rasterEntries ): mFormulaString( formulaString ), mOutputFile( outputFile ), mOutputFormat( outputFormat ),
mOutputRectangle( outputExtent ), mNumOutputColumns( nOutputColumns ), mNumOutputRows( nOutputRows ), mRasterEntries( rasterEntries )
const QgsRectangle& outputExtent, int nOutputColumns, int nOutputRows, const QVector<QgsRasterCalculatorEntry>& rasterEntries )
: mFormulaString( formulaString )
, mOutputFile( outputFile )
, mOutputFormat( outputFormat )
, mOutputRectangle( outputExtent )
, mNumOutputColumns( nOutputColumns )
, mNumOutputRows( nOutputRows )
, mRasterEntries( rasterEntries )
{
}

@@ -71,7 +78,7 @@ int QgsRasterCalculator::processCalculation( QProgressDialog* p )
return 2;
}
GDALDatasetH inputDataset = GDALOpen( TO8F( it->raster->source() ), GA_ReadOnly );
if ( inputDataset == NULL )
if ( !inputDataset )
{
return 2;
}
@@ -94,7 +101,6 @@ int QgsRasterCalculator::processCalculation( QProgressDialog* p )
mInputDatasets.push_back( inputDataset );
}


GDALRasterBandH inputRasterBand = GDALGetRasterBand( inputDataset, it->bandNumber );
if ( inputRasterBand == NULL )
{
@@ -412,5 +418,3 @@ void QgsRasterCalculator::outputGeoTransform( double* transform ) const
transform[4] = 0;
transform[5] = -mOutputRectangle.height() / mNumOutputRows;
}


@@ -28,12 +28,18 @@ QgsRasterMatrix::QgsRasterMatrix()
{
}

QgsRasterMatrix::QgsRasterMatrix( int nCols, int nRows, float* data, double nodataValue ):
mColumns( nCols ), mRows( nRows ), mData( data ), mNodataValue( nodataValue )
QgsRasterMatrix::QgsRasterMatrix( int nCols, int nRows, float* data, double nodataValue )
: mColumns( nCols )
, mRows( nRows )
, mData( data )
, mNodataValue( nodataValue )
{
}

QgsRasterMatrix::QgsRasterMatrix( const QgsRasterMatrix& m ): mColumns( 0 ), mRows( 0 ), mData( 0 )
QgsRasterMatrix::QgsRasterMatrix( const QgsRasterMatrix& m )
: mColumns( 0 )
, mRows( 0 )
, mData( 0 )
{
operator=( m );
}
@@ -67,7 +67,7 @@ QString QgsRasterCalcDialog::outputFile() const
return outputFileName;
}

return ( outputFileName + "." + it.value() );
return outputFileName + "." + it.value();
}

QString QgsRasterCalcDialog::outputFormat() const
@@ -130,7 +130,7 @@ void QgsRasterCalcDialog::insertAvailableRasterBands()
QgsRasterCalculatorEntry entry;
entry.raster = rlayer;
entry.bandNumber = i + 1;
entry.ref = quoteBandEntry( rlayer->name() + "@" + QString::number( i + 1 ) );
entry.ref = rlayer->name() + "@" + QString::number( i + 1 );
mAvailableRasterBands.push_back( entry );
mRasterBandsListWidget->addItem( entry.ref );
}
@@ -146,7 +146,7 @@ void QgsRasterCalcDialog::insertAvailableOutputFormats()
for ( int i = 0; i < nDrivers; ++i )
{
GDALDriverH driver = GDALGetDriver( i );
if ( driver != NULL )
if ( driver )
{
char** driverMetadata = GDALGetMetadata( driver, NULL );
if ( CSLFetchBoolean( driverMetadata, GDAL_DCAP_CREATE, false ) )
@@ -309,7 +309,7 @@ bool QgsRasterCalcDialog::filePathValid() const

void QgsRasterCalcDialog::on_mRasterBandsListWidget_itemDoubleClicked( QListWidgetItem* item )
{
mExpressionTextEdit->insertPlainText( item->text() );
mExpressionTextEdit->insertPlainText( quoteBandEntry( item->text() ) );
}

void QgsRasterCalcDialog::on_mPlusPushButton_clicked()
@@ -182,8 +182,8 @@ QgsPostgresConn::QgsPostgresConn( QString conninfo, bool readOnly, bool shared,
, mPostgresqlVersion( 0 )
, mPostgisVersionMajor( 0 )
, mPostgisVersionMinor( 0 )
, mGistAvailable( 0 )
, mProjAvailable( 0 )
, mGistAvailable( false )
, mProjAvailable( false )
, mUseWkbHex( false )
, mReadOnly( readOnly )
, mSwapEndian( false )
@@ -920,8 +920,8 @@ bool QgsPostgresConn::openCursor( QString cursorName, QString sql )
PQexecNR( "BEGIN" );
}
QgsDebugMsgLevel( QString( "Binary cursor %1 for %2" ).arg( cursorName ).arg( sql ), 3 );
return PQexecNR( QString( "DECLARE %1 BINARY CURSOR %2 FOR %3" ).
arg( cursorName ).arg( !mTransaction ? "" : QString( "WITH HOLD" ) ).arg( sql ) );
return PQexecNR( QString( "DECLARE %1 BINARY CURSOR%2 FOR %3" ).
arg( cursorName ).arg( !mTransaction ? "" : QString( " WITH HOLD" ) ).arg( sql ) );
}

bool QgsPostgresConn::closeCursor( QString cursorName )

0 comments on commit b35a596

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