Skip to content

Commit 8f02861

Browse files
authored
Merge pull request #9861 from qgis/backport-9856-to-release-3_6
[Backport release-3_6] [Server] WMTS - use resolution for bbox calculation
2 parents 4bc8aff + 83397dd commit 8f02861

File tree

11 files changed

+825
-817
lines changed

11 files changed

+825
-817
lines changed

src/server/services/wmts/qgswmtsutils.cpp

+10-4
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ namespace QgsWmts
140140
double top = ( extent.yMinimum() + ( extent.yMaximum() - extent.yMinimum() ) / 2.0 ) + ( row / 2.0 ) * ( tileSize * res );
141141
tmi.extent = QgsRectangle( left, bottom, right, top );
142142

143+
tmi.resolution = res;
143144
tmi.scaleDenominator = scaleDenominator;
144145

145146
calculatedTileMatrixInfoMap[crsStr] = tmi;
@@ -155,8 +156,7 @@ namespace QgsWmts
155156
QgsUnitTypes::DistanceUnit unit = tmi.unit;
156157

157158
// 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;
160160
int column = std::ceil( ( extent.xMaximum() - extent.xMinimum() ) / ( tileSize * resolution ) );
161161
int row = std::ceil( ( extent.yMaximum() - extent.yMinimum() ) / ( tileSize * resolution ) );
162162

@@ -263,7 +263,7 @@ namespace QgsWmts
263263
{
264264
tmi = fixedTileMatrixInfoMap[crsStr];
265265
// Calculate resolution based on scale denominator
266-
resolution = POINTS_TO_M * tmi.scaleDenominator / QgsUnitTypes::fromUnitToUnitFactor( tmi.unit, QgsUnitTypes::DistanceMeters );
266+
resolution = tmi.resolution;
267267
// Get fixed corner
268268
QgsRectangle extent = tmi.extent;
269269
fixedTop = extent.yMaximum();
@@ -805,17 +805,23 @@ namespace QgsWmts
805805

806806
// Tile matrix information
807807
// 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
808810
tileMatrixInfo tmi3857;
809811
tmi3857.ref = QStringLiteral( "EPSG:3857" );
810812
tmi3857.extent = QgsRectangle( -20037508.3427892480, -20037508.3427892480, 20037508.3427892480, 20037508.3427892480 );
813+
tmi3857.resolution = 156543.0339280410;
811814
tmi3857.scaleDenominator = 559082264.0287179;
812815
tmi3857.unit = QgsUnitTypes::DistanceMeters;
813816
m[tmi3857.ref] = tmi3857;
814817

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
816821
tileMatrixInfo tmi4326;
817822
tmi4326.ref = QStringLiteral( "EPSG:4326" );
818823
tmi4326.extent = QgsRectangle( -180, -90, 180, 90 );
824+
tmi4326.resolution = 0.703125000000000;
819825
tmi4326.scaleDenominator = 279541132.0143588675418869;
820826
tmi4326.unit = QgsUnitTypes::DistanceDegrees;
821827
tmi4326.hasAxisInverted = true;

src/server/services/wmts/qgswmtsutils.h

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ namespace QgsWmts
4545

4646
bool hasAxisInverted = false;
4747

48+
double resolution = 0.0;
49+
4850
double scaleDenominator = 0.0;
4951

5052
int lastLevel = -1;

0 commit comments

Comments
 (0)