@@ -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 ();
@@ -811,17 +811,23 @@ namespace QgsWmts
811
811
812
812
// Tile matrix information
813
813
// to build tile matrix set like Google Mercator or TMS
814
+ // some references for resolution
815
+ // https://github.com/mapserver/mapcache/blob/master/lib/configuration.c#L94
814
816
tileMatrixInfo tmi3857;
815
817
tmi3857.ref = QStringLiteral ( " EPSG:3857" );
816
818
tmi3857.extent = QgsRectangle ( -20037508.3427892480 , -20037508.3427892480 , 20037508.3427892480 , 20037508.3427892480 );
819
+ tmi3857.resolution = 156543.0339280410 ;
817
820
tmi3857.scaleDenominator = 559082264.0287179 ;
818
821
tmi3857.unit = QgsUnitTypes::DistanceMeters;
819
822
m[tmi3857.ref ] = tmi3857;
820
823
821
-
824
+ // To build tile matrix set like mapcache for WGS84
825
+ // some references for resolution
826
+ // https://github.com/mapserver/mapcache/blob/master/lib/configuration.c#L73
822
827
tileMatrixInfo tmi4326;
823
828
tmi4326.ref = QStringLiteral ( " EPSG:4326" );
824
829
tmi4326.extent = QgsRectangle ( -180 , -90 , 180 , 90 );
830
+ tmi4326.resolution = 0.703125000000000 ;
825
831
tmi4326.scaleDenominator = 279541132.0143588675418869 ;
826
832
tmi4326.unit = QgsUnitTypes::DistanceDegrees;
827
833
tmi4326.hasAxisInverted = true ;
0 commit comments