Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
wcs 1.0.0 partialy working
  • Loading branch information
blazek committed Jul 3, 2012
1 parent e8a9314 commit 49ca5f5
Show file tree
Hide file tree
Showing 5 changed files with 412 additions and 79 deletions.
12 changes: 9 additions & 3 deletions src/gui/qgsowssourceselect.cpp
Expand Up @@ -159,7 +159,11 @@ 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, GEOTIFFINT16

// 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,14 +219,16 @@ void QgsOWSSourceSelect::populateFormats()
else
{
QgsDebugMsg( QString( "format %1 not supported." ).arg( format ) );
btn->setEnabled( false );
//btn->setEnabled( false );
btn->setEnabled( true );
tip += " " + tr( "is not supported by GDAL" );
}
btn->setText( label );
btn->setToolTip( tip );
}
// Set prefered
prefered = prefered >= 0 ? prefered : firstEnabled;
// TODO: all enabled for now, see above
//prefered = prefered >= 0 ? prefered : firstEnabled;
if ( prefered >= 0 )
{
mImageFormatGroup->button( prefered )->setChecked( true );
Expand Down
71 changes: 71 additions & 0 deletions src/providers/wcs/qgswcscapabilities.cpp
Expand Up @@ -453,6 +453,43 @@ QString QgsWcsCapabilities::firstChildText( const QDomElement &element, const QS
return QString();
}

QDomElement QgsWcsCapabilities::domElement( const QDomElement &element, const QString & path )
{
QStringList names = path.split( "." );
if ( names.size() == 0 ) return QDomElement();

QDomElement el = firstChild( element, names.value( 0 ) );
if ( names.size() == 1 || el.isNull() )
{
return el;
}
names.removeFirst();
return domElement( el, names.join( "." ) );
}

QString QgsWcsCapabilities::domElementText( const QDomElement &element, const QString & path )
{
QDomElement el = domElement( element, path );
return el.text();
}

QList<int> QgsWcsCapabilities::parseInts( const QString &text )
{
QList<int> list;
foreach( QString s, text.split( " " ) )
{
int i;
bool ok;
list.append( s.toInt( &ok ) );
if ( !ok )
{
list.clear();
return list;
}
}
return list;
}

// ------------------------ 1.0 ----------------------------------------------
void QgsWcsCapabilities::parseService( const QDomElement &e, QgsWcsServiceIdentification &serviceIdentification ) // 1.0
{
Expand Down Expand Up @@ -490,6 +527,9 @@ void QgsWcsCapabilities::parseContentMetadata( QDomElement const & e, QgsWcsCove
QgsWcsCoverageSummary subCoverageSummary;

subCoverageSummary.described = false;
subCoverageSummary.width = 0;
subCoverageSummary.height = 0;
subCoverageSummary.hasSize = false;

parseCoverageOfferingBrief( el, subCoverageSummary, &coverageSummary );

Expand Down Expand Up @@ -655,6 +695,32 @@ bool QgsWcsCapabilities::parseDescribeCoverageDom( QByteArray const &xml, QgsWcs
}
QgsDebugMsg( "supportedFormat = " + coverage->supportedFormat.join( "," ) );

// spatialDomain and Grid/RectifiedGrid are optional according to specificationi.
// If missing, we cannot get native resolution and size.
QDomElement gridElement = domElement( coverageOfferingElement, "domainSet.spatialDomain.Grid" );

if ( gridElement.isNull() )
{
gridElement = domElement( coverageOfferingElement, "domainSet.spatialDomain.RectifiedGrid" );
}

if ( !gridElement.isNull() )
{
QList<int> low = parseInts( domElementText( gridElement, "limits.GridEnvelope.low" ) );
QList<int> high = parseInts( domElementText( gridElement, "limits.GridEnvelope.high" ) );
if ( low.size() == 2 && high.size() == 2 )
{
coverage->width = high[0] - low[0] + 1;
coverage->height = high[1] - low[1] + 1;
coverage->hasSize = true;
}
// RectifiedGrid has also gml:origin which we dont need I think (attention however
// it should contain gml:Point but mapserver 6.0.3 / WCS 1.0.0 is using gml:pos instead)
// RectifiedGrid also contains 2 gml:offsetVector which could be used to get resolution
// but it should be sufficient to calc resolution from size
}
QgsDebugMsg( QString( "width = %1 height = %2" ).arg( coverage->width ).arg( coverage->height ) );

coverage->described = true;

return true;
Expand Down Expand Up @@ -773,6 +839,11 @@ void QgsWcsCapabilities::parseCoverageSummary( QDomElement const & e, QgsWcsCove

QgsWcsCoverageSummary subCoverageSummary;

subCoverageSummary.described = false;
subCoverageSummary.width = 0;
subCoverageSummary.height = 0;
subCoverageSummary.hasSize = false;

// Inherit
subCoverageSummary.supportedCrs = coverageSummary.supportedCrs;
subCoverageSummary.supportedFormat = coverageSummary.supportedFormat;
Expand Down
12 changes: 12 additions & 0 deletions src/providers/wcs/qgswcscapabilities.h
Expand Up @@ -97,6 +97,10 @@ struct QgsWcsCoverageSummary
QgsRectangle wgs84BoundingBox;
QVector<QgsWcsCoverageSummary> coverageSummary;
bool described; // 1.0
// non reflecting directly Capabilities structure:
int width;
int height;
bool hasSize;
};

/** Contents structure */
Expand Down Expand Up @@ -242,6 +246,14 @@ class QgsWcsCapabilities : public QObject
//! Get first child of specified name, NS is ignored
QDomElement firstChild( const QDomElement &element, const QString &name );

/** Find first sub element by path which is string of dot separated tag names.
* NS is ignored. Example path: domainSet.spatialDomain.RectifiedGrid */
QDomElement domElement( const QDomElement &element, const QString &path );

/** Get text of element specified by path */
QString domElementText( const QDomElement &element, const QString &path );

QList<int> parseInts( const QString &text );
/**
* \brief Retrieve and parse the (cached) Capabilities document from the server
*
Expand Down

0 comments on commit 49ca5f5

Please sign in to comment.