@@ -90,6 +90,35 @@ QgsGrassRasterProvider::QgsGrassRasterProvider( QString const & uri )
9090 mGrassDataType = mInfo [" TYPE" ].toInt ();
9191 QgsDebugMsg ( " mGrassDataType = " + QString::number ( mGrassDataType ) );
9292
93+ // TODO: avoid showing these strange numbers in GUI
94+ // TODO: don't save no data values in project file, add a flag if value was defined by user
95+ if ( mGrassDataType == CELL_TYPE )
96+ {
97+ // limit: -2147483647;
98+ mNoDataValue = -2000000000 ;
99+ }
100+ else if ( mGrassDataType == DCELL_TYPE )
101+ {
102+ // Don't use numeric limits, raster layer is using
103+ // qAbs( myValue - mNoDataValue ) <= TINY_VALUE
104+ // if the mNoDataValue would be a limit, the subtraction could overflow.
105+ // No data value is shown in GUI, use some nice number.
106+ // Choose values with small representation error.
107+ // limit: 1.7976931348623157e+308
108+ mNoDataValue = -1e+300 ;
109+ }
110+ else
111+ {
112+ if ( mGrassDataType != FCELL_TYPE )
113+ {
114+ QgsDebugMsg ( " unexpected data type" );
115+ }
116+
117+ // limit: 3.40282347e+38
118+ mNoDataValue = -1e+30 ;
119+ }
120+ QgsDebugMsg ( QString ( " mNoDataValue = %1" ).arg ( mNoDataValue ) );
121+
93122 // TODO: refresh mRows and mCols if raster was rewritten
94123 // We have to decide some reasonable block size, not to big to occupate too much
95124 // memory, not too small to result in too many calls to readBlock -> qgis.d.rast
@@ -258,36 +287,7 @@ void QgsGrassRasterProvider::readBlock( int bandNo, QgsRectangle const & viewEx
258287
259288double QgsGrassRasterProvider::noDataValue () const
260289{
261- double nul;
262- // TODO: avoid showing these strange numbers in GUI
263- // TODO: don't save no data values in project file, add a flag if value was defined by user
264- if ( mGrassDataType == CELL_TYPE )
265- {
266- // limit: -2147483647;
267- nul = -2000000000 ;
268- }
269- else if ( mGrassDataType == DCELL_TYPE )
270- {
271- // Don't use numeric limits, raster layer is using
272- // qAbs( myValue - mNoDataValue ) <= TINY_VALUE
273- // if the mNoDataValue would be a limit, the subtraction could overflow.
274- // No data value is shown in GUI, use some nice number.
275- // Choose values with small representation error.
276- // limit: 1.7976931348623157e+308
277- nul = -1e+300 ;
278- }
279- else
280- {
281- if ( mGrassDataType != FCELL_TYPE )
282- {
283- QgsDebugMsg ( " unexpected data type" );
284- }
285-
286- // limit: 3.40282347e+38
287- nul = -1e+30 ;
288- }
289- QgsDebugMsg ( QString ( " noDataValue = %1" ).arg ( nul ) );
290- return nul;
290+ return mNoDataValue ;
291291}
292292
293293double QgsGrassRasterProvider::minimumValue ( int bandNo ) const
0 commit comments