Skip to content
Permalink
Browse files

WCS native

  • Loading branch information
blazek committed Aug 7, 2012
2 parents 829f672 + 0fc62dd commit b6c7804a592466dd58931fd5116d8840f380a710
Showing with 4,386 additions and 1,021 deletions.
  1. +1 −1 src/app/qgisapp.cpp
  2. +3 −0 src/app/qgsrasterlayerproperties.cpp
  3. +5 −0 src/core/qgsdatasourceuri.cpp
  4. +5 −0 src/core/qgsdatasourceuri.h
  5. +11 −5 src/core/qgsrasterdataprovider.cpp
  6. +23 −16 src/gui/qgsnewhttpconnection.cpp
  7. +32 −2 src/gui/qgsowssourceselect.cpp
  8. +9 −0 src/gui/qgsowssourceselect.h
  9. +1 −0 src/providers/CMakeLists.txt
  10. +1 −5 src/providers/gdal/CMakeLists.txt
  11. +0 −273 src/providers/gdal/qgsgdaldataitems.cpp
  12. +0 −59 src/providers/gdal/qgsgdaldataitems.h
  13. +8 −203 src/providers/gdal/qgsgdalprovider.cpp
  14. +2 −19 src/providers/gdal/qgsgdalprovider.h
  15. +249 −0 src/providers/gdal/qgsgdalproviderbase.cpp
  16. +59 −0 src/providers/gdal/qgsgdalproviderbase.h
  17. +34 −0 src/providers/wcs/CMakeLists.txt
  18. +43 −0 src/providers/wcs/URI
  19. +464 −206 src/providers/{gdal → wcs}/qgswcscapabilities.cpp
  20. +70 −107 src/providers/{gdal → wcs}/qgswcscapabilities.h
  21. +309 −0 src/providers/wcs/qgswcsdataitems.cpp
  22. +78 −0 src/providers/wcs/qgswcsdataitems.h
  23. +1,573 −0 src/providers/wcs/qgswcsprovider.cpp
  24. +416 −0 src/providers/wcs/qgswcsprovider.h
  25. +39 −15 src/providers/{gdal → wcs}/qgswcssourceselect.cpp
  26. +2 −0 src/providers/{gdal → wcs}/qgswcssourceselect.h
  27. +148 −110 src/ui/qgsowssourceselectbase.ui
  28. +1 −0 tests/src/CMakeLists.txt
  29. +76 −0 tests/src/providers/CMakeLists.txt
  30. +339 −0 tests/src/providers/testqgswcsprovider.cpp
  31. +23 −0 tests/testdata/raster/README.WCS
  32. BIN tests/testdata/raster/band1_byte_ct_epsg4326.tif
  33. +13 −0 tests/testdata/raster/band1_byte_ct_epsg4326.tif.aux.xml
  34. BIN tests/testdata/raster/band1_byte_noct_epsg4326.tif
  35. +13 −0 tests/testdata/raster/band1_byte_noct_epsg4326.tif.aux.xml
  36. BIN tests/testdata/raster/band1_float32_noct_epsg4326.tif
  37. +12 −0 tests/testdata/raster/band1_float32_noct_epsg4326.tif.aux.xml
  38. BIN tests/testdata/raster/band1_int16_noct_epsg4326.tif
  39. +13 −0 tests/testdata/raster/band1_int16_noct_epsg4326.tif.aux.xml
  40. BIN tests/testdata/raster/band3_byte_noct_epsg4326.tif
  41. +35 −0 tests/testdata/raster/band3_byte_noct_epsg4326.tif.aux.xml
  42. BIN tests/testdata/raster/band3_float32_noct_epsg4326.tif
  43. +32 −0 tests/testdata/raster/band3_float32_noct_epsg4326.tif.aux.xml
  44. BIN tests/testdata/raster/band3_int16_noct_epsg4326.tif
  45. +35 −0 tests/testdata/raster/band3_int16_noct_epsg4326.tif.aux.xml
  46. +209 −0 tests/testdata/raster/wcs.map
@@ -2863,7 +2863,7 @@ void QgisApp::addWcsLayer()
QgsDebugMsg( "about to addWcsLayer" );

// TODO: QDialog for now, switch to QWidget in future
QDialog *wcss = dynamic_cast<QDialog*>( QgsProviderRegistry::instance()->selectWidget( QString( "gdal" ), this ) );
QDialog *wcss = dynamic_cast<QDialog*>( QgsProviderRegistry::instance()->selectWidget( QString( "wcs" ), this ) );
if ( !wcss )
{
QMessageBox::warning( this, tr( "WCS" ), tr( "Cannot get WCS select dialog from provider." ) );
@@ -147,7 +147,10 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer* lyr, QgsMapCanv
{
// disable Pyramids tab completely
tabPagePyramids->setEnabled( false );
}

if ( !( provider->capabilities() & QgsRasterDataProvider::Histogram ) )
{
// disable Histogram tab completely
tabPageHistogram->setEnabled( false );
}
@@ -709,6 +709,11 @@ void QgsDataSourceURI::setParam( const QString &key, const QStringList &value )
}
}

