Skip to content
Permalink
Browse files

prepare for GRASS raster provider

git-svn-id: http://svn.osgeo.org/qgis/trunk@12879 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
rblazek
rblazek committed Feb 4, 2010
1 parent 2034de2 commit 9f6a28686ffff31a52126af0e52d0ecbc73e8c32
Showing with 33 additions and 57 deletions.
  1. +7 −0 src/core/qgsrasterdataprovider.cpp
  2. +3 −0 src/core/qgsrasterdataprovider.h
  3. +23 −57 src/core/raster/qgsrasterlayer.cpp
@@ -19,6 +19,8 @@
#include "qgsrasterdataprovider.h"
#include "qgslogger.h"

#include <QMap>

QgsRasterDataProvider::QgsRasterDataProvider(): mDpi( -1 )
{
}
@@ -45,5 +47,10 @@ QString QgsRasterDataProvider::capabilitiesString() const
return abilitiesList.join( ", " );
}

bool QgsRasterDataProvider::identify( const QgsPoint& thePoint, QMap<QString, QString>& theResults )
{
theResults.clear();
return false;
}

// ENDS
@@ -115,6 +115,9 @@ class CORE_EXPORT QgsRasterDataProvider : public QgsDataProvider
*/
virtual QString metadata() = 0;

/** \brief Identify raster value(s) found on the point position */
virtual bool identify( const QgsPoint & point, QMap<QString, QString>& results );

/**
* \brief Identify details from a server (e.g. WMS) from the last screen update
*
@@ -490,58 +490,6 @@ QDateTime QgsRasterLayer::lastModified( QString const & name )

t = fi.lastModified();

// Check also color table for GRASS
if ( name.contains( "cellhd" ) > 0 )
{ // most probably GRASS
QString dir = fi.path();
QString map = fi.fileName();
fi.setFile( dir + "/../colr/" + map );

if ( fi.exists() )
{
if ( fi.lastModified() > t ) t = fi.lastModified();
}
}

// Check GRASS group members (bands)
if ( name.contains( "group" ) > 0 )
{ // probably GRASS group
fi.setFile( name + "/REF" );

if ( fi.exists() )
{ // most probably GRASS group
QFile f( name + "/REF" );
if ( f.open( QIODevice::ReadOnly ) )
{
QString dir = fi.path() + "/../../../";

char buf[101];
while ( f.readLine( buf, 100 ) != -1 )
{
QString ln = QString( buf );
QStringList sl = ln.trimmed().split( ' ', QString::SkipEmptyParts );
QString map = sl.first();
sl.pop_front();
QString mapset = sl.first();

// header
fi.setFile( dir + mapset + "/cellhd/" + map );
if ( fi.exists() )
{
if ( fi.lastModified() > t ) t = fi.lastModified();
}

// color
fi.setFile( dir + mapset + "/colr/" + map );
if ( fi.exists() )
{
if ( fi.lastModified() > t ) t = fi.lastModified();
}
}
}
}
}

QgsDebugMsg( "last modified = " + t.toString() );

return t;
@@ -1170,6 +1118,9 @@ QgsRasterLayer::RasterPyramidList QgsRasterLayer::buildPyramidList()
int myWidth = mWidth;
int myHeight = mHeight;
int myDivisor = 2;

if ( mDataProvider ) return mPyramidList;

GDALRasterBandH myGDALBand = GDALGetRasterBand( mGdalDataset, 1 ); //just use the first band

mPyramidList.clear();
@@ -1928,6 +1879,12 @@ bool QgsRasterLayer::identify( const QgsPoint& thePoint, QMap<QString, QString>&

QgsDebugMsg( thePoint.toString() );

if ( !mProviderKey.isEmpty() )
{
QgsDebugMsg( "identify provider : " + mProviderKey ) ;
return ( mDataProvider->identify( thePoint, theResults ) );
}

if ( !mLayerExtent.contains( thePoint ) )
{
// Outside the raster
@@ -3270,8 +3227,15 @@ void QgsRasterLayer::setDataProvider( QString const & provider,
mDrawingStyle = MultiBandColor; //sensible default

// Setup source CRS
*mCRS = QgsCoordinateReferenceSystem();
mCRS->createFromOgcWmsCrs( crs );
if ( mProviderKey == "wms" )
{
*mCRS = QgsCoordinateReferenceSystem();
mCRS->createFromOgcWmsCrs( crs );
}
else
{
*mCRS = QgsCoordinateReferenceSystem( mDataProvider->crs() );
}
}
}
else
@@ -5453,9 +5417,11 @@ bool QgsRasterLayer::update()

if ( mLastModified < QgsRasterLayer::lastModified( source() ) )
{
QgsDebugMsg( "Outdated -> reload" );
closeDataset();
return readFile( source() );
if ( !usesProvider() ) {
QgsDebugMsg( "Outdated -> reload" );
closeDataset();
return readFile( source() );
}
}
return true;
}

0 comments on commit 9f6a286

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