@@ -103,8 +103,8 @@ bool QgsWmsSettings::parseUri( QString uriString )
103
103
104
104
105
105
QgsWmsCapabilities::QgsWmsCapabilities ()
106
- : mValid( false )
107
- , mLayerCount( -1 )
106
+ : mValid( false )
107
+ , mLayerCount( -1 )
108
108
{
109
109
}
110
110
@@ -591,7 +591,7 @@ void QgsWmsCapabilities::parseCapability( QDomElement const & e, QgsWmsCapabilit
591
591
else if ( name == " GetFeatureInfo" )
592
592
{
593
593
ot = &capabilityProperty.request .getFeatureInfo ;
594
- }
594
+ }
595
595
else if ( name == " GetLegendGraphic" || name == " sld:GetLegendGraphic" )
596
596
{
597
597
ot = &capabilityProperty.request .getLegendGraphic ;
@@ -692,7 +692,7 @@ void QgsWmsCapabilities::parseLegendUrl( QDomElement const & e, QgsWmsLegendUrlP
692
692
}
693
693
694
694
void QgsWmsCapabilities::parseLayer ( QDomElement const & e, QgsWmsLayerProperty& layerProperty,
695
- QgsWmsLayerProperty *parentProperty )
695
+ QgsWmsLayerProperty *parentProperty )
696
696
{
697
697
QgsDebugMsg ( " entering." );
698
698
@@ -732,7 +732,7 @@ void QgsWmsCapabilities::parseLayer( QDomElement const & e, QgsWmsLayerProperty&
732
732
// Ref: 7.2.4.8 Inheritance of layer properties
733
733
subLayerProperty.style = layerProperty.style ;
734
734
subLayerProperty.crs = layerProperty.crs ;
735
- subLayerProperty.boundingBox = layerProperty.boundingBox ;
735
+ subLayerProperty.boundingBoxes = layerProperty.boundingBoxes ;
736
736
subLayerProperty.ex_GeographicBoundingBox = layerProperty.ex_GeographicBoundingBox ;
737
737
// TODO
738
738
@@ -846,7 +846,7 @@ void QgsWmsCapabilities::parseLayer( QDomElement const & e, QgsWmsLayerProperty&
846
846
bbox.box = invAxisBbox;
847
847
}
848
848
849
- layerProperty.boundingBox . push_back ( bbox ) ;
849
+ layerProperty.boundingBoxes << bbox ;
850
850
}
851
851
else
852
852
{
@@ -1180,20 +1180,33 @@ void QgsWmsCapabilities::parseTileSetProfile( QDomElement const &e )
1180
1180
}
1181
1181
else if ( tagName == " BoundingBox" )
1182
1182
{
1183
- l.boundingBox .box = QgsRectangle (
1184
- e1 .attribute ( " minx" ).toDouble (),
1185
- e1 .attribute ( " miny" ).toDouble (),
1186
- e1 .attribute ( " maxx" ).toDouble (),
1187
- e1 .attribute ( " maxy" ).toDouble ()
1188
- );
1183
+ QgsWmsBoundingBoxProperty bb;
1184
+ bb.box = QgsRectangle (
1185
+ e1 .attribute ( " minx" ).toDouble (),
1186
+ e1 .attribute ( " miny" ).toDouble (),
1187
+ e1 .attribute ( " maxx" ).toDouble (),
1188
+ e1 .attribute ( " maxy" ).toDouble ()
1189
+ );
1189
1190
if ( e1 .hasAttribute ( " SRS" ) )
1190
- l. boundingBox .crs = e1 .attribute ( " SRS" );
1191
+ bb .crs = e1 .attribute ( " SRS" );
1191
1192
else if ( e1 .hasAttribute ( " srs" ) )
1192
- l. boundingBox .crs = e1 .attribute ( " srs" );
1193
+ bb .crs = e1 .attribute ( " srs" );
1193
1194
else if ( e1 .hasAttribute ( " CRS" ) )
1194
- l. boundingBox .crs = e1 .attribute ( " CRS" );
1195
+ bb .crs = e1 .attribute ( " CRS" );
1195
1196
else if ( e1 .hasAttribute ( " crs" ) )
1196
- l.boundingBox .crs = e1 .attribute ( " crs" );
1197
+ bb.crs = e1 .attribute ( " crs" );
1198
+ else
1199
+ QgsDebugMsg ( " crs of bounding box undefined" );
1200
+
1201
+ if ( !bb.crs .isEmpty () )
1202
+ {
1203
+ QgsCoordinateReferenceSystem crs;
1204
+ crs.createFromOgcWmsCrs ( bb.crs );
1205
+ if ( crs.isValid () )
1206
+ bb.crs = crs.authid ();
1207
+
1208
+ l.boundingBoxes << bb;
1209
+ }
1197
1210
}
1198
1211
else if ( tagName == " Resolutions" )
1199
1212
{
@@ -1225,9 +1238,10 @@ void QgsWmsCapabilities::parseTileSetProfile( QDomElement const &e )
1225
1238
{
1226
1239
double r = rS.toDouble ();
1227
1240
m.identifier = QString::number ( i );
1228
- m.matrixWidth = ceil ( l.boundingBox .box .width () / m.tileWidth / r );
1229
- m.matrixHeight = ceil ( l.boundingBox .box .height () / m.tileHeight / r );
1230
- m.topLeft = QgsPoint ( l.boundingBox .box .xMinimum (), l.boundingBox .box .yMinimum () + m.matrixHeight * m.tileHeight * r );
1241
+ Q_ASSERT ( l.boundingBoxes .size () == 1 );
1242
+ m.matrixWidth = ceil ( l.boundingBoxes [0 ].box .width () / m.tileWidth / r );
1243
+ m.matrixHeight = ceil ( l.boundingBoxes [0 ].box .height () / m.tileHeight / r );
1244
+ m.topLeft = QgsPoint ( l.boundingBoxes [0 ].box .xMinimum (), l.boundingBoxes [0 ].box .yMinimum () + m.matrixHeight * m.tileHeight * r );
1231
1245
ms.tileMatrices .insert ( r, m );
1232
1246
i++;
1233
1247
}
@@ -1242,20 +1256,22 @@ void QgsWmsCapabilities::parseWMTSContents( QDomElement const &e )
1242
1256
//
1243
1257
1244
1258
mTileMatrixSets .clear ();
1245
- for ( QDomNode n0 = e.firstChildElement ( " TileMatrixSet" ); !n0.isNull (); n0 = n0.nextSiblingElement ( " TileMatrixSet" ) )
1259
+ for ( QDomElement e0 = e.firstChildElement ( " TileMatrixSet" );
1260
+ !e0 .isNull ();
1261
+ e0 = e0 .nextSiblingElement ( " TileMatrixSet" ) )
1246
1262
{
1247
1263
QgsWmtsTileMatrixSet s;
1248
- s.identifier = n0 .firstChildElement ( " ows:Identifier" ).text ();
1249
- s.title = n0 .firstChildElement ( " ows:Title" ).text ();
1250
- s.abstract = n0 .firstChildElement ( " ows:Abstract" ).text ();
1251
- parseKeywords ( n0 , s.keywords );
1264
+ s.identifier = e0 .firstChildElement ( " ows:Identifier" ).text ();
1265
+ s.title = e0 .firstChildElement ( " ows:Title" ).text ();
1266
+ s.abstract = e0 .firstChildElement ( " ows:Abstract" ).text ();
1267
+ parseKeywords ( e0 , s.keywords );
1252
1268
1253
- QString supportedCRS = n0 .firstChildElement ( " ows:SupportedCRS" ).text ();
1269
+ QString supportedCRS = e0 .firstChildElement ( " ows:SupportedCRS" ).text ();
1254
1270
1255
1271
QgsCoordinateReferenceSystem crs;
1256
1272
crs.createFromOgcWmsCrs ( supportedCRS );
1257
1273
1258
- s.wkScaleSet = n0 .firstChildElement ( " WellKnownScaleSet" ).text ();
1274
+ s.wkScaleSet = e0 .firstChildElement ( " WellKnownScaleSet" ).text ();
1259
1275
1260
1276
double metersPerUnit = QGis::fromUnitToUnitFactor ( crs.mapUnits (), QGis::Meters );
1261
1277
@@ -1273,20 +1289,20 @@ void QgsWmsCapabilities::parseWMTSContents( QDomElement const &e )
1273
1289
.arg ( invert ? " yes" : " no" )
1274
1290
);
1275
1291
1276
- for ( QDomNode n1 = n0 .firstChildElement ( " TileMatrix" );
1277
- !n1 .isNull ();
1278
- n1 = n1 .nextSiblingElement ( " TileMatrix" ) )
1292
+ for ( QDomElement e1 = e0 .firstChildElement ( " TileMatrix" );
1293
+ !e1 .isNull ();
1294
+ e1 = e1 .nextSiblingElement ( " TileMatrix" ) )
1279
1295
{
1280
1296
QgsWmtsTileMatrix m;
1281
1297
1282
- m.identifier = n1 .firstChildElement ( " ows:Identifier" ).text ();
1283
- m.title = n1 .firstChildElement ( " ows:Title" ).text ();
1284
- m.abstract = n1 .firstChildElement ( " ows:Abstract" ).text ();
1285
- parseKeywords ( n1 , m.keywords );
1298
+ m.identifier = e1 .firstChildElement ( " ows:Identifier" ).text ();
1299
+ m.title = e1 .firstChildElement ( " ows:Title" ).text ();
1300
+ m.abstract = e1 .firstChildElement ( " ows:Abstract" ).text ();
1301
+ parseKeywords ( e1 , m.keywords );
1286
1302
1287
- m.scaleDenom = n1 .firstChildElement ( " ScaleDenominator" ).text ().toDouble ();
1303
+ m.scaleDenom = e1 .firstChildElement ( " ScaleDenominator" ).text ().toDouble ();
1288
1304
1289
- QStringList topLeft = n1 .firstChildElement ( " TopLeftCorner" ).text ().split ( " " );
1305
+ QStringList topLeft = e1 .firstChildElement ( " TopLeftCorner" ).text ().split ( " " );
1290
1306
if ( topLeft.size () == 2 )
1291
1307
{
1292
1308
if ( invert )
@@ -1304,10 +1320,10 @@ void QgsWmsCapabilities::parseWMTSContents( QDomElement const &e )
1304
1320
continue ;
1305
1321
}
1306
1322
1307
- m.tileWidth = n1 .firstChildElement ( " TileWidth" ).text ().toInt ();
1308
- m.tileHeight = n1 .firstChildElement ( " TileHeight" ).text ().toInt ();
1309
- m.matrixWidth = n1 .firstChildElement ( " MatrixWidth" ).text ().toInt ();
1310
- m.matrixHeight = n1 .firstChildElement ( " MatrixHeight" ).text ().toInt ();
1323
+ m.tileWidth = e1 .firstChildElement ( " TileWidth" ).text ().toInt ();
1324
+ m.tileHeight = e1 .firstChildElement ( " TileHeight" ).text ().toInt ();
1325
+ m.matrixWidth = e1 .firstChildElement ( " MatrixWidth" ).text ().toInt ();
1326
+ m.matrixHeight = e1 .firstChildElement ( " MatrixHeight" ).text ().toInt ();
1311
1327
1312
1328
double res = m.scaleDenom * 0.00028 / metersPerUnit;
1313
1329
@@ -1344,7 +1360,7 @@ void QgsWmsCapabilities::parseWMTSContents( QDomElement const &e )
1344
1360
l.abstract = e0 .firstChildElement ( " ows:Abstract" ).text ();
1345
1361
parseKeywords ( e0 , l.keywords );
1346
1362
1347
- l. boundingBox . crs = " " ;
1363
+ QgsWmsBoundingBoxProperty bb ;
1348
1364
1349
1365
QDomElement bbox = e0 .firstChildElement ( " ows:WGS84BoundingBox" );
1350
1366
if ( !bbox.isNull () )
@@ -1354,43 +1370,46 @@ void QgsWmsCapabilities::parseWMTSContents( QDomElement const &e )
1354
1370
1355
1371
if ( ll.size () == 2 && ur.size () == 2 )
1356
1372
{
1357
- l. boundingBox . box = QgsRectangle ( QgsPoint ( ll[ 0 ]. toDouble (), ll[ 1 ]. toDouble () ),
1358
- QgsPoint ( ur [0 ].toDouble (), ur [1 ].toDouble () ) );
1359
- l. boundingBox . crs = DEFAULT_LATLON_CRS ;
1373
+ bb. crs = DEFAULT_LATLON_CRS;
1374
+ bb. box = QgsRectangle ( QgsPoint ( ll [0 ].toDouble (), ll [1 ].toDouble () ),
1375
+ QgsPoint ( ur[ 0 ]. toDouble (), ur[ 1 ]. toDouble () ) ) ;
1360
1376
}
1361
1377
}
1362
1378
1363
- if ( l.boundingBox .crs .isEmpty () )
1379
+ for ( bbox = e0 .firstChildElement ( " ows:BoundingBox" );
1380
+ !bbox.isNull ();
1381
+ bbox = bbox.nextSiblingElement ( " ows:BoundingBox" ) )
1364
1382
{
1365
- bbox = e0 .firstChildElement ( " ows:BoundingBox" );
1366
- if ( !bbox.isNull () )
1383
+ QStringList ll = bbox.firstChildElement ( " ows:LowerCorner" ).text ().split ( " " );
1384
+ QStringList ur = bbox.firstChildElement ( " ows:UpperCorner" ).text ().split ( " " );
1385
+
1386
+ if ( ll.size () == 2 && ur.size () == 2 )
1367
1387
{
1368
- QStringList ll = bbox.firstChildElement ( " ows:LowerCorner" ).text ().split ( " " );
1369
- QStringList ur = bbox.firstChildElement ( " ows:UpperCorner" ).text ().split ( " " );
1388
+ bb.box = QgsRectangle ( QgsPoint ( ll[0 ].toDouble (), ll[1 ].toDouble () ),
1389
+ QgsPoint ( ur[0 ].toDouble (), ur[1 ].toDouble () ) );
1390
+
1391
+ if ( bbox.hasAttribute ( " SRS" ) )
1392
+ bb.crs = bbox.attribute ( " SRS" );
1393
+ else if ( bbox.hasAttribute ( " srs" ) )
1394
+ bb.crs = bbox.attribute ( " srs" );
1395
+ else if ( bbox.hasAttribute ( " CRS" ) )
1396
+ bb.crs = bbox.attribute ( " CRS" );
1397
+ else if ( bbox.hasAttribute ( " crs" ) )
1398
+ bb.crs = bbox.attribute ( " crs" );
1399
+ else
1400
+ QgsDebugMsg ( " crs of bounding box undefined" );
1370
1401
1371
- if ( ll. size () == 2 && ur. size () == 2 )
1402
+ if ( !bb. crs . isEmpty () )
1372
1403
{
1373
- l.boundingBox .box = QgsRectangle ( QgsPoint ( ll[0 ].toDouble (), ll[1 ].toDouble () ),
1374
- QgsPoint ( ur[0 ].toDouble (), ur[1 ].toDouble () ) );
1375
-
1376
- if ( bbox.hasAttribute ( " SRS" ) )
1377
- l.boundingBox .crs = bbox.attribute ( " SRS" );
1378
- else if ( bbox.hasAttribute ( " srs" ) )
1379
- l.boundingBox .crs = bbox.attribute ( " srs" );
1380
- else if ( bbox.hasAttribute ( " CRS" ) )
1381
- l.boundingBox .crs = bbox.attribute ( " CRS" );
1382
- else if ( bbox.hasAttribute ( " crs" ) )
1383
- l.boundingBox .crs = bbox.attribute ( " crs" );
1404
+ QgsCoordinateReferenceSystem crs;
1405
+ crs.createFromOgcWmsCrs ( bb.crs );
1406
+ if ( crs.isValid () )
1407
+ bb.crs = crs.authid ();
1408
+ l.boundingBoxes << bb;
1384
1409
}
1385
1410
}
1386
1411
}
1387
1412
1388
- if ( l.boundingBox .crs .isEmpty () )
1389
- {
1390
- l.boundingBox .box = QgsRectangle ( -180.0 , -90.0 , 180.0 , 90.0 );
1391
- l.boundingBox .crs = DEFAULT_LATLON_CRS;
1392
- }
1393
-
1394
1413
for ( QDomElement e1 = e0 .firstChildElement ( " Style" );
1395
1414
!e1 .isNull ();
1396
1415
e1 = e1 .nextSiblingElement ( " Style" ) )
@@ -1597,13 +1616,16 @@ void QgsWmsCapabilities::parseWMTSContents( QDomElement const &e )
1597
1616
{
1598
1617
QgsWmtsTileLayer& l = *it;
1599
1618
1600
- if ( l.boundingBox . crs .isEmpty () )
1619
+ if ( l.boundingBoxes .isEmpty () )
1601
1620
{
1602
1621
if ( !detectTileLayerBoundingBox ( l ) )
1603
1622
{
1604
1623
QgsDebugMsg ( " failed to detect bounding box for " + l.identifier + " - using extent of the whole world" );
1605
- l.boundingBox .box = QgsRectangle ( -180.0 , -90.0 , 180.0 , 90.0 );
1606
- l.boundingBox .crs = DEFAULT_LATLON_CRS;
1624
+
1625
+ QgsWmsBoundingBoxProperty bb;
1626
+ bb.crs = DEFAULT_LATLON_CRS;
1627
+ bb.box = QgsRectangle ( -180.0 , -90.0 , 180.0 , 90.0 );
1628
+ l.boundingBoxes << bb;
1607
1629
}
1608
1630
}
1609
1631
}
@@ -1699,8 +1721,11 @@ bool QgsWmsCapabilities::detectTileLayerBoundingBox( QgsWmtsTileLayer& l )
1699
1721
QgsRectangle extent ( tm.topLeft , bottomRight );
1700
1722
extent.normalize ();
1701
1723
1702
- l.boundingBox .box = extent;
1703
- l.boundingBox .crs = tmsIt->crs ;
1724
+ QgsWmsBoundingBoxProperty bb;
1725
+ bb.box = extent;
1726
+ bb.crs = crs.authid ();
1727
+ l.boundingBoxes << bb;
1728
+
1704
1729
return true ;
1705
1730
}
1706
1731
@@ -1731,9 +1756,9 @@ bool QgsWmsCapabilities::shouldInvertAxisOrientation( const QString& ogcCrs )
1731
1756
1732
1757
1733
1758
QgsWmsCapabilitiesDownload::QgsWmsCapabilitiesDownload ( const QString& baseUrl, const QgsWmsAuthorization& auth, QObject *parent )
1734
- : QObject( parent )
1735
- , mBaseUrl( baseUrl )
1736
- , mAuth( auth )
1759
+ : QObject( parent )
1760
+ , mBaseUrl( baseUrl )
1761
+ , mAuth( auth )
1737
1762
{
1738
1763
}
1739
1764
@@ -1764,7 +1789,7 @@ bool QgsWmsCapabilitiesDownload::downloadCapabilities()
1764
1789
connect ( mCapabilitiesReply , SIGNAL ( downloadProgress ( qint64, qint64 ) ), this , SLOT ( capabilitiesReplyProgress ( qint64, qint64 ) ), Qt::DirectConnection );
1765
1790
1766
1791
QEventLoop loop;
1767
- connect (mCapabilitiesReply , SIGNAL (finished ()), &loop, SLOT (quit ()) );
1792
+ connect ( mCapabilitiesReply , SIGNAL ( finished () ), &loop, SLOT ( quit () ) );
1768
1793
loop.exec ( QEventLoop::ExcludeUserInputEvents );
1769
1794
1770
1795
return mError .isEmpty ();
0 commit comments