Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
WCS native
  • Loading branch information
blazek committed Aug 7, 2012
2 parents 829f672 + 0fc62dd commit b6c7804
Show file tree
Hide file tree
Showing 46 changed files with 4,386 additions and 1,021 deletions.
2 changes: 1 addition & 1 deletion src/app/qgisapp.cpp
Expand Up @@ -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." ) );
Expand Down
3 changes: 3 additions & 0 deletions src/app/qgsrasterlayerproperties.cpp
Expand Up @@ -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 );
}
Expand Down
5 changes: 5 additions & 0 deletions src/core/qgsdatasourceuri.cpp
Expand Up @@ -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 );
Expand Down
5 changes: 5 additions & 0 deletions src/core/qgsdatasourceuri.h
Expand Up @@ -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;
Expand Down
16 changes: 11 additions & 5 deletions src/core/qgsrasterdataprovider.cpp
Expand Up @@ -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
}

Expand All @@ -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++ )
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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++ )
Expand Down Expand Up @@ -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
}
Expand All @@ -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 ) );
Expand Down
39 changes: 23 additions & 16 deletions src/gui/qgsnewhttpconnection.cpp
Expand Up @@ -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 );
Expand Down Expand Up @@ -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() );
Expand Down
34 changes: 32 additions & 2 deletions src/gui/qgsowssourceselect.cpp
Expand Up @@ -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" );
Expand Down Expand Up @@ -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 )
{
Expand All @@ -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();
Expand Down Expand Up @@ -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() ) );

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

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

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

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

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

void QgsOWSSourceSelect::updateButtons()
{
}
9 changes: 9 additions & 0 deletions src/gui/qgsowssourceselect.h
Expand Up @@ -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
Expand All @@ -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();

Expand Down Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions src/providers/CMakeLists.txt
Expand Up @@ -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)
Expand Down
6 changes: 1 addition & 5 deletions src/providers/gdal/CMakeLists.txt
@@ -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 (
Expand Down

0 comments on commit b6c7804

Please sign in to comment.