@@ -137,6 +137,7 @@ namespace QgsWmts
137137 double top = ( extent.yMinimum () + ( extent.yMaximum () - extent.yMinimum () ) / 2.0 ) + ( row / 2.0 ) * ( tileSize * res );
138138 tmi.extent = QgsRectangle ( left, bottom, right, top );
139139
140+ tmi.resolution = res;
140141 tmi.scaleDenominator = scaleDenominator;
141142
142143 tileMatrixInfoMap[crsStr] = tmi;
@@ -152,8 +153,7 @@ namespace QgsWmts
152153 QgsUnitTypes::DistanceUnit unit = tmi.unit ;
153154
154155 // constant
155- double unit_to_m = QgsUnitTypes::fromUnitToUnitFactor ( tmi.unit , QgsUnitTypes::DistanceMeters );
156- double resolution = points_to_m * scaleDenominator / unit_to_m;
156+ double resolution = tmi.resolution ;
157157 int column = std::ceil ( ( extent.xMaximum () - extent.xMinimum () ) / ( tileSize * resolution ) );
158158 int row = std::ceil ( ( extent.yMaximum () - extent.yMinimum () ) / ( tileSize * resolution ) );
159159
@@ -691,17 +691,23 @@ namespace QgsWmts
691691
692692 // Tile matrix information
693693 // to build tile matrix set like Google Mercator or TMS
694+ // some references for resolution
695+ // https://github.com/mapserver/mapcache/blob/master/lib/configuration.c#L94
694696 tileMatrixInfo tmi3857;
695697 tmi3857.ref = QStringLiteral ( " EPSG:3857" );
696698 tmi3857.extent = QgsRectangle ( -20037508.3427892480 , -20037508.3427892480 , 20037508.3427892480 , 20037508.3427892480 );
699+ tmi3857.resolution = 156543.0339280410 ;
697700 tmi3857.scaleDenominator = 559082264.0287179 ;
698701 tmi3857.unit = QgsUnitTypes::DistanceMeters;
699702 m[tmi3857.ref ] = tmi3857;
700703
701-
704+ // To build tile matrix set like mapcache for WGS84
705+ // some references for resolution
706+ // https://github.com/mapserver/mapcache/blob/master/lib/configuration.c#L73
702707 tileMatrixInfo tmi4326;
703708 tmi4326.ref = QStringLiteral ( " EPSG:4326" );
704709 tmi4326.extent = QgsRectangle ( -180 , -90 , 180 , 90 );
710+ tmi4326.resolution = 0.703125000000000 ;
705711 tmi4326.scaleDenominator = 279541132.0143588675418869 ;
706712 tmi4326.unit = QgsUnitTypes::DistanceDegrees;
707713 tmi4326.hasAxisInverted = true ;
0 commit comments