int QgsDataSourceURI::removeParam( const QString &key )
{
return mParams.remove( key );
}

QString QgsDataSourceURI::param( const QString &key ) const
{
return mParams.value( key );
@@ -75,6 +75,11 @@ class CORE_EXPORT QgsDataSourceURI
void setParam( const QString &key, const QString &value );
void setParam( const QString &key, const QStringList &value );

//! Remove generic param (generic mode)
// \note remove all occurrences of key, returns number of params removed
// \note added in 1.9
int removeParam( const QString &key );

//! Get generic param (generic mode)
// \note added in 1.9
QString param( const QString &key ) const;
@@ -286,6 +286,7 @@ QgsRasterBandStats QgsRasterDataProvider::bandStatistics( int theBandNo )

if ( xBlockSize() == 0 || yBlockSize() == 0 )
{
QgsDebugMsg( "Cannot collect statistics (raster size or block size) are unknown" );
return QgsRasterBandStats(); //invalid raster band stats
}

@@ -299,6 +300,7 @@ QgsRasterBandStats QgsRasterDataProvider::bandStatistics( int theBandNo )

int myBandXSize = xSize();
int myBandYSize = ySize();
int maxCount = xSize() * ySize();
for ( int iYBlock = 0; iYBlock < myNYBlocks; iYBlock++ )
{
for ( int iXBlock = 0; iXBlock < myNXBlocks; iXBlock++ )
@@ -326,12 +328,15 @@ QgsRasterBandStats QgsRasterDataProvider::bandStatistics( int theBandNo )
double myValue = readValue( myData, myDataType, iX + ( iY * xBlockSize() ) );
//QgsDebugMsg ( QString ( "%1 %2 value %3" ).arg (iX).arg(iY).arg( myValue ) );

if ( mValidNoDataValue && ( qAbs( myValue - myNoDataValue ) <= TINY_VALUE ) )
if ( mValidNoDataValue &&
(( std::isnan( myNoDataValue ) && std::isnan( myValue ) ) || qAbs( myValue - myNoDataValue ) <= TINY_VALUE ) )
{
continue; // NULL
}

myRasterBandStats.sum += myValue;
// sum can easily run out of limits
myRasterBandStats.mean += myValue / maxCount;
++myRasterBandStats.elementCount;
//only use this element if we have a non null element
if ( myFirstIterationFlag )
@@ -362,7 +367,8 @@ QgsRasterBandStats QgsRasterDataProvider::bandStatistics( int theBandNo )
//end of first pass through data now calculate the range
myRasterBandStats.range = myRasterBandStats.maximumValue - myRasterBandStats.minimumValue;
//calculate the mean
myRasterBandStats.mean = myRasterBandStats.sum / myRasterBandStats.elementCount;
//myRasterBandStats.mean = myRasterBandStats.sum / myRasterBandStats.elementCount;
myRasterBandStats.mean = maxCount * ( myRasterBandStats.mean / myRasterBandStats.elementCount );

//for the second pass we will get the sum of the squares / mean
for ( int iYBlock = 0; iYBlock < myNYBlocks; iYBlock++ )
@@ -393,7 +399,8 @@ QgsRasterBandStats QgsRasterDataProvider::bandStatistics( int theBandNo )
double myValue = readValue( myData, myDataType, iX + ( iY * xBlockSize() ) );
//QgsDebugMsg ( "myValue = " + QString::number(myValue) );

if ( mValidNoDataValue && ( qAbs( myValue - myNoDataValue ) <= TINY_VALUE ) )
if ( mValidNoDataValue &&
(( std::isnan( myNoDataValue ) && std::isnan( myValue ) ) || qAbs( myValue - myNoDataValue ) <= TINY_VALUE ) )
{
continue; // NULL
}
@@ -406,8 +413,7 @@ QgsRasterBandStats QgsRasterDataProvider::bandStatistics( int theBandNo )
} //end of row wise loop

//divide result by sample size - 1 and get square root to get stdev
myRasterBandStats.stdDev = static_cast < double >( sqrt( myRasterBandStats.sumOfSquares /
( myRasterBandStats.elementCount - 1 ) ) );
myRasterBandStats.stdDev = static_cast < double >( sqrt( myRasterBandStats.sumOfSquares / ( myRasterBandStats.elementCount - 1 ) ) );

QgsDebugMsg( "************ STATS **************" );
QgsDebugMsg( QString( "VALID NODATA %1" ).arg( mValidNoDataValue ) );
@@ -51,35 +51,39 @@ QgsNewHttpConnection::QgsNewHttpConnection(
txtName->setText( connName );
txtUrl->setText( settings.value( key + "/url" ).toString() );

if ( mBaseKey == "/Qgis/connections-wms/" )
cbxIgnoreGetMapURI->setChecked( settings.value( key + "/ignoreGetMapURI", false ).toBool() );
cbxIgnoreAxisOrientation->setChecked( settings.value( key + "/ignoreAxisOrientation", false ).toBool() );
cbxInvertAxisOrientation->setChecked( settings.value( key + "/invertAxisOrientation", false ).toBool() );
cbxIgnoreGetFeatureInfoURI->setChecked( settings.value( key + "/ignoreGetFeatureInfoURI", false ).toBool() );

txtUserName->setText( settings.value( credentialsKey + "/username" ).toString() );
txtPassword->setText( settings.value( credentialsKey + "/password" ).toString() );
}

if ( mBaseKey != "/Qgis/connections-wms/" )
{
if ( mBaseKey == "/Qgis/connections-wcs/" )
{
cbxIgnoreGetMapURI->setChecked( settings.value( key + "/ignoreGetMapURI", false ).toBool() );
cbxIgnoreGetFeatureInfoURI->setChecked( settings.value( key + "/ignoreGetFeatureInfoURI", false ).toBool() );
cbxIgnoreAxisOrientation->setChecked( settings.value( key + "/ignoreAxisOrientation", false ).toBool() );
cbxInvertAxisOrientation->setChecked( settings.value( key + "/invertAxisOrientation", false ).toBool() );
cbxIgnoreGetMapURI->setText( tr( "Ignore GetCoverage URI reported in capabilities" ) );
cbxIgnoreAxisOrientation->setText( tr( "Ignore axis orientation" ) );
}
else
{
cbxIgnoreGetMapURI->setVisible( false );
cbxIgnoreGetFeatureInfoURI->setVisible( false );
cbxIgnoreAxisOrientation->setVisible( false );
cbxInvertAxisOrientation->setVisible( false );
mGroupBox->layout()->removeWidget( cbxIgnoreGetMapURI );
mGroupBox->layout()->removeWidget( cbxIgnoreAxisOrientation );
mGroupBox->layout()->removeWidget( cbxInvertAxisOrientation );
}

txtUserName->setText( settings.value( credentialsKey + "/username" ).toString() );
txtPassword->setText( settings.value( credentialsKey + "/password" ).toString() );
}
if ( mBaseKey != "/Qgis/connections-wms/" )
{
cbxIgnoreGetMapURI->setVisible( false );
cbxIgnoreGetFeatureInfoURI->setVisible( false );
mGroupBox->layout()->removeWidget( cbxIgnoreGetMapURI );
mGroupBox->layout()->removeWidget( cbxIgnoreGetFeatureInfoURI );

// Adjust height
int w = width();
adjustSize();
resize( w, height() );

}

on_txtName_textChanged( connName );
@@ -143,13 +147,16 @@ void QgsNewHttpConnection::accept()
}

