@@ -71,6 +71,8 @@ static QString WCS_DESCRIPTION = "OGC Web Coverage Service version 1.0/1.1 data
71
71
72
72
static QString DEFAULT_LATLON_CRS = " CRS:84" ;
73
73
74
+ // TODO: colortable - use comon baseclass with gdal, mapserver does not support http://trac.osgeo.org/mapserver/ticket/1671
75
+
74
76
QgsWcsProvider::QgsWcsProvider ( QString const &uri )
75
77
: QgsRasterDataProvider( uri )
76
78
, mHttpUri( QString::null )
@@ -88,6 +90,8 @@ QgsWcsProvider::QgsWcsProvider( QString const &uri )
88
90
, mCachedMemFile( 0 )
89
91
, mWidth( 0 )
90
92
, mHeight( 0 )
93
+ , mXBlockSize( 0 )
94
+ , mYBlockSize( 0 )
91
95
, mHasSize( false )
92
96
, mBandCount( 0 )
93
97
{
@@ -174,6 +178,12 @@ QgsWcsProvider::QgsWcsProvider( QString const &uri )
174
178
mSrcGdalDataType .append ( myGdalDataType );
175
179
// TODO: This could be shared with GDAL provider
176
180
int isValid = false ;
181
+
182
+ // UMN Mapserver does not automaticaly set null value, METADATA wcs_rangeset_nullvalue must be used
183
+ // http://lists.osgeo.org/pipermail/mapserver-users/2010-April/065328.html
184
+
185
+ // TODO:
186
+
177
187
double myNoDataValue = GDALGetRasterNoDataValue ( gdalBand, &isValid );
178
188
if ( isValid )
179
189
{
@@ -216,6 +226,7 @@ QgsWcsProvider::QgsWcsProvider( QString const &uri )
216
226
}
217
227
}
218
228
mNoDataValue .append ( myNoDataValue );
229
+ mValidNoDataValue = true ;
219
230
220
231
QgsDebugMsg ( QString ( " mSrcGdalDataType[%1] = %2" ).arg ( i - 1 ).arg ( mSrcGdalDataType [i-1 ] ) );
221
232
QgsDebugMsg ( QString ( " mGdalDataType[%1] = %2" ).arg ( i - 1 ).arg ( mGdalDataType [i-1 ] ) );
@@ -224,6 +235,18 @@ QgsWcsProvider::QgsWcsProvider( QString const &uri )
224
235
225
236
clearCache ();
226
237
238
+ // Block size is used for for statistics
239
+ // TODO: How to find maximum block size supported by server?
240
+ if ( mHasSize )
241
+ {
242
+ // This is taken from GDAL, how they come to these numbers?
243
+ if ( mWidth > 1800 ) mXBlockSize = 1024 ;
244
+ else mXBlockSize = mWidth ;
245
+
246
+ if ( mHeight > 900 ) mYBlockSize = 512 ;
247
+ else mYBlockSize = mHeight ;
248
+ }
249
+
227
250
mValid = true ;
228
251
QgsDebugMsg ( " Constructed ok, provider valid." );
229
252
}
@@ -491,6 +514,32 @@ void QgsWcsProvider::getCache( int bandNo, QgsRectangle const & viewExtent, int
491
514
492
515
}
493
516
517
+ // For stats only, maybe change QgsRasterDataProvider::bandStatistics() to
518
+ // use standard readBlock with extent
519
+ void QgsWcsProvider::readBlock ( int theBandNo, int xBlock, int yBlock, void *block )
520
+ {
521
+ QgsDebugMsg ( " Entered" );
522
+
523
+ QgsDebugMsg ( QString ( " xBlock = %1 yBlock = %2" ).arg ( xBlock ).arg ( yBlock ) );
524
+
525
+ if ( !mHasSize ) return ;
526
+
527
+ double xRes = mCoverageExtent .width () / mWidth ;
528
+ double yRes = mCoverageExtent .height () / mHeight ;
529
+
530
+ // blocks on edges may run out of extent, that should not be problem (at least for
531
+ // stats - there is a check for it)
532
+ double xMin = mCoverageExtent .xMinimum () + xRes * xBlock * mXBlockSize ;
533
+ double xMax = xMin + xRes * mXBlockSize ;
534
+ double yMax = mCoverageExtent .yMaximum () - yRes * yBlock * mYBlockSize ;
535
+ double yMin = yMax - yRes * mYBlockSize ;
536
+ // QgsDebugMsg( QString("yMin = %1 yMax = %2").arg(yMin).arg(yMax) );
537
+
538
+ QgsRectangle extent ( xMin, yMin, xMax, yMax );
539
+
540
+ readBlock ( theBandNo, extent, mXBlockSize , mYBlockSize , block );
541
+ }
542
+
494
543
void QgsWcsProvider::cacheReplyFinished ()
495
544
{
496
545
if ( mCacheReply ->error () == QNetworkReply::NoError )
@@ -685,6 +734,29 @@ int QgsWcsProvider::bandCount() const
685
734
return mBandCount ;
686
735
}
687
736
737
+ double QgsWcsProvider::noDataValue () const
738
+ {
739
+ if ( mNoDataValue .size () > 0 )
740
+ {
741
+ return mNoDataValue [0 ];
742
+ }
743
+ return std::numeric_limits<int >::max (); // should not happen or be used
744
+ }
745
+
746
+ // this is only called once when statistics are calculated
747
+ // TODO
748
+ int QgsWcsProvider::xBlockSize () const
749
+ {
750
+ return mXBlockSize ;
751
+ }
752
+ int QgsWcsProvider::yBlockSize () const
753
+ {
754
+ return mYBlockSize ;
755
+ }
756
+
757
+ int QgsWcsProvider::xSize () const { return mWidth ; }
758
+ int QgsWcsProvider::ySize () const { return mHeight ; }
759
+
688
760
void QgsWcsProvider::clearCache ()
689
761
{
690
762
QgsDebugMsg ( " Entered" );
0 commit comments