Skip to content

Commit 05ae00d

Browse files
committed
Merge branch 'master' of github.com:qgis/Quantum-GIS
2 parents 8fd7805 + 5243423 commit 05ae00d

38 files changed

+1202
-496
lines changed

python/core/qgsrasterinterface.sip

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class QgsRasterInterface
8282

8383
virtual int bandCount() const;
8484

85-
virtual double noDataValue() const;
85+
virtual double noDataValue( int bandNo ) const;
8686

8787
virtual void * block( int bandNo, const QgsRectangle & extent, int width, int height );
8888

python/core/qgsrasterlayer.sip

+4-4
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public:
172172
int height();
173173

174174
/** \brief Is the NoDataValue Valid */
175-
bool isNoDataValueValid() const;
175+
//bool isNoDataValueValid() const;
176176

177177
/** \brief Accessor for mGrayMinimumMaximumEstimated */
178178
//bool isGrayMinimumMaximumEstimated() const; //removed with raster redesign
@@ -181,7 +181,7 @@ public:
181181
//bool isRGBMinimumMaximumEstimated() const; //removed with raster redesign
182182

183183
/** \brief Accessor that returns the NO_DATA entry for this raster */
184-
double noDataValue( bool* isValid = 0 );
184+
//double noDataValue( bool* isValid = 0 );
185185

186186
/** \brief Returns a pointer to the transparency object */
187187
//QgsRasterTransparency* rasterTransparency(); //removed with raster redesign
@@ -385,7 +385,7 @@ public:
385385
//bool readColorTable( int theBandNumber, QList<QgsColorRampShader::ColorRampItem>* theList );
386386

387387
/** \brief Simple reset function that set the noDataValue back to the value stored in the first raster band */
388-
void resetNoDataValue();
388+
//void resetNoDataValue();
389389

390390
/** \brief Mutator for blue band name mapping */
391391
void setBlueBandName( const QString & theBandName );
@@ -431,7 +431,7 @@ public:
431431
void setMinimumValue( QString theBand, double theValue, bool theGenerateLookupTableFlag = true );
432432

433433
/** \brief Mutator that allows the NO_DATA entry for this raster to be overridden */
434-
void setNoDataValue( double theNoData );
434+
//void setNoDataValue( double theNoData );
435435

436436
/** \brief Set the raster shader function to a user defined function
437437
\note ownership of the shader function is transfered to raster shader */

python/gui/qgsrasterformatsaveoptionswidget.sip

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class QgsRasterFormatSaveOptionsWidget : QWidget
2929

3030
void apply();
3131
void helpOptions();
32-
bool validateOptions( bool gui = true );
32+
QString validateOptions( bool gui = true, bool reportOk = true );
3333

3434
private slots:
3535

src/app/qgsrasterlayerproperties.cpp

+16-9
Original file line numberDiff line numberDiff line change
@@ -546,13 +546,20 @@ void QgsRasterLayerProperties::sync()
546546
// TODO: no data ranges
547547
if ( mRasterLayer->dataProvider()->srcHasNoDataValue( 1 ) )
548548
{
549-
lblSrcNoDataValue->setText( QgsRasterInterface::printValue( mRasterLayer->dataProvider()->noDataValue( 1 ) ) );
549+
lblSrcNoDataValue->setText( QgsRasterInterface::printValue( mRasterLayer->dataProvider()->srcNoDataValue( 1 ) ) );
550550
}
551551
else
552552
{
553553
lblSrcNoDataValue->setText( tr( "not defined" ) );
554554
}
555555