settings.setValue( key + "/url", url.toString() );
if ( mBaseKey == "/Qgis/connections-wms/" )
if ( mBaseKey == "/Qgis/connections-wms/" || mBaseKey == "/Qgis/connections-wcs/" )
{
settings.setValue( key + "/ignoreGetMapURI", cbxIgnoreGetMapURI->isChecked() );
settings.setValue( key + "/ignoreGetFeatureInfoURI", cbxIgnoreGetFeatureInfoURI->isChecked() );
settings.setValue( key + "/ignoreAxisOrientation", cbxIgnoreAxisOrientation->isChecked() );
settings.setValue( key + "/invertAxisOrientation", cbxInvertAxisOrientation->isChecked() );
}
if ( mBaseKey == "/Qgis/connections-wms/" )
{
settings.setValue( key + "/ignoreGetFeatureInfoURI", cbxIgnoreGetFeatureInfoURI->isChecked() );
}

settings.setValue( credentialsKey + "/username", txtUserName->text() );
settings.setValue( credentialsKey + "/password", txtPassword->text() );
@@ -159,7 +159,14 @@ void QgsOWSSourceSelect::populateFormats()

// selectedLayersFormats may come in various forms:
// image/tiff, GTiff, GeoTIFF, TIFF, geotiff_int16, geotiff_rgb,
// PNG, GTOPO30, ARCGRID, IMAGEMOSAIC,
// PNG, GTOPO30, ARCGRID, IMAGEMOSAIC
// and even any string defined in server configuration, for example the
// value used in UMN Mapserver for OUTPUTFORMAT->NAME is used in
// WCS 1.0.0 SupportedFormats/Format

// TODO: It is impossible to cover all possible formats comming from server
// -> enabled all formats, GDAL may be able to open them

