Skip to content
Permalink
Browse files
WCS - better versions and CRS
  • Loading branch information
blazek committed Apr 26, 2012
1 parent 866fa9c commit dce6b6c6791b7ec0be4c85974a024c03d2aa9fc2
@@ -56,7 +56,7 @@

QgsOWSSourceSelect::QgsOWSSourceSelect( QString service, QWidget * parent, Qt::WFlags fl, bool managerMode, bool embeddedMode )
: QDialog( parent, fl )
, mService ( service )
, mService( service )
, mManagerMode( managerMode )
, mEmbeddedMode( embeddedMode )
, mCurrentTileset( 0 )
@@ -122,7 +122,7 @@ QgsOWSSourceSelect::~QgsOWSSourceSelect()

void QgsOWSSourceSelect::populateFormats()
{
QgsDebugMsg ( "entered");
QgsDebugMsg( "entered" );
if ( mProviderFormats.size() == 0 )
{
QHBoxLayout *layout = new QHBoxLayout;
@@ -165,9 +165,9 @@ void QgsOWSSourceSelect::populateFormats()
if ( firstVisible == -1 ) firstVisible = id;
}
// Set first if no one visible is checked
if ( mImageFormatGroup->checkedId() < 0 || ( !mImageFormatGroup->button( mImageFormatGroup->checkedId() )->isVisible() && firstVisible > -1 ) )
if ( mImageFormatGroup->checkedId() < 0 || ( !mImageFormatGroup->button( mImageFormatGroup->checkedId() )->isVisible() && firstVisible > -1 ) )
{
mImageFormatGroup->button( firstVisible )->setChecked(true);
mImageFormatGroup->button( firstVisible )->setChecked( true );
}

mImageFormatsGroupBox->setEnabled( true );
@@ -176,7 +176,7 @@ void QgsOWSSourceSelect::populateFormats()
void QgsOWSSourceSelect::populateConnectionList()
{
mConnectionsComboBox->clear();
mConnectionsComboBox->addItems( QgsOWSConnection::connectionList(mService) );
mConnectionsComboBox->addItems( QgsOWSConnection::connectionList( mService ) );

setConnectionListPosition();

@@ -264,13 +264,13 @@ QgsNumericSortTreeWidgetItem *QgsOWSSourceSelect::createItem(
const QMap<int, int> &layerParents,
const QMap<int, QStringList> &layerParentNames )
{
QgsDebugMsg( QString( "id = %1 layerAndStyleCount = %2 names = %3 ").arg( id).arg(layerAndStyleCount).arg(names.join(",") ) );
QgsDebugMsg( QString( "id = %1 layerAndStyleCount = %2 names = %3 " ).arg( id ).arg( layerAndStyleCount ).arg( names.join( "," ) ) );
if ( items.contains( id ) )
return items[id];


QgsNumericSortTreeWidgetItem *item;
if ( layerParents.contains( id ) )
if ( layerParents.contains( id ) )
{
// it has parent -> create first its parent
int parent = layerParents[ id ];
@@ -314,7 +314,7 @@ void QgsOWSSourceSelect::on_mConnectButton_clicked()

void QgsOWSSourceSelect::addClicked()
{
QgsDebugMsg( "entered");
QgsDebugMsg( "entered" );
}

void QgsOWSSourceSelect::enableLayersForCrs( QTreeWidgetItem *item )
@@ -393,16 +393,15 @@ void QgsOWSSourceSelect::populateCRS()
{
// not found
mSelectedCRS = defaultCRS;
mSelectedCRSLabel->setText( descriptionForAuthId( mSelectedCRS ) );
}

mSelectedCRSLabel->setText( descriptionForAuthId( mSelectedCRS ) );
}
else
{
mSelectedCRS = "";
mSelectedCRSLabel->setText( "" );
}
mChangeCRSButton->setEnabled( !mSelectedLayersCRSs.isEmpty() );
mChangeCRSButton->setEnabled( !mSelectedLayersCRSs.isEmpty() );
}

void QgsOWSSourceSelect::on_mTilesetsTableWidget_itemClicked( QTableWidgetItem *item )
@@ -498,7 +497,7 @@ void QgsOWSSourceSelect::showError( QString const &theTitle, QString const &theF
}
else
{
mv->setMessageAsPlainText( tr( "Could not understand the response:\n%1" ).arg( theError) );
mv->setMessageAsPlainText( tr( "Could not understand the response:\n%1" ).arg( theError ) );
}
mv->showMessage( true ); // Is deleted when closed
}
@@ -717,9 +716,9 @@ void QgsOWSSourceSelect::on_mLayerDownButton_clicked()
selectedItem->setSelected( true );
}

