@@ -137,6 +137,7 @@ namespace QgsWmts
137
137
double top = ( extent.yMinimum () + ( extent.yMaximum () - extent.yMinimum () ) / 2.0 ) + ( row / 2.0 ) * ( tileSize * res );
138
138
tmi.extent = QgsRectangle ( left, bottom, right, top );
139
139
140
+ tmi.resolution = res;
140
141
tmi.scaleDenominator = scaleDenominator;
141
142
142
143
tileMatrixInfoMap[crsStr] = tmi;
@@ -152,8 +153,7 @@ namespace QgsWmts
152
153
QgsUnitTypes::DistanceUnit unit = tmi.unit ;
153
154
154
155
// 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 ;
157
157
int column = std::ceil ( ( extent.xMaximum () - extent.xMinimum () ) / ( tileSize * resolution ) );
158
158
int row = std::ceil ( ( extent.yMaximum () - extent.yMinimum () ) / ( tileSize * resolution ) );
159
159
@@ -691,17 +691,23 @@ namespace QgsWmts
691
691
692
692
// Tile matrix information
693
693
// 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
694
696
tileMatrixInfo tmi3857;
695
697
tmi3857.ref = QStringLiteral ( " EPSG:3857" );
696
698
tmi3857.extent = QgsRectangle ( -20037508.3427892480 , -20037508.3427892480 , 20037508.3427892480 , 20037508.3427892480 );
699
+ tmi3857.resolution = 156543.0339280410 ;
697
700
tmi3857.scaleDenominator = 559082264.0287179 ;
698
701
tmi3857.unit = QgsUnitTypes::DistanceMeters;
699
702
m[tmi3857.ref ] = tmi3857;
700
703
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
702
707
tileMatrixInfo tmi4326;
703
708
tmi4326.ref = QStringLiteral ( " EPSG:4326" );
704
709
tmi4326.extent = QgsRectangle ( -180 , -90 , 180 , 90 );
710
+ tmi4326.resolution = 0.703125000000000 ;
705
711
tmi4326.scaleDenominator = 279541132.0143588675418869 ;
706
712
tmi4326.unit = QgsUnitTypes::DistanceDegrees;
707
713
tmi4326.hasAxisInverted = true ;
0 commit comments