Skip to content

Commit 9f6a286

Browse files
author
rblazek
committed
prepare for GRASS raster provider
git-svn-id: http://svn.osgeo.org/qgis/trunk@12879 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 2034de2 commit 9f6a286

File tree

3 files changed

+33
-57
lines changed

3 files changed

+33
-57
lines changed

src/core/qgsrasterdataprovider.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#include "qgsrasterdataprovider.h"
2020
#include "qgslogger.h"
2121

22+
#include <QMap>
23+
2224
QgsRasterDataProvider::QgsRasterDataProvider(): mDpi( -1 )
2325
{
2426
}
@@ -45,5 +47,10 @@ QString QgsRasterDataProvider::capabilitiesString() const
4547
return abilitiesList.join( ", " );
4648
}
4749

50+
bool QgsRasterDataProvider::identify( const QgsPoint& thePoint, QMap<QString, QString>& theResults )
51+
{
52+
theResults.clear();
53+
return false;
54+
}
4855

4956
// ENDS

src/core/qgsrasterdataprovider.h

+3
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ class CORE_EXPORT QgsRasterDataProvider : public QgsDataProvider
115115
*/
116116
virtual QString metadata() = 0;
117117

118+
/** \brief Identify raster value(s) found on the point position */
119+
virtual bool identify( const QgsPoint & point, QMap<QString, QString>& results );
120+
118121
/**
119122
* \brief Identify details from a server (e.g. WMS) from the last screen update
120123
*

src/core/raster/qgsrasterlayer.cpp

+23-57
Original file line numberDiff line numberDiff line change
@@ -490,58 +490,6 @@ QDateTime QgsRasterLayer::lastModified( QString const & name )
490490

491491
t = fi.lastModified();
492492

493-
// Check also color table for GRASS
494-
if ( name.contains( "cellhd" ) > 0 )
495-
{ // most probably GRASS
496-
QString dir = fi.path();
497-
QString map = fi.fileName();
498-
fi.setFile( dir + "/../colr/" + map );
499-
500-
if ( fi.exists() )
501-
{
502-
if ( fi.lastModified() > t ) t = fi.lastModified();
503-
}
504-
}
505-
506-
// Check GRASS group members (bands)
507-
if ( name.contains( "group" ) > 0 )
508-
{ // probably GRASS group
509-
fi.setFile( name + "/REF" );
510-
511-
if ( fi.exists() )
512-
{ // most probably GRASS group
513-
QFile f( name + "/REF" );
514-
if ( f.open( QIODevice::ReadOnly ) )
515-
{
516-
QString dir = fi.path() + "/../../../";
517-
518-
char buf[101];
519-
while ( f.readLine( buf, 100 ) != -1 )
520-
{
521-
QString ln = QString( buf );
522-
QStringList sl = ln.trimmed().split( ' ', QString::SkipEmptyParts );
523-
QString map = sl.first();
524-
sl.pop_front();
525-
QString mapset = sl.first();
526-
527-
// header
528-
fi.setFile( dir + mapset + "/cellhd/" + map );
529-
if ( fi.exists() )
530-
{
531-
if ( fi.lastModified() > t ) t = fi.lastModified();
532-
}
533-
534-
// color
535-
fi.setFile( dir + mapset + "/colr/" + map );
536-
if ( fi.exists() )
537-
{
538-
if ( fi.lastModified() > t ) t = fi.lastModified();
539-
}
540-
}
541-
}
542-
}
543-
}
544-
545493
QgsDebugMsg( "last modified = " + t.toString() );
546494

547495
return t;
@@ -1170,6 +1118,9 @@ QgsRasterLayer::RasterPyramidList QgsRasterLayer::buildPyramidList()
11701118
int myWidth = mWidth;
11711119
int myHeight = mHeight;
11721120
int myDivisor = 2;
1121+
1122+
if ( mDataProvider ) return mPyramidList;
1123+
11731124
GDALRasterBandH myGDALBand = GDALGetRasterBand( mGdalDataset, 1 ); //just use the first band
11741125

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

19291880
QgsDebugMsg( thePoint.toString() );
19301881

1882+
if ( !mProviderKey.isEmpty() )
1883+
{
1884+
QgsDebugMsg( "identify provider : " + mProviderKey ) ;
1885+
return ( mDataProvider->identify( thePoint, theResults ) );
1886+
}
1887+
19311888
if ( !mLayerExtent.contains( thePoint ) )
19321889
{
19331890
// Outside the raster
@@ -3270,8 +3227,15 @@ void QgsRasterLayer::setDataProvider( QString const & provider,
32703227
mDrawingStyle = MultiBandColor; //sensible default
32713228

32723229
// Setup source CRS
3273-
*mCRS = QgsCoordinateReferenceSystem();
3274-
mCRS->createFromOgcWmsCrs( crs );
3230+
if ( mProviderKey == "wms" )
3231+
{
3232+
*mCRS = QgsCoordinateReferenceSystem();
3233+
mCRS->createFromOgcWmsCrs( crs );
3234+
}
3235+
else
3236+
{
3237+
*mCRS = QgsCoordinateReferenceSystem( mDataProvider->crs() );
3238+
}
32753239
}
32763240
}
32773241
else
@@ -5453,9 +5417,11 @@ bool QgsRasterLayer::update()
54535417

54545418
if ( mLastModified < QgsRasterLayer::lastModified( source() ) )
54555419
{
5456-
QgsDebugMsg( "Outdated -> reload" );
5457-
closeDataset();
5458-
return readFile( source() );
5420+
if ( !usesProvider() ) {
5421+
QgsDebugMsg( "Outdated -> reload" );
5422+
closeDataset();
5423+
return readFile( source() );
5424+
}
54595425
}
54605426
return true;
54615427
}

0 commit comments

Comments
 (0)