Skip to content
Permalink
Browse files

[GRASS] raster identify: do not start info module until it is used

  • Loading branch information
blazek committed Oct 19, 2015
1 parent 483f3ee commit 75c7bfe0fe6333371c83e174eba7641cf68d1383
Showing with 25 additions and 12 deletions.
  1. +22 −11 src/providers/grass/qgsgrassrasterprovider.cpp
  2. +3 −1 src/providers/grass/qgsgrassrasterprovider.h
@@ -90,7 +90,7 @@ QgsGrassRasterProvider::QgsGrassRasterProvider( QString const & uri )

mTimestamp = dataTimestamp();

mRasterValue.start( mGisdbase, mLocation, mMapset, mMapName );
mRasterValue.set( mGisdbase, mLocation, mMapset, mMapName );
//mValidNoDataValue = true;

QString error;
@@ -651,13 +651,13 @@ void QgsGrassRasterProvider::freeze()
void QgsGrassRasterProvider::thaw()
{
QgsDebugMsg( "entered" );
mRasterValue.start( mGisdbase, mLocation, mMapset, mMapName );
mValid = true;
}

//-------------------------------- QgsGrassRasterValue ----------------------------------------

QgsGrassRasterValue::QgsGrassRasterValue() : mProcess( 0 )
QgsGrassRasterValue::QgsGrassRasterValue()
: mProcess( 0 )
{
}

@@ -666,18 +666,21 @@ QgsGrassRasterValue::~QgsGrassRasterValue()
stop();
}

void QgsGrassRasterValue::start( QString gisdbase, QString location,
QString mapset, QString map )
void QgsGrassRasterValue::set( const QString & gisdbase, const QString & location, const QString & mapset, const QString & map )
{
QgsDebugMsg( "entered" );
if ( mProcess )
{
QgsDebugMsg( "alread running" );
}
mGisdbase = gisdbase;
mLocation = location;
mMapset = mapset;
mMapName = map;
}

void QgsGrassRasterValue::start()
{
QgsDebugMsg( "entered" );
if ( mProcess )
{
QgsDebugMsg( "already running" );
}
// TODO: catch exceptions
QString module = QgsGrass::qgisGrassModulePath() + "/qgis.g.info";
QStringList arguments;
@@ -715,7 +718,15 @@ double QgsGrassRasterValue::value( double x, double y, bool *ok )
*ok = false;
double value = std::numeric_limits<double>::quiet_NaN();

if ( !mProcess ) return value;
if ( !mProcess )
{
start();
}

if ( !mProcess )
{
return value;
}

QString coor = QString( "%1 %2\n" ).arg( QgsRasterBlock::printValue( x ),
QgsRasterBlock::printValue( y ) );
@@ -56,12 +56,14 @@ class GRASS_LIB_EXPORT QgsGrassRasterValue
public:
QgsGrassRasterValue();
~QgsGrassRasterValue();
void start( QString gisdbase, QString location, QString mapset, QString map );

void set( const QString & gisdbase, const QString & location, const QString & mapset, const QString & map );
void stop();
// returns raster value, NaN for no data
// ok is set to true if ok or false on error
double value( double x, double y, bool *ok );
private:
void start();
QString mGisdbase; // map gisdabase
QString mLocation; // map location name (not path!)
QString mMapset; // map mapset

0 comments on commit 75c7bfe

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