mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
GRASS direct no data for type
This commit is contained in:
parent
9e82df814b
commit
a7e1d40e8a
@ -605,21 +605,7 @@ int QgsGrassGisLib::G_open_raster_new( const char *name, RASTER_MAP_TYPE wr_type
|
|||||||
}
|
}
|
||||||
|
|
||||||
raster.band = 1;
|
raster.band = 1;
|
||||||
double noDataValue = std::numeric_limits<double>::quiet_NaN();
|
double noDataValue = noDataValueForGrassType( wr_type );
|
||||||
switch ( wr_type )
|
|
||||||
{
|
|
||||||
case CELL_TYPE:
|
|
||||||
noDataValue = -1 * std::numeric_limits<int>::max();
|
|
||||||
break;
|
|
||||||
case FCELL_TYPE:
|
|
||||||
noDataValue = std::numeric_limits<float>::quiet_NaN();
|
|
||||||
break;
|
|
||||||
case DCELL_TYPE:
|
|
||||||
noDataValue = std::numeric_limits<double>::quiet_NaN();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
QgsDebugMsg( QString( "noDataValue = %1" ).arg(( int )noDataValue ) );
|
QgsDebugMsg( QString( "noDataValue = %1" ).arg(( int )noDataValue ) );
|
||||||
raster.provider->setNoDataValue( raster.band, noDataValue );
|
raster.provider->setNoDataValue( raster.band, noDataValue );
|
||||||
|
|
||||||
@ -1286,6 +1272,26 @@ RASTER_MAP_TYPE QgsGrassGisLib::grassRasterType( QGis::DataType qgisType )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double QgsGrassGisLib::noDataValueForGrassType( RASTER_MAP_TYPE grassType )
|
||||||
|
{
|
||||||
|
double noDataValue = std::numeric_limits<double>::quiet_NaN();
|
||||||
|
switch ( grassType )
|
||||||
|
{
|
||||||
|
case CELL_TYPE:
|
||||||
|
noDataValue = -1 * std::numeric_limits<int>::max();
|
||||||
|
break;
|
||||||
|
case FCELL_TYPE:
|
||||||
|
noDataValue = std::numeric_limits<float>::quiet_NaN();
|
||||||
|
break;
|
||||||
|
case DCELL_TYPE:
|
||||||
|
noDataValue = std::numeric_limits<double>::quiet_NaN();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return noDataValue;
|
||||||
|
}
|
||||||
|
|
||||||
typedef int G_vasprintf_type( char **, const char *, va_list );
|
typedef int G_vasprintf_type( char **, const char *, va_list );
|
||||||
int G_vasprintf( char **out, const char *fmt, va_list ap )
|
int G_vasprintf( char **out, const char *fmt, va_list ap )
|
||||||
{
|
{
|
||||||
|
@ -107,6 +107,9 @@ class GRASS_LIB_EXPORT QgsGrassGisLib
|
|||||||
/** Get GRASS raster type for QGIS raster type */
|
/** Get GRASS raster type for QGIS raster type */
|
||||||
RASTER_MAP_TYPE grassRasterType( QGis::DataType qgisType );
|
RASTER_MAP_TYPE grassRasterType( QGis::DataType qgisType );
|
||||||
|
|
||||||
|
/** Get no data value for GRASS data type */
|
||||||
|
double noDataValueForGrassType( RASTER_MAP_TYPE grassType );
|
||||||
|
|
||||||
/** Grass does not seem to have any function to init Cell_head,
|
/** Grass does not seem to have any function to init Cell_head,
|
||||||
* initialisation is done in G__read_Cell_head_array */
|
* initialisation is done in G__read_Cell_head_array */
|
||||||
void initCellHead( struct Cell_head *cellhd );
|
void initCellHead( struct Cell_head *cellhd );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user