Skip to content

Commit

Permalink
wms provider fixes:
Browse files Browse the repository at this point in the history
- use smooth transformation when rescaling tiles
- use ows:BoundingBox to retrieve WMTS extents if no ows:WGS84BoundingBox was
  given
- handle empty WMTS dimensions
  • Loading branch information
jef-n committed Apr 13, 2013
1 parent b65c463 commit 938da18
Showing 1 changed file with 43 additions and 8 deletions.
51 changes: 43 additions & 8 deletions src/providers/wms/qgswmsprovider.cpp
Expand Up @@ -1182,6 +1182,7 @@ void QgsWmsProvider::tileReplyFinished()
if ( !myLocalImage.isNull() )
{
QPainter p( mCachedImage );
p.setRenderHint( QPainter::SmoothPixmapTransform, true );
p.drawImage( dst, myLocalImage );
#if 0
myLocalImage.save( QString( "%1/%2-tile-%3.png" ).arg( QDir::tempPath() ).arg( mTileReqNo ).arg( tileNo ) );
Expand Down Expand Up @@ -2753,22 +2754,53 @@ void QgsWmsProvider::parseWMTSContents( QDomElement const &e )
l.abstract = e0.firstChildElement( "ows:Abstract" ).text();
parseKeywords( e0, l.keywords );

l.boundingBox.crs = "";

QDomElement bbox = e0.firstChildElement( "ows:WGS84BoundingBox" );
QStringList ll = bbox.firstChildElement( "ows:LowerCorner" ).text().split( " " );
QStringList ur = bbox.firstChildElement( "ows:UpperCorner" ).text().split( " " );
if ( !bbox.isNull() )
{
QStringList ll = bbox.firstChildElement( "ows:LowerCorner" ).text().split( " " );
QStringList ur = bbox.firstChildElement( "ows:UpperCorner" ).text().split( " " );

if ( ll.size() == 2 && ur.size() == 2 )
{
l.boundingBox.box = QgsRectangle( QgsPoint( ll[0].toDouble(), ll[1].toDouble() ),
QgsPoint( ur[0].toDouble(), ur[1].toDouble() ) );
l.boundingBox.crs = DEFAULT_LATLON_CRS;
}
}

if ( ll.size() == 2 && ur.size() == 2 )
if ( l.boundingBox.crs.isEmpty() )
{
l.boundingBox.box = QgsRectangle( QgsPoint( ll[0].toDouble(), ll[1].toDouble() ),
QgsPoint( ur[0].toDouble(), ur[1].toDouble() ) );
bbox = e0.firstChildElement( "ows:BoundingBox" );
if ( !bbox.isNull() )
{
QStringList ll = bbox.firstChildElement( "ows:LowerCorner" ).text().split( " " );
QStringList ur = bbox.firstChildElement( "ows:UpperCorner" ).text().split( " " );

if ( ll.size() == 2 && ur.size() == 2 )
{
l.boundingBox.box = QgsRectangle( QgsPoint( ll[0].toDouble(), ll[1].toDouble() ),
QgsPoint( ur[0].toDouble(), ur[1].toDouble() ) );

if ( bbox.hasAttribute( "SRS" ) )
l.boundingBox.crs = bbox.attribute( "SRS" );
else if ( bbox.hasAttribute( "srs" ) )
l.boundingBox.crs = bbox.attribute( "srs" );
else if ( bbox.hasAttribute( "CRS" ) )
l.boundingBox.crs = bbox.attribute( "CRS" );
else if ( bbox.hasAttribute( "crs" ) )
l.boundingBox.crs = bbox.attribute( "crs" );
}
}
}
else

if ( l.boundingBox.crs.isEmpty() )
{
l.boundingBox.box = QgsRectangle( -180.0, -90.0, 180.0, 90.0 );
l.boundingBox.crs = DEFAULT_LATLON_CRS;
}

l.boundingBox.crs = DEFAULT_LATLON_CRS;

for ( QDomElement e1 = e0.firstChildElement( "Style" );
!e1.isNull();
e1 = e1.nextSiblingElement( "Style" ) )
Expand Down Expand Up @@ -2818,6 +2850,9 @@ void QgsWmsProvider::parseWMTSContents( QDomElement const &e )
QgsWmtsDimension d;

d.identifier = e1.firstChildElement( "ows:Identifier" ).text();
if ( d.identifier.isEmpty() )
continue;

d.title = e1.firstChildElement( "ows:Title" ).text();
d.abstract = e1.firstChildElement( "ows:Abstract" ).text();
parseKeywords( e1, d.keywords );
Expand Down

0 comments on commit 938da18

Please sign in to comment.