QList<QgsOWSSupportedFormat> QgsOWSSourceSelect::providerFormats()
{
return QList<QgsOWSSupportedFormat>();
QList<QgsOWSSupportedFormat> QgsOWSSourceSelect::providerFormats()
{
return QList<QgsOWSSupportedFormat>();
}

QStringList QgsOWSSourceSelect::selectedLayersFormats()
@@ -110,27 +110,49 @@ QgsGdalProvider::QgsGdalProvider( QString const & uri )

// The uri is either a file name or encoded parameters for WCS
QString gdalUri = uri;
if ( uri.contains("url=") && uri.contains("identifier=") && !QFile::exists(uri) )
{
// WCS
// GDAL currently (4/2012) supports WCS 1.0.0 (default) and 1.1.0
if ( uri.contains( "url=" ) && uri.contains( "identifier=" ) && !QFile::exists( uri ) )
{
// - GDAL currently (4/2012) supports WCS 1.0.0 (default) and 1.1.0
// We cannot use 1.1.0 because of wrong longlat bbox send by GDAL
// and impossibility to set GridOffsets.

// - WCS 1.0.0 does not work with GDAL r24316 2012-04-25 + Mapserver 6.0.2 with
// geographic CRS
// GDAL sends BOUNDINGBOX=min_long,min_lat,max_lon,max_lat,urn:ogc:def:crs:EPSG::4326
// Mapserver works with min_lat,min_long,max_lon,max_lat
// OGC 07-067r5 (WCS 1.1.2) referes to OGC 06-121r3 which says:
// "The number of axes included, and the order of these axes, shall be as
// specified by the referenced CRS."
// EPSG defines for EPSG:4326 Axes: latitude, longitude
// (don't confuse with OGC:CRS84 with lon,lat order)
//

QgsDataSourceURI dsUri;
dsUri.setEncodedUri( uri );
gdalUri = "<WCS_GDAL>";
gdalUri += "<Version>1.0.0</Version>";
// prepareUri adds ? or & if necessary, GDAL fails otherwise
gdalUri += "<ServiceURL>" + Qt::escape( QgsWcsCapabilities::prepareUri( dsUri.param("url") ) ) + "</ServiceURL>";
gdalUri += "<CoverageName>" + dsUri.param("identifier") + "</CoverageName>";
gdalUri += "<PreferredFormat>" + dsUri.param("format") + "</PreferredFormat>";

// TODO: There is no tag for CRS response.
// There is undocumented CRS tag, but it only overrides CRS param in requests
// but BBOX is left unchanged and thus results in server error (usually).
gdalUri += "<GetCoverageExtra>&amp;RESPONSE_CRS=" + dsUri.param("crs") + "</GetCoverageExtra>";

if ( dsUri.hasParam("username") && dsUri.hasParam("password") )
gdalUri += "<ServiceURL>" + Qt::escape( QgsWcsCapabilities::prepareUri( dsUri.param( "url" ) ) ) + "</ServiceURL>";
gdalUri += "<CoverageName>" + dsUri.param( "identifier" ) + "</CoverageName>";
gdalUri += "<PreferredFormat>" + dsUri.param( "format" ) + "</PreferredFormat>";

// - CRS : there is undocumented GDAL CRS tag, but it only overrides CRS param
// in requests but the BBOX is left unchanged and thus results in server error (usually).
// 1.0 : RESPONSE_CRS
if ( dsUri.hasParam( "crs" ) )
{
gdalUri += "<GetCoverageExtra>&amp;RESPONSE_CRS=" + dsUri.param( "crs" ) + "</GetCoverageExtra>";
}
// 1.1 : Required parameters are: GridBaseCRS and GridOffsets (resolution)
// We dont have the GridOffsets here and it should be probably dynamic
// according to requested data (zoom).
// Mapserver 6.0.2 works without the GridOffsets, but other servers may not.
//QString crsUrn = "urn:ogc:def:crs:" + dsUri.param("crs").replace(":","::");
//gdalUri += "<GetCoverageExtra>&amp;GridBaseCRS=" + crsUrn + "</GetCoverageExtra>";

if ( dsUri.hasParam( "username" ) && dsUri.hasParam( "password" ) )
{
gdalUri += "<UserPwd>" + dsUri.param("username") + ":" + dsUri.param("password") + "</UserPwd>";
gdalUri += "<UserPwd>" + dsUri.param( "username" ) + ":" + dsUri.param( "password" ) + "</UserPwd>";
}
gdalUri += "</WCS_GDAL>";
QgsDebugMsg( "WCS uri: " + gdalUri );
Loading

0 comments on commit dce6b6c

Please sign in to comment.