@@ -140,6 +140,7 @@ namespace QgsWmts
140
140
double top = ( extent.yMinimum () + ( extent.yMaximum () - extent.yMinimum () ) / 2.0 ) + ( row / 2.0 ) * ( tileSize * res );
141
141
tmi.extent = QgsRectangle ( left, bottom, right, top );
142
142
143
+ tmi.resolution = res;
143
144
tmi.scaleDenominator = scaleDenominator;
144
145
145
146
calculatedTileMatrixInfoMap[crsStr] = tmi;
@@ -155,8 +156,7 @@ namespace QgsWmts
155
156
QgsUnitTypes::DistanceUnit unit = tmi.unit ;
156
157
157
158
// constant
158
- double UNIT_TO_M = QgsUnitTypes::fromUnitToUnitFactor ( tmi.unit , QgsUnitTypes::DistanceMeters );
159
- double resolution = POINTS_TO_M * scaleDenominator / UNIT_TO_M;
159
+ double resolution = tmi.resolution ;
160
160
int column = std::ceil ( ( extent.xMaximum () - extent.xMinimum () ) / ( tileSize * resolution ) );
161
161
int row = std::ceil ( ( extent.yMaximum () - extent.yMinimum () ) / ( tileSize * resolution ) );
162
162
@@ -263,7 +263,7 @@ namespace QgsWmts
263
263
{
264
264
tmi = fixedTileMatrixInfoMap[crsStr];
265
265
// Calculate resolution based on scale denominator
266
- resolution = POINTS_TO_M * tmi.scaleDenominator / QgsUnitTypes::fromUnitToUnitFactor ( tmi. unit , QgsUnitTypes::DistanceMeters ) ;
266
+ resolution = tmi.resolution ;
267
267
// Get fixed corner
268
268
QgsRectangle extent = tmi.extent ;
269
269
fixedTop = extent.yMaximum ();
@@ -805,17 +805,23 @@ namespace QgsWmts
805
805
806
806
// Tile matrix information
807
807
// to build tile matrix set like Google Mercator or TMS
808
+ // some references for resolution
809
+ // https://github.com/mapserver/mapcache/blob/master/lib/configuration.c#L94
808
810
tileMatrixInfo tmi3857;
809
811
tmi3857.ref = QStringLiteral ( " EPSG:3857" );
810
812
tmi3857.extent = QgsRectangle ( -20037508.3427892480 , -20037508.3427892480 , 20037508.3427892480 , 20037508.3427892480 );
813
+ tmi3857.resolution = 156543.0339280410 ;
811
814
tmi3857.scaleDenominator = 559082264.0287179 ;
812
815
tmi3857.unit = QgsUnitTypes::DistanceMeters;
813
816
m[tmi3857.ref ] = tmi3857;
814
817
815
-
818
+ // To build tile matrix set like mapcache for WGS84
819
+ // some references for resolution
820
+ // https://github.com/mapserver/mapcache/blob/master/lib/configuration.c#L73
816
821
tileMatrixInfo tmi4326;
817
822
tmi4326.ref = QStringLiteral ( " EPSG:4326" );
818
823
tmi4326.extent = QgsRectangle ( -180 , -90 , 180 , 90 );
824
+ tmi4326.resolution = 0.703125000000000 ;
819
825
tmi4326.scaleDenominator = 279541132.0143588675418869 ;
820
826
tmi4326.unit = QgsUnitTypes::DistanceDegrees;
821
827
tmi4326.hasAxisInverted = true ;
0 commit comments