QMap<QString, QString> formatsMap;
formatsMap.insert( "geotiff", "tiff" );
formatsMap.insert( "gtiff", "tiff" );
@@ -215,13 +222,16 @@ void QgsOWSSourceSelect::populateFormats()
else
{
QgsDebugMsg( QString( "format %1 not supported." ).arg( format ) );
btn->setEnabled( false );
//btn->setEnabled( false );
btn->setEnabled( true );
if ( firstEnabled < 0 ) { firstEnabled = i; }
tip += " " + tr( "is not supported by GDAL" );
}
btn->setText( label );
btn->setToolTip( tip );
}
// Set prefered
// TODO: all enabled for now, see above
prefered = prefered >= 0 ? prefered : firstEnabled;
if ( prefered >= 0 )
{
@@ -231,6 +241,14 @@ void QgsOWSSourceSelect::populateFormats()
mImageFormatsGroupBox->setEnabled( true );
}

void QgsOWSSourceSelect::populateTimes()
{
QgsDebugMsg( "entered" );
mTimeComboBox->clear();
mTimeComboBox->insertItems( 0, selectedLayersTimes() );
mTimeComboBox->setEnabled( !selectedLayersTimes().isEmpty() );
}

void QgsOWSSourceSelect::populateConnectionList()
{
mConnectionsComboBox->clear();
@@ -426,6 +444,7 @@ void QgsOWSSourceSelect::on_mLayersTreeWidget_itemSelectionChanged()

void QgsOWSSourceSelect::populateCRS()
{
QgsDebugMsg( "Entered" );
mSelectedLayersCRSs = selectedLayersCRSs().toSet();
mCRSGroupBox->setTitle( tr( "Coordinate Reference System (%n available)", "crs count", mSelectedLayersCRSs.count() ) );

@@ -463,6 +482,7 @@ void QgsOWSSourceSelect::populateCRS()
mSelectedCRS = "";
mSelectedCRSLabel->setText( "" );
}
QgsDebugMsg( "mSelectedCRS = " + mSelectedCRS );
mChangeCRSButton->setEnabled( !mSelectedLayersCRSs.isEmpty() );
}

@@ -523,6 +543,11 @@ QString QgsOWSSourceSelect::selectedCRS()
return mSelectedCRS;
}

QString QgsOWSSourceSelect::selectedTime()
{
return mTimeComboBox->currentText();
}

void QgsOWSSourceSelect::setConnectionListPosition()
{
QString toSelect = QgsOWSConnection::selectedConnection( mService );
@@ -793,6 +818,11 @@ QStringList QgsOWSSourceSelect::selectedLayersCRSs()
return QStringList();
}

QStringList QgsOWSSourceSelect::selectedLayersTimes()
{
return QStringList();
}

void QgsOWSSourceSelect::updateButtons()
{
}
@@ -124,6 +124,9 @@ class GUI_EXPORT QgsOWSSourceSelect : public QDialog, public Ui::QgsOWSSourceSel
//! Server CRS supported for currently selected layer item(s)
virtual QStringList selectedLayersCRSs();

//! List of times (temporalDomain timePosition/timePeriod for currently selected layer item(s)
virtual QStringList selectedLayersTimes();

//virtual QStringList layerCRS( int id );

//! Populate the connection list combo box
@@ -138,6 +141,9 @@ class GUI_EXPORT QgsOWSSourceSelect : public QDialog, public Ui::QgsOWSSourceSel
//! Set supported CRSs
void populateCRS();

//! Populate times
void populateTimes();

//! Connection name
QString connName();

@@ -199,6 +205,9 @@ class GUI_EXPORT QgsOWSSourceSelect : public QDialog, public Ui::QgsOWSSourceSel
//! Returns currently selected Crs
QString selectedCRS();

//! Returns currently selected time
QString selectedTime();

QList<QTreeWidgetItem*> mCurrentSelection;
QTableWidgetItem* mCurrentTileset;

@@ -11,6 +11,7 @@ ADD_SUBDIRECTORY(sqlanywhere)
ADD_SUBDIRECTORY(gdal)
ADD_SUBDIRECTORY(mssql)
ADD_SUBDIRECTORY(ows)
ADD_SUBDIRECTORY(wcs)

IF (POSTGRES_FOUND)
ADD_SUBDIRECTORY(postgres)
@@ -1,14 +1,10 @@
SET(GDAL_SRCS
qgsgdalproviderbase.cpp
qgsgdalprovider.cpp
qgsgdaldataitems.cpp
qgswcscapabilities.cpp
qgswcssourceselect.cpp
)
SET(GDAL_MOC_HDRS
qgsgdalprovider.h
qgsgdaldataitems.h
qgswcscapabilities.h
qgswcssourceselect.h
)

INCLUDE_DIRECTORIES (

0 comments on commit b6c7804

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