@@ -332,16 +332,16 @@ namespace QgsWmts
332
332
// WMTS Project configuration
333
333
bool wmtsProject = project->readBoolEntry ( QStringLiteral ( " WMTSLayers" ), QStringLiteral ( " Project" ) );
334
334
335
- if ( wmtsProject )
335
+ // Root Layer name
336
+ QString rootLayerName = QgsServerProjectUtils::wmsRootName ( *project );
337
+ if ( rootLayerName.isEmpty () && !project->title ().isEmpty () )
336
338
{
337
- layerDef pLayer;
339
+ rootLayerName = project->title ();
340
+ }
338
341
339
- // Root Layer name
340
- QString rootLayerName = QgsServerProjectUtils::wmsRootName ( *project );
341
- if ( rootLayerName.isEmpty () && !project->title ().isEmpty () )
342
- {
343
- rootLayerName = project->title ();
344
- }
342
+ if ( wmtsProject && !rootLayerName.isEmpty () )
343
+ {
344
+ layerDef pLayer;
345
345
pLayer.id = rootLayerName;
346
346
347
347
if ( !project->title ().isEmpty () )
@@ -533,6 +533,7 @@ namespace QgsWmts
533
533
layerElem.appendChild ( layerAbstElem );
534
534
}
535
535
536
+ // WGS84 bounding box
536
537
QDomElement wgs84BBoxElement = doc.createElement ( QStringLiteral ( " ows:WGS84BoundingBox" ) );
537
538
QDomElement wgs84LowerCornerElement = doc.createElement ( QStringLiteral ( " LowerCorner" ) );
538
539
QDomText wgs84LowerCornerText = doc.createTextNode ( qgsDoubleToString ( wmtsLayer.wgs84BoundingRect .xMinimum (), 6 ) + ' ' + qgsDoubleToString ( wmtsLayer.wgs84BoundingRect .yMinimum (), 6 ) );
@@ -544,6 +545,41 @@ namespace QgsWmts
544
545
wgs84BBoxElement.appendChild ( wgs84UpperCornerElement );
545
546
layerElem.appendChild ( wgs84BBoxElement );
546
547
548
+ // Other bounding boxes
549
+ tmsIt = tmsList.begin ();
550
+ for ( ; tmsIt != tmsList.end (); ++tmsIt )
551
+ {
552
+ tileMatrixSet &tms = *tmsIt;
553
+ if ( tms.ref == " EPSG:4326" )
554
+ continue ;
555
+
556
+ QgsRectangle rect;
557
+ QgsCoordinateReferenceSystem crs = QgsCoordinateReferenceSystem::fromOgcWmsCrs ( tms.ref );
558
+ Q_NOWARN_DEPRECATED_PUSH
559
+ QgsCoordinateTransform exGeoTransform ( wgs84, crs );
560
+ Q_NOWARN_DEPRECATED_POP
561
+ try
562
+ {
563
+ rect = exGeoTransform.transformBoundingBox ( wmtsLayer.wgs84BoundingRect );
564
+ }
565
+ catch ( const QgsCsException & )
566
+ {
567
+ continue ;
568
+ }
569
+
570
+ QDomElement bboxElement = doc.createElement ( QStringLiteral ( " ows:BoundingBox" ) );
571
+ bboxElement.setAttribute ( QStringLiteral ( " crs" ), tms.ref );
572
+ QDomElement lowerCornerElement = doc.createElement ( QStringLiteral ( " LowerCorner" ) );
573
+ QDomText lowerCornerText = doc.createTextNode ( qgsDoubleToString ( rect.xMinimum (), 6 ) + ' ' + qgsDoubleToString ( rect.yMinimum (), 6 ) );
574
+ lowerCornerElement.appendChild ( lowerCornerText );
575
+ bboxElement.appendChild ( lowerCornerElement );
576
+ QDomElement upperCornerElement = doc.createElement ( QStringLiteral ( " UpperCorner" ) );
577
+ QDomText upperCornerText = doc.createTextNode ( qgsDoubleToString ( rect.xMaximum (), 6 ) + ' ' + qgsDoubleToString ( rect.yMaximum (), 6 ) );
578
+ upperCornerElement.appendChild ( upperCornerText );
579
+ bboxElement.appendChild ( upperCornerElement );
580
+ layerElem.appendChild ( bboxElement );
581
+ }
582
+
547
583
// Layer Style
548
584
QDomElement layerStyleElem = doc.createElement ( QStringLiteral ( " Style" ) );
549
585
layerStyleElem.setAttribute ( QStringLiteral ( " isDefault" ), QStringLiteral ( " true" ) );
@@ -578,6 +614,22 @@ namespace QgsWmts
578
614
for ( ; tmsIt != tmsList.end (); ++tmsIt )
579
615
{
580
616
tileMatrixSet &tms = *tmsIt;
617
+ if ( tms.ref != " EPSG:4326" )
618
+ {
619
+ QgsRectangle rect;
620
+ QgsCoordinateReferenceSystem crs = QgsCoordinateReferenceSystem::fromOgcWmsCrs ( tms.ref );
621
+ Q_NOWARN_DEPRECATED_PUSH
622
+ QgsCoordinateTransform exGeoTransform ( wgs84, crs );
623
+ Q_NOWARN_DEPRECATED_POP
624
+ try
625
+ {
626
+ rect = exGeoTransform.transformBoundingBox ( wmtsLayer.wgs84BoundingRect );
627
+ }
628
+ catch ( const QgsCsException & )
629
+ {
630
+ continue ;
631
+ }
632
+ }
581
633
582
634
// wmts:TileMatrixSetLink
583
635
QDomElement tmslElement = doc.createElement ( QStringLiteral ( " TileMatrixSetLink" )/* wmts:TileMatrixSetLink*/ );
@@ -587,6 +639,47 @@ namespace QgsWmts
587
639
identifierElem.appendChild ( identifierText );
588
640
tmslElement.appendChild ( identifierElem );
589
641
642
+ // wmts:TileMatrixSetLimits
643
+ QDomElement tmsLimitsElement = doc.createElement ( QStringLiteral ( " TileMatrixSetLimits" )/* wmts:TileMatrixSetLimits*/ );
644
+ int tmIdx = 0 ;
645
+ QList<tileMatrix>::iterator tmIt = tms.tileMatrixList .begin ();
646
+ for ( ; tmIt != tms.tileMatrixList .end (); ++tmIt )
647
+ {
648
+ tileMatrix &tm = *tmIt;
649
+
650
+ QDomElement tmLimitsElement = doc.createElement ( QStringLiteral ( " TileMatrixLimits" )/* wmts:TileMatrixLimits*/ );
651
+
652
+ QDomElement tmIdentifierElem = doc.createElement ( QStringLiteral ( " TileMatrix" ) );
653
+ QDomText tmIdentifierText = doc.createTextNode ( QString::number ( tmIdx ) );
654
+ tmIdentifierElem.appendChild ( tmIdentifierText );
655
+ tmLimitsElement.appendChild ( tmIdentifierElem );
656
+
657
+ QDomElement minTileColElem = doc.createElement ( QStringLiteral ( " MinTileCol" ) );
658
+ QDomText minTileColText = doc.createTextNode ( QString::number ( 0 ) );
659
+ minTileColElem.appendChild ( minTileColText );
660
+ tmLimitsElement.appendChild ( minTileColElem );
661
+
662
+ QDomElement maxTileColElem = doc.createElement ( QStringLiteral ( " MaxTileCol" ) );
663
+ QDomText maxTileColText = doc.createTextNode ( QString::number ( tm.col ) );
664
+ maxTileColElem.appendChild ( maxTileColText );
665
+ tmLimitsElement.appendChild ( maxTileColElem );
666
+
667
+ QDomElement minTileRowElem = doc.createElement ( QStringLiteral ( " MinTileRow" ) );
668
+ QDomText minTileRowText = doc.createTextNode ( QString::number ( 0 ) );
669
+ minTileRowElem.appendChild ( minTileRowText );
670
+ tmLimitsElement.appendChild ( minTileRowElem );
671
+
672
+ QDomElement maxTileRowElem = doc.createElement ( QStringLiteral ( " MaxTileRow" ) );
673
+ QDomText maxTileRowText = doc.createTextNode ( QString::number ( tm.row ) );
674
+ maxTileRowElem.appendChild ( maxTileRowText );
675
+ tmLimitsElement.appendChild ( maxTileRowElem );
676
+
677
+ tmsLimitsElement.appendChild ( tmLimitsElement );
678
+
679
+ ++tmIdx;
680
+ }
681
+ tmslElement.appendChild ( tmsLimitsElement );
682
+
590
683
layerElem.appendChild ( tmslElement );
591
684
}
592
685
0 commit comments