-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
413 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -209,3 +209,4 @@ double QgsRasterInterface::time( bool cumulative ) | |
} | ||
return t; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/*************************************************************************** | ||
qgsrasternuller.cpp | ||
--------------------- | ||
begin : August 2012 | ||
copyright : (C) 2012 by Radim Blazek | ||
email : radim dot blazek at gmail dot com | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "qgsrasterdataprovider.h" | ||
#include "qgsrasternuller.h" | ||
|
||
QgsRasterNuller::QgsRasterNuller( QgsRasterInterface* input ) | ||
: QgsRasterInterface( input ) | ||
{ | ||
} | ||
|
||
QgsRasterNuller::~QgsRasterNuller() | ||
{ | ||
} | ||
|
||
QgsRasterInterface * QgsRasterNuller::clone() const | ||
{ | ||
QgsDebugMsg( "Entered" ); | ||
QgsRasterNuller * nuller = new QgsRasterNuller( 0 ); | ||
nuller->mNoData = mNoData; | ||
return nuller; | ||
} | ||
|
||
int QgsRasterNuller::bandCount() const | ||
{ | ||
if ( mInput ) return mInput->bandCount(); | ||
return 0; | ||
} | ||
|
||
QgsRasterInterface::DataType QgsRasterNuller::dataType( int bandNo ) const | ||
{ | ||
if ( mInput ) return mInput->dataType( bandNo ); | ||
return QgsRasterInterface::UnknownDataType; | ||
} | ||
|
||
void * QgsRasterNuller::readBlock( int bandNo, QgsRectangle const & extent, int width, int height ) | ||
{ | ||
QgsDebugMsg( "Entered" ); | ||
if ( !mInput ) return 0; | ||
|
||
//QgsRasterDataProvider *provider = dynamic_cast<QgsRasterDataProvider*>( mInput->srcInput() ); | ||
|
||
void * rasterData = mInput->block( bandNo, extent, width, height ); | ||
|
||
QgsRasterInterface::DataType dataType = mInput->dataType( bandNo ); | ||
int pixelSize = mInput->typeSize( dataType ) / 8; | ||
|
||
double noDataValue = mInput->noDataValue ( bandNo ); | ||
|
||
for ( int i = 0; i < height; ++i ) | ||
{ | ||
for ( int j = 0; j < width; ++j ) | ||
{ | ||
int index = pixelSize * ( i * width + j ); | ||
|
||
double value = readValue( rasterData, dataType, index ); | ||
|
||
foreach ( NoData noData, mNoData ) | ||
{ | ||
if ( ( value >= noData.min && value <= noData.max ) || | ||
doubleNear( value, noData.min ) || | ||
doubleNear( value, noData.max ) ) | ||
{ | ||
writeValue( rasterData, dataType, index, noDataValue ); | ||
} | ||
} | ||
} | ||
} | ||
|
||
return rasterData; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/*************************************************************************** | ||
qgsrasternuller.h | ||
------------------- | ||
begin : August 2012 | ||
copyright : (C) 2012 by Radim Blazek | ||
email : radim dot blazek at gmail dot com | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#ifndef QGSRASTERNULLER_H | ||
#define QGSRASTERNULLER_H | ||
|
||
#include "qgsrasterdataprovider.h" | ||
#include "qgsrasterinterface.h" | ||
|
||
#include <QList> | ||
|
||
class CORE_EXPORT QgsRasterNuller : public QgsRasterInterface | ||
{ | ||
public: | ||
QgsRasterNuller( QgsRasterInterface* input = 0 ); | ||
~QgsRasterNuller(); | ||
|
||
struct NoData | ||
{ | ||
double min; | ||
double max; | ||
}; | ||
|
||
QgsRasterInterface * clone() const; | ||
|
||
int bandCount() const; | ||
|
||
QgsRasterInterface::DataType dataType( int bandNo ) const; | ||
|
||
void * readBlock( int bandNo, QgsRectangle const & extent, int width, int height ); | ||
|
||
void setNoData( QList<QgsRasterNuller::NoData> noData ) { mNoData = noData; } | ||
|
||
private: | ||
QList<QgsRasterNuller::NoData> mNoData; | ||
}; | ||
|
||
#endif // QGSRASTERNULLER_H |
Oops, something went wrong.