556+
mSrcNoDataValueCheckBox->setChecked( mRasterLayer->dataProvider()->useSrcNoDataValue( 1 ) );
557+
558+
bool enableSrcNoData = mRasterLayer->dataProvider()->srcHasNoDataValue( 1 ) && !qIsNaN( mRasterLayer->dataProvider()->srcNoDataValue( 1 ) );
559+
560+
mSrcNoDataValueCheckBox->setEnabled( enableSrcNoData );
561+
lblSrcNoDataValue->setEnabled( enableSrcNoData );
562+
556563
QList<QgsRasterInterface::Range> noDataRangeList = mRasterLayer->dataProvider()->userNoDataValue( 1 );
557564
QgsDebugMsg( QString( "noDataRangeList.size = %1" ).arg( noDataRangeList.size() ) );
558565
if ( noDataRangeList.size() > 0 )
@@ -600,13 +607,14 @@ void QgsRasterLayerProperties::sync()
600607
}
601608
else
602609
{
603-
if ( mRasterLayer->isNoDataValueValid() )
610+
// TODO: all bands
611+
if ( mRasterLayer->dataProvider()->srcHasNoDataValue( 1 ) )
604612
{
605-
lblNoData->setText( tr( "No-Data Value: %1" ).arg( mRasterLayer->noDataValue() ) );
613+
lblNoData->setText( tr( "No-Data Value: %1" ).arg( mRasterLayer->dataProvider()->noDataValue( 1 ) ) );
606614
}
607615
else
608616
{
609-
lblNoData->setText( tr( "No-Data Value: Not Set" ) );
617+
lblNoData->setText( tr( "No-Data Value: " ) + tr( "n/a" ) );
610618
}
611619
}
612620

@@ -678,6 +686,7 @@ void QgsRasterLayerProperties::apply()
678686
for ( int bandNo = 1; bandNo <= mRasterLayer->dataProvider()->bandCount(); bandNo++ )
679687
{
680688
mRasterLayer->dataProvider()->setUserNoDataValue( bandNo, myNoDataRangeList );
689+
mRasterLayer->dataProvider()->setUseSrcNoDataValue( bandNo, mSrcNoDataValueCheckBox->isChecked() );
681690
}
682691

683692
//set renderer from widget
@@ -992,32 +1001,30 @@ void QgsRasterLayerProperties::on_pbnDefaultValues_clicked()
9921001

9931002
setupTransparencyTable( nBands );
9941003

1004+
// I don't think that noDataValue should be added to transparency list
1005+
#if 0
9951006
if ( nBands == 3 )
9961007
{
9971008
if ( mRasterLayer->isNoDataValueValid() )
9981009
{
999-
// I don't think that noDataValue should be added to transparency list
1000-
#if 0
10011010
tableTransparency->insertRow( tableTransparency->rowCount() );
10021011
setTransparencyCell( 0, 0, mRasterLayer->noDataValue() );
10031012
setTransparencyCell( 0, 1, mRasterLayer->noDataValue() );
10041013
setTransparencyCell( 0, 2, mRasterLayer->noDataValue() );
10051014
setTransparencyCell( 0, 1, 100 );
1006-
#endif
10071015
}
10081016
}
10091017
else //1 band
10101018
{
10111019
if ( mRasterLayer->isNoDataValueValid() )
10121020
{
1013-
#if 0
10141021
tableTransparency->insertRow( tableTransparency->rowCount() );
10151022
setTransparencyCell( 0, 0, mRasterLayer->noDataValue() );
10161023
setTransparencyCell( 0, 1, mRasterLayer->noDataValue() );
10171024
setTransparencyCell( 0, 1, 100 );
1018-
#endif
10191025
}
10201026
}
1027+
#endif
10211028

10221029
tableTransparency->resizeColumnsToContents(); // works only with values
10231030
tableTransparency->resizeRowsToContents();

src/core/qgsgeometry.cpp

+12-12
Original file line numberDiff line numberDiff line change
@@ -4226,10 +4226,10 @@ QString QgsGeometry::exportToGeoJSON()
42264226
{
42274227
mWkt += "{ \"type\": \"Point\", \"coordinates\": [";
42284228
x = ( double * )( mGeometry + 5 );
4229-
mWkt += QString::number( *x, 'f', 6 );
4229+
mWkt += QString::number( *x, 'f' );
42304230
mWkt += ", ";
42314231
y = ( double * )( mGeometry + 5 + sizeof( double ) );
4232-
mWkt += QString::number( *y, 'f', 6 );
4232+
mWkt += QString::number( *y, 'f' );
42334233
mWkt += "] }";
42344234
return mWkt;
42354235
}
@@ -4256,11 +4256,11 @@ QString QgsGeometry::exportToGeoJSON()
42564256
}
42574257
mWkt += "[";
42584258
x = ( double * ) ptr;
4259-
mWkt += QString::number( *x, 'f', 6 );
4259+
mWkt += QString::number( *x, 'f' );
42604260
mWkt += ", ";
42614261
ptr += sizeof( double );
42624262
y = ( double * ) ptr;
4263-
mWkt += QString::number( *y, 'f', 6 );
4263+
mWkt += QString::number( *y, 'f' );
42644264
ptr += sizeof( double );
42654265
if ( hasZValue )
42664266
{
@@ -4313,11 +4313,11 @@ QString QgsGeometry::exportToGeoJSON()
43134313
}
43144314
mWkt += "[";
43154315
x = ( double * ) ptr;
4316-
mWkt += QString::number( *x, 'f', 6 );
4316+
mWkt += QString::number( *x, 'f' );
43174317
mWkt += ", ";
43184318
ptr += sizeof( double );
43194319
y = ( double * ) ptr;
4320-
mWkt += QString::number( *y, 'f', 6 );
4320+
mWkt += QString::number( *y, 'f' );
43214321
ptr += sizeof( double );
43224322
if ( hasZValue )
43234323
{
@@ -4353,11 +4353,11 @@ QString QgsGeometry::exportToGeoJSON()
43534353
}
43544354
mWkt += "[";
43554355
x = ( double * )( ptr );
4356-
mWkt += QString::number( *x, 'f', 6 );
4356+
mWkt += QString::number( *x, 'f' );
43574357
mWkt += ", ";
43584358
ptr += sizeof( double );
43594359
y = ( double * )( ptr );
4360-
mWkt += QString::number( *y, 'f', 6 );
4360+
mWkt += QString::number( *y, 'f' );
43614361
ptr += sizeof( double );
43624362
if ( hasZValue )
43634363
{
@@ -4399,11 +4399,11 @@ QString QgsGeometry::exportToGeoJSON()
43994399
}
44004400
mWkt += "[";
44014401
x = ( double * ) ptr;
4402-
mWkt += QString::number( *x, 'f', 6 );
4402+
mWkt += QString::number( *x, 'f' );
44034403
ptr += sizeof( double );
44044404
mWkt += ", ";
44054405
y = ( double * ) ptr;
4406-
mWkt += QString::number( *y, 'f', 6 );
4406+
mWkt += QString::number( *y, 'f' );
44074407
ptr += sizeof( double );
44084408
if ( hasZValue )
44094409
{
@@ -4457,11 +4457,11 @@ QString QgsGeometry::exportToGeoJSON()
44574457
}
44584458
mWkt += "[";
44594459
x = ( double * ) ptr;
4460-
mWkt += QString::number( *x, 'f', 6 );
4460+
mWkt += QString::number( *x, 'f' );
44614461
ptr += sizeof( double );
44624462
mWkt += ", ";
44634463
y = ( double * ) ptr;
4464-
mWkt += QString::number( *y, 'f', 6 );
4464+
mWkt += QString::number( *y, 'f' );
44654465
ptr += sizeof( double );
44664466
if ( hasZValue )
44674467
{

src/core/qgsrasterdataprovider.cpp

+28-8
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,27 @@
2525

2626
#include <qmath.h>
2727

28+
void QgsRasterDataProvider::setUseSrcNoDataValue( int bandNo, bool use )
29+
{
30+
if ( mUseSrcNoDataValue.size() < bandNo )
31+
{
32+
for ( int i = mUseSrcNoDataValue.size(); i < bandNo; i++ )
33+
{
34+
mUseSrcNoDataValue.append( false );
35+
}
36+
}
37+
mUseSrcNoDataValue[bandNo-1] = use;
38+
}
39+
40+
double QgsRasterDataProvider::noDataValue( int bandNo ) const
41+
{
42+
if ( mSrcHasNoDataValue.value( bandNo - 1 ) && mUseSrcNoDataValue.value( bandNo - 1 ) )
43+
{
44+
return mSrcNoDataValue.value( bandNo -1 );
45+
}
46+
return mInternalNoDataValue.value( bandNo -1 );
47+
}
48+
2849
void QgsRasterDataProvider::readBlock( int bandNo, QgsRectangle
2950
const & viewExtent, int width,
3051
int height,
@@ -289,7 +310,7 @@ QByteArray QgsRasterDataProvider::noValueBytes( int theBandNo )
289310
QByteArray ba;
290311
ba.resize(( int )size );
291312
char * data = ba.data();
292-
double noval = mNoDataValue[theBandNo-1];
313+
double noval = noDataValue( theBandNo - 1 );
293314
unsigned char uc;
294315
unsigned short us;
295316
short s;
@@ -616,7 +637,6 @@ QgsRasterBandStats QgsRasterDataProvider::bandStatistics( int theBandNo,
616637
int myWidth = myRasterBandStats.width;
617638
int myHeight = myRasterBandStats.height;
618639

619-
double myNoDataValue = noDataValue();
620640
int myDataType = dataType( theBandNo );
621641

622642
int myXBlockSize = xBlockSize();
@@ -669,7 +689,8 @@ QgsRasterBandStats QgsRasterDataProvider::bandStatistics( int theBandNo,
669689
double myValue = readValue( myData, myDataType, myX + ( myY * myBlockWidth ) );
670690
//QgsDebugMsg ( QString ( "%1 %2 value %3" ).arg (myX).arg(myY).arg( myValue ) );
671691

672-
if ( mValidNoDataValue && ( qAbs( myValue - myNoDataValue ) <= TINY_VALUE ) )
692+
// TODO: user nodata
693+
if ( isNoDataValue( theBandNo, myValue ) )
673694
{
674695
continue; // NULL
675696
}
@@ -718,7 +739,6 @@ QgsRasterBandStats QgsRasterDataProvider::bandStatistics( int theBandNo,
718739
myRasterBandStats.stdDev = sqrt( mySumOfSquares / ( myRasterBandStats.elementCount - 1 ) );
719740

720741
QgsDebugMsg( "************ STATS **************" );
721-
QgsDebugMsg( QString( "VALID NODATA %1" ).arg( mValidNoDataValue ) );
722742
QgsDebugMsg( QString( "MIN %1" ).arg( myRasterBandStats.minimumValue ) );
723743
QgsDebugMsg( QString( "MAX %1" ).arg( myRasterBandStats.maximumValue ) );
724744
QgsDebugMsg( QString( "RANGE %1" ).arg( myRasterBandStats.range ) );
@@ -893,7 +913,6 @@ QgsRasterHistogram QgsRasterDataProvider::histogram( int theBandNo,
893913
QgsRectangle myExtent = myHistogram.extent;
894914
myHistogram.histogramVector.resize( myBinCount );
895915

896-
double myNoDataValue = noDataValue();
897916
int myDataType = dataType( theBandNo );
898917

899918
int myXBlockSize = xBlockSize();
@@ -953,7 +972,8 @@ QgsRasterHistogram QgsRasterDataProvider::histogram( int theBandNo,
953972
double myValue = readValue( myData, myDataType, myX + ( myY * myBlockWidth ) );
954973
//QgsDebugMsg ( QString ( "%1 %2 value %3" ).arg (myX).arg(myY).arg( myValue ) );
955974

956-
if ( mValidNoDataValue && ( qAbs( myValue - myNoDataValue ) <= TINY_VALUE ) )
975+
// TODO: user defined nodata values
976+
if ( isNoDataValue( theBandNo, myValue ) )
957977
{
958978
continue; // NULL
959979
}
@@ -1034,7 +1054,7 @@ void QgsRasterDataProvider::cumulativeCut( int theBandNo,
10341054
double QgsRasterDataProvider::readValue( void *data, int type, int index )
10351055
{
10361056
if ( !data )
1037-
return mValidNoDataValue ? noDataValue() : 0.0;
1057+
return std::numeric_limits<double>::quiet_NaN();
10381058

10391059
switch ( type )
10401060
{
@@ -1063,7 +1083,7 @@ double QgsRasterDataProvider::readValue( void *data, int type, int index )
10631083
QgsLogger::warning( "GDAL data type is not supported" );
10641084
}
10651085

1066-
return mValidNoDataValue ? noDataValue() : 0.0;
1086+
return std::numeric_limits<double>::quiet_NaN();
10671087
}
10681088

10691089
void QgsRasterDataProvider::setUserNoDataValue( int bandNo, QList<QgsRasterInterface::Range> noData )

0 commit comments

Comments
